Skip to content

Xeni Travel Documentation

These pages of documentation of the XENI Travel API are always in a state of living improvement, so please revist them frequently. We are going to first present a series of quick guides to get you up and started quickly. Read through these and then visit the API documentation. You can also use our openapi definition document in your favorite HTTP tools, such as Insomnia.

Before you Start Some Assumptions

We're assuming that the following environment varialbes are set with your email and password registered with Xeni:

export XENI_API_HOST="https://xenitravelapi-beta01.gigalixirapp.com"
export XENI_USER_EMAIL="some@email.com"
export XENI_USER_PASSWORD="some password"
export XENI_TOKEN=$(curl -X 'POST' $XENI_API_HOST/api/accounts/get_token \
        -H 'accept: application/json' \
        -H 'content-type: application/json' \
        -d '{"user":{"email": "'"$XENI_USER_EMAIL"'", "password": "'"$XENI_USER_PASSWORD"'"}}' \
        | sed "s/{.*\"token\":\"\([^\"]*\).*}/\1/g")

Authentification

In order to authenticate, you need to add an authorization to your HTTP request's headers with its value in this format bearer: XENI_TOKEN

curl -X 'POST'  "$XENI_API_HOST/api/some/api/call" \
-H "accept: application/json" \
-H "content-type: application/json" \
-H "authorization: bearer: $XENI_TOKEN"

Simulated Responses

To avoid hitting the backend services for a full search reulst when you are doing development you can add a custom request header.

-H "x-simulate-return: success"

Ordering or Sorting

To sort the list results from any api, specify fields to order by and the direction of sorting for each field. ?order_by[]=name&order_by[]=age&order_directions[]=asc&order_directions[]=desc

Filtering.

Filtering is complex and and we will try and illustrate it through examples

OPERATOR VALUE WHERE CLAUSE
:==< "Salicaceae" WHERE column = 'Salicaceae'
:!=< "Salicaceae" WHERE column != 'Salicaceae'
:=~< "cyth" WHERE column ILIKE '%cyth%'

Pagination

Unless the set of data is very small the classic "REST GET a list of some records" will return a paged result. In the below example the page of records is found in the entries field, the paging information is in the meta:

{
  "data": []
  "meta": {
        "current_offset": null,
        "current_page": null,
        "end_cursor": "g3QAAAABZAAEbmFtZW0AAAAwJ3QgS2xpbWR1aW4sIFNjaG9vcmwsIE5vcnRoIEhvbGxhbmQsIE5ldGhlcmxhbmRz",
        "errors": [],
        "has_next_page?": true,
        "has_previous_page?": true,
        "next_offset": null,
        "next_page": null,
        "page_size": 50,
        "params": {},
        "previous_offset": null,
        "previous_page": null,
        "start_cursor": "g3QAAAABZAAEbmFtZW0AAAAzIjQuOCIgTWFydHlycyBNZW1vcmlhbCBoYWxsLCBMdmxpYW5nLCBTaGFueGksIENoaW5h",
        "total_count": null,
        "total_pages": null
    }
}
To page forward or back you feed the appropriate cursor value into the query string, below shows an example of paging 10 rows after or before cursor

 ?first=10&after=g3QAAAABZAACaWRiAAACDg==
 ?last=10&before=g3QAAAABZAACaWRiAAACDg==

The Meta information for a query result

  • current_offset - The offset value used in the query when using offset-based pagination or a derived value when using page-based pagination. Always nil when using cursor-based pagination.
  • current_page - The page value used in the query when using page-based pagination or a derived value when using offset-based pagination. Note that the value will be rounded if the offset lies between pages. Always nil when using cursor-based pagination.
  • errors - Any validation errors that occurred. The format is the same as the result of Ecto.Changeset.traverse_errors(changeset, & &1). previous_offset, next_offset, previous_page, next_page - Values based on current_page and current_offset/page_size. Always nil when using cursor-based pagination.
  • start_cursor, end_cursor - The cursors of the first and last record in the result set. Only set when using cursor-based pagination with first/after or last/before. has_previous_page?, has_next_page? - Set in all pagination types. Note that has_previous_page? is always true when using cursor-based pagination with first and after is set; likewise, has_next_page? is always true when using cursor-based pagination with before and last is set.
  • page_size - The page size or limit of the query. Set to the first or last parameter when using cursor-based pagination.
  • params - The original, unvalidated params that were passed. Only set if validation errors occurred.
  • total_count - The total count of records for the given query. Always nil when using cursor-based pagination.
  • total_pages - The total page count based on the total record count and the page size. Always nil when using cursor-based pagination.