Best fares, easy and straightforward integration
Designed with for developers
In the following pages you will learn how to authenticate with our API.
There are two ways of authenticating: with a GET query parameter or with a header. Both behave exactly the same way, so it's up to you to decide which way suits you best. You will be sending a token that will be provided to you.
If Authentication failed, you'll get a 401 Unauthorized Error Response.
What you need to do is send a Authorization header with your request. We'll provide an example using the open-source GuzzleHttp PHP library.
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
$client = new Client();
$url = 'https://faresapi.com/api/v1/data/routes';
$request = new Request('GET', $url, [
// Your first option is to set your header to the Request object (if not using Guzzle's magic methods)
'Authorization' => 'YourTokenHere'
]);
$response = $client->send($request, [
RequestOptions::HEADERS => [
// And your second option is to send the header upon sending the request
'Authorization' => 'YourTokenHere'
]
]);
All you need to do is append the accessToken query parameter to the URL. For example:
$url = 'https://faresapi.com/api/v1/data/routes?accessToken=YourAccessToken';
$json = file_get_contents($url);
$data = json_decode($json, true);
var_dump($data);
// $data will now contain an associative array
In case other query parameters need to be submitted, accessToken goes together with them. Search is an example of that.
Your token is secure because we will never host the API unencrypted.