import { Ticketnation, formatPeso } from 'ticketnation-sdk';
const tn = new Ticketnation({
apiKey: process.env.TICKETNATION_API_KEY!,
});
async function main() {
// 1. Verify your API key works
const info = await tn.me();
console.log(`Connected as: ${info.organization.name}`);
// 2. Search for a venue
const { data: venues } = await tn.venues.search({ query: 'MOA Arena' });
const venueId = venues[0]?.id;
// 3. Create and publish the event in one call
const event = await tn.events.createAndPublish({
name: 'Summer Music Fest 2025',
dateTime: '2025-06-15T18:00:00.000Z',
endDateTime: '2025-06-15T23:00:00.000Z',
venueId,
imageUrl: 'https://example.com/images/summer-fest-cover.jpg',
galleryUrls: [
'https://example.com/images/gallery-1.jpg',
'https://example.com/images/gallery-2.jpg',
],
absorbFees: true,
tickets: [
{
name: 'General Admission',
price: 1500,
quantity: 500,
published: true,
},
{
name: 'VIP',
price: 5000,
quantity: 50,
published: true,
},
],
});
console.log(`Event live: ${event.name} (${event.status})`);
console.log(`GA price: ${formatPeso(1500)}`); // ₱1,500.00
console.log(`VIP price: ${formatPeso(5000)}`); // ₱5,000.00
// 4. Add performers to the lineup
const headliner = await tn.performers.create(event.id, {
name: 'SB19',
type: 'ARTIST',
imageUrl: 'https://example.com/images/sb19.jpg',
description: 'P-pop icons',
});
const dj = await tn.performers.create(event.id, {
name: 'DJ Nix',
type: 'DJ',
});
console.log('Performers added:', headliner.name, dj.name);
// 5. Build the event schedule
await tn.schedules.create(event.id, {
title: 'Doors Open',
startTime: '2025-06-15T17:00:00.000Z',
endTime: '2025-06-15T18:00:00.000Z',
icon: 'door',
});
await tn.schedules.create(event.id, {
title: 'DJ Nix Set',
startTime: '2025-06-15T18:00:00.000Z',
endTime: '2025-06-15T19:30:00.000Z',
performerId: dj.id,
color: '#FF6B35',
});
await tn.schedules.create(event.id, {
title: 'SB19 Live',
startTime: '2025-06-15T20:00:00.000Z',
endTime: '2025-06-15T22:30:00.000Z',
performerId: headliner.id,
description: 'Main stage performance',
color: '#1DB954',
});
console.log('Schedule built');
// 6. Add sponsor brands
await tn.brands.create(event.id, {
name: 'Red Bull',
url: 'https://redbull.com',
imageUrl: 'https://example.com/images/redbull-logo.png',
description: 'Energy drink partner',
});
await tn.brands.create(event.id, {
name: 'Globe Telecom',
url: 'https://globe.com.ph',
imageUrl: 'https://example.com/images/globe-logo.png',
});
console.log('Brands attached');
console.log(`\nDone! View your event at: https://ticketnation.ph/${event.slug}`);
}
main().catch(console.error);