Client & methods
createClient options, methods, and the ApiResult envelope.
Creating a client
import { createClient } from '@jetronticket/api'
const client = createClient({
apiKey: 'jt_public_...',
})Prop
Type
Methods
One method per endpoint:
| Method | Endpoint |
|---|---|
health() | GET /health (unauthenticated) |
listEvents(params?) | GET /events |
getEvent(slug, options?) | GET /events/{slug} |
getEventGallery(slug, options?) | GET /events/{slug}/gallery |
listTickets(slug, options?) | GET /events/{slug}/tickets |
createReservation(slug, body, options?) | POST /events/{slug}/reservations |
releaseReservation(slug, options?) | DELETE /events/{slug}/reservations |
createOrder(slug, body, options) | POST /events/{slug}/orders |
Every method accepts per-request options with signal (an AbortSignal) and
headers. The checkout methods additionally accept deviceId, which is sent
as the X-Device-ID header: optional when reserving or releasing, required
when creating an order.
The ApiResult envelope
Every method resolves to an ApiResult<T> with the payload already unwrapped
from the response envelope:
interface ApiResult<T> {
data: T // unwrapped payload (null on a 304 Not Modified)
status: number // HTTP status code
etag: string | null // response ETag, when present
notModified: boolean // true when a conditional GET returned 304
response: Response // the raw fetch Response
}Escape hatch: request()
For anything not covered by a dedicated method, request() performs an
authenticated call against the same base URL and unwraps the envelope:
const { data } = await client.request<{ example: string }>('GET', '/some/path', {
query: { key: 'value' },
})Exported types
All request/response types are exported and mirror the
API Reference schemas, including EventSummary, Event,
EventHeadliner, EventArtistProfile, EventGallery, EventList, Ticket,
Reservation, Order, CreateReservationRequest, CreateOrderRequest, and
the enums EventStatus, EventArtistPlatform, TicketStatus, OrderStatus,
and Country:
import type {
Event,
EventGallery,
EventHeadliner,
EventSummary,
Order,
Reservation,
Ticket,
} from '@jetronticket/api'
