# The API playground

> Try every booking API endpoint with your own trips and departures, see the JSON your website gets, and copy the request as curl or JavaScript.

Source: https://docs.bifrostorbit.com/travel/developers/api-playground/

The **API playground** runs the [booking API](https://docs.bifrostorbit.com/travel/developers/booking-api/) and [GraphQL](https://docs.bifrostorbit.com/travel/developers/graphql/) the way your website does. Open it from **Developers** in the sidebar. It needs no key, and your booking name is filled in for you, such as `northwilds`. It works like the playground in CMS Orbit and the other Orbit apps.

## Run a request

1. Choose **REST** or **GraphQL** at the top left.
2. With REST, pick an endpoint on the left, such as **Trips** or **One country**, and fill in its parameters. Lists offer your own published trips, departures, continents and countries, so you don't need to look up an id.
3. Choose **Run**, or press ⌘ and Enter (Ctrl and Enter on Windows).

The answer appears on the right with its status, such as `200`, how long it took and its size. The copy button next to it copies the whole answer. **Endpoints** at the top (**Schema** with GraphQL) hides or shows the list on the left.

The REST list has **Organisation**, **Trips** and **One trip** under Catalogue, **Destinations**, **One continent** and **One country** under Destinations, and **Price a booking** and **Make a booking** under Booking. The guides endpoints and checking a booking aren't in the list; call them from curl or your code.

The address above the parameters is the one the playground calls, such as `/travel/api/public/northwilds/trips?country=NO`. The curl and JavaScript you copy use the full address your website calls.

Under the parameters, each endpoint describes what it returns, field by field, such as `seatsLeft` or `priceFromByCurrency`.

## GraphQL

With **GraphQL**, the left side shows the schema: every query, such as `trips` or `country`, with its arguments and fields. Tick fields to add them to the query, or write the query yourself. The playground starts with a query for your organisation. Add variables under **Variables**.

## Run with a key

Reading works without a key. To run a request the way your server would, choose **Add a key** at the top and paste a key from [API keys](https://docs.bifrostorbit.com/travel/developers/api-keys/). The button then shows **Key** and the start of the key. With a key that reads drafts, **Trips** and **One trip** also return your draft trips, marked with `"draft": true`.

The key stays in this browser, and the curl and JavaScript you copy include it. Empty the field to run without it again.

## Languages and currencies

Choose a language at the top, such as `nb`, and every request and query asks for it. Without translations, answers are in your main language.

Prices come in every currency a trip is sold in, so the trips endpoints don't need a currency. A quote takes `currency` in its body: the list offers the currencies of the chosen departure's trip.

## Price a booking

**Price a booking** sends a `POST` to `/quote` with a JSON body. The playground fills in an example from your next open departure: two travellers on its first package, its first extra, an active discount code if you have one, and the trip's main currency. Change the body as you like, or choose **Example** to start again.

A quote saves nothing, holds no places and doesn't use up discount codes, so run it as often as you like.

## What isn't run here

Some endpoints are described but can't be run from the playground, marked with a lock:

- **Make a booking:** it creates a real booking, holds places and emails the traveller. Price the same booking with a quote instead.
- **Traveller portal:** these need a traveller signed in with a code from their inbox, and some start real payments.

The booking API article has examples of each.

## Copy the request

Open **curl** or **JavaScript** under the request to see the same request as a command or as `fetch` code, and copy it into your terminal or your website.

## API responses elsewhere

Look for **API response** on **Overview**, the **Trips** list, a trip, a departure, a booking, **Discount codes**, a destination and **Booking settings**. It shows what the booking API answers for that page, with the same curl and JavaScript, without leaving it.
