Skip to main content

Hello API Key

Goal: Confirm your API key works and you know what a Discovery 401 looks like.
Prep time: ~1 minute

What you’ll use

  • GET /flynet/v1/restaurants with X-API-Key: <key>

Code

const res = await fetch(
  "https://api.staging.blackbird.xyz/flynet/v1/restaurants?page=0&page_size=1",
  { headers: { "X-API-Key": process.env.API_KEY! } },
);

if (res.status === 401) {
  console.log(await res.json());
} else {
  console.log(res.status, await res.json());
}
curl -i "https://api.staging.blackbird.xyz/flynet/v1/restaurants?page=0&page_size=1" \
  -H "X-API-Key: $API_KEY"
200 returns { "restaurants": [...], "pagination": {...} }. A missing or invalid key returns 401 with a JSON envelope, different from the OAuth empty-body 401:
{
  "status": 401,
  "message": "API key is required. Include your key in the X-API-Key header.",
  "error_code": "MISSING_API_KEY"
}
Discovery 401s are JSON. OAuth 401s are empty-body. The two envelopes are not interchangeable; see Pagination + errors.
Next: Fetch a restaurant list: paginate the Discovery surface.