Using the API

This document goes into more detail about the various operations you can perform with the API.

Pagination

When making an API request, you usually don't receive all of the results of that request in a single response. This is because some responses could contain thousands of objects so most responses are paginated by default.

Cursor-based Pagination

Cursor-based pagination is the most efficient method of paging and should always be used when possible. A cursor refers to a random string of characters which marks a specific item in a list of data. The cursor will always point to the item, however it will be invalidated if the item is deleted or removed. Therefore, your app shouldn't store cursors or assume that they will be valid in the future.

When reading an edge that supports cursor pagination, you see the following JSON response:

{ 
"data": [ ... Endpoint data is here],
"paging": {
"limit": 10,
"totalCount": 7936,
"totalPages": 794,
"previous": "https://api.oag.com/flights/?limit=10&cursor=006b8729d52d1c1bd1600d7fb06d4d26f4d27a1fe97d06f7914870fad4f052411", 
"next": "https://api.oag.com/flights/?limit=10&cursor=00be40c7ef00f3ab4e6b4339ecfb 125e2638ff151edb844a078f7cf5ee52bc7e1"
}
}

A cursor-paginated edge supports the following parameters:

  • limit : This is the maximum number of objects that may be returned. A query may return fewer than the value of limit due to filtering.

  • totalCount : This is the total amount of records returned by the query.

  • totalPages : This is the total amount of pages returned by the query.

  • next : The API endpoint that will return the next page of data. If not included, this is the last page of data. Stop paging when the next link no longer appears.

  • previous : The API endpoint that will return the previous page of data. If not included, this is the first page of data.

Health

The Health API is a public endpoint which gives information on service health.

Request

GET /health

Response

Depending on the service health status any of the following responses can be returned:

  • HTTP Status 200 OK

  • HTTP Status 503 Service Unavailable

Sample 200 OK response

{
"flightInfo": "healthy",
"flightChanges": "healthy",
"flightInfoAlerts": "healthy"
}

Sample 503 Service Unavailable response

{
"flightInfo": "unhealthy",
"flightChanges": "unhealthy",
"flightInfoAlerts": "unhealthy"
}