Switch to dark mode

Query Anything by ID

Bookings, orders, offers and many other objects have a unique id and implement the Node interface. You can fetch any of them by id with the node query.

When you create a booking or an order, you get its id back. Store the id, and use node later to check the status or fetch the tickets. The API has no webhooks, so reading a booking or an order again is also how you see that it has changed.

How it works

Pass the id to node:

graphql
query {
  node(id: "some-id-here") {
    # Query fields here
  }
}

node can return any type that implements Node, so select the fields with an inline fragment (... on TypeName) for the type you expect. See the GraphQL documentation for details.

An id that matches nothing you can read returns null. A malformed id, such as order_xyz, fails with INVALID_ARGUMENT. If you don't know what type an id belongs to, select __typename.

Examples

Fetching a booking

A booking with its selected offers:

Example: Get booking by ID

graphql
query GetBooking {
  node(id: "booking_66p1m4f270j171x2m6g30282k3") {
    ... on Booking {
      id
      selections {
        ... on JourneyOfferSelection {
          offers {
            id
            price {
              amount
              currency
            }
            parts {
              ... on AdmissionPart {
                conditions {
                  __typename
                  description
                }
                flexibility
                serviceClass
                comfortClass
              }
              ... on ReservationPart {
                conditions {
                  __typename
                  description
                }
                flexibility
                comfortClass
                accommodation {
                  type
                }
              }
            }
          }
        }
      }
    }
  }
}

Fetching an offer

An offer with its price and parts:

Example: Get offer by ID

graphql
query GetOffer {
  node(id: "offer_n0g22075r0y216r632z4h101r5") {
    ... on Offer {
      id
      price {
        amount
        currency
      }
      parts {
        ... on AdmissionPart {
          flexibility
          serviceClass
          comfortClass
        }
        ... on ReservationPart {
          flexibility
          comfortClass
          accommodation {
            type
          }
        }
      }
    }
  }
}

Fetching an order

The most common use is fetching an order to get its tickets or pass codes:

graphql
query GetOrder {
  node(id: "order_70g7f594z356y5v6h5y6r3b5s5") {
    ... on Order {
      id
      status
      items {
        # Get tickets or pass codes
      }
    }
  }
}

Available node types

These types implement Node and can be fetched with node:

Next steps

Booking Tickets
Fetch an order to retrieve its tickets.
Booking Rail Passes
Fetch an order to retrieve its pass codes.
API Types
The full list of fields on each type.