Skip to main content

Installation

Requires Node.js 18+ (uses native fetch). TypeScript 5.0+ recommended.
Current version: v1.1.1view on npm

Initialization

Never hardcode your API key. Store it in an environment variable (TICKETNATION_API_KEY) and load it at runtime. Add .env to your .gitignore to prevent accidental commits.

tn.me()

Get API key and organization info.

tn.events

create(params)

Creates an event in DRAFT status. Optionally include inline ticket types.

createAndPublish(params)

Creates an event and immediately publishes it to the marketplace in a single call. Accepts the same parameters as create().
Use createAndPublish() when you want events to go live immediately. Use create() + publish() separately when you need a review step before going live.

list(params?)

get(idOrSlug)

update(eventId, params)

publish(eventId) / unpublish(eventId) / archive(eventId)

delete(eventId)

Only works on DRAFT events with no sold tickets.

tn.tickets

create(eventId, params)

list(eventId)

get(eventId, ticketId)

update(eventId, ticketId, params)

publish(eventId, ticketId)

markSoldOut(eventId, ticketId)

Sets remainingQuantity to 0.

delete(eventId, ticketId)

Only works if no tickets have been sold.

tn.performers

Manage the performer lineup for an event. Requires events:write scope for mutations, events:read for listing.

create(eventId, params)

list(eventId)

remove(eventId, performerId)

Full example — building a lineup:

tn.schedules

Build a timetable for your event. Schedule entries can optionally link to performers. Requires events:write scope for mutations, events:read for listing.

create(eventId, params)

list(eventId)

update(eventId, scheduleId, params)

remove(eventId, scheduleId)

Full example — building a timetable:

tn.brands

Attach sponsor or partner brands to your event. Requires events:write scope for mutations, events:read for listing.

create(eventId, params)

list(eventId)

remove(eventId, brandId)

Full example — attaching sponsors:

tn.orders

Orders are read-only. Requires orders:read scope.

list(eventId, params?)

get(orderId)

Includes payment details.

tn.venues

search(params)


tn.webhooks

create(params)

Returns the webhook with a secret field — store it securely, it is only shown once.

list()

update(webhookId, params)

delete(webhookId)

test(webhookId)

Sends a test payload to your webhook URL.

deliveries(webhookId, params?)

View delivery history for a webhook.

Utilities

The SDK exports helper functions for common tasks.

formatPeso(amount)

Formats a number as a Philippine Peso string. Returns "Free" for zero.

validatePrice(price)

Validates that a price is a valid number. Throws a TicketnationError if invalid.

Pagination Helpers

paginate()

Async generator that yields one page at a time:

fetchAllPages()

Collects all pages into a single array:
fetchAllPages() loads everything into memory. For large datasets, prefer paginate() which streams one page at a time.

Error Handling

All API errors throw TicketnationError with a hint property that provides actionable guidance:
The error.hint property gives you a human-readable suggestion for how to fix the error. It is especially useful for SCOPE_REQUIRED and VALIDATION_ERROR responses.
Error handling with hints:
See the Error Handling page for the complete list of error codes and troubleshooting tips.

TypeScript Types

All types are exported from the package:

Key Type Definitions