Loading...

API DOCS

Last updated: April 11th, 2022
Image placeholder

Welcome


API is fundamental in Griley Air Freight's functionality and service. We use the API which is documented here for our own use. E.g. our entire webapp is built using this very API!

The purpose of our customer API is to give all customers the ability to create orders in our system without us needing to set anything up. All customers can just do it easily. We do not expect our customers to pull data from our system, although it is possible, we are fully capable of updating our customers databases through their API and that is our preference in practice.

A fair warning: API Usage is monitored and if customers are interacting with the API we will know. All requests are logged.

Getting Started


Griley Air's API is a REST oriented service designed to be completely open and easy to access. As a company we have invested very heavily into our API, so much so that our own apps work on the same API we are documenting here.

Must know

  • Every Griley Air customer connects through our https://grileyair.com domain.
  • Authentication is done with permanent tokens.
  • Returned data is always JSON.
  • All POST data must be JSON string.
  • You will get maximum of 500 records when you do open ended queries (or any other query for that matter).

API Versioning

Currently we are running v1 of our api. You will see all queries are going to /api/v1. We will continuously keep adding to our v1 of the API. We do not expect version to be incremented but if so we would reach out to all clients respectively before any changes were made.

Authentication

Depending on why you need to build an integration with Griley Air Freight, you currently have two options:

  • Permanent token
  • OAuth **Invite only ( data companies servicing multiple customers )

Permanent Token

If you are building an integration with Griley Air you should use a permanent token. This once-off and you really don't have to worry about the OAuth dance.

Permanent token will never expire!

Steps:

  1. Log in to Griley Air
  2. Go to your account home page
  3. Once you are logged in go to https://www.grileyair.com/api/v1/perm_token
  4. Create a dummy client of yours and get an Access Token from there.
  5. You can use this access token as you like! Please note that this token will stop working if you as a user gets de-activated from Griley Air.

Demo Data

To set yourself up for development mode you will need to have an API Key. Next you will need to add they key "Demo" to your header. This will route all your requests to a public sandbox account. Here is a sample on how to perform this:

headers = {
"Content-Type" : "application/json",
"Authorization" : "API_KEY << API_KEY >>",
"Demo" : ""
}

Resources

System ( Shared )

Freight Bill ( Specific )

Airport Transfers ( Specific )

Warehouse Receiving ( Specific )

Endpoints

Method Endpoint Summary

GET

/api/v1/who_am_i Get details for your access connection. Basic user info and security access level. !important : This shows what you can access

GET

/api/v1/ << RESOURCE >> /INFO Get details for a specific resource. This will show all resource attributes and their types.

POST

/api/v1/ << RESOURCE >> /QUERY Query a specific resource. This will return a list of resource objects. Queries can be made on any resource by any data attribute.

POST

/api/v1/ << RESOURCE >> Post data or create a resource object. Currently users create api_transfer_orders objects. Send a blank POST to the resource to get the required attributes to create a new order.
We are releasing this working API to all customers. But if you need something else, contact us, anything is possible. We are always happy to help.

"The Query"

The query is used to query a specific resource. All resources have a query endpoint. Here is a sample payload for a query on api_freight_bill:


                            {
                                "query": [
                                    {
                                        "field": "pronumber",
                                        "operator": "eq",
                                        "value": "123456789"
                                    }, {
                                        "field": "status",
                                        "operator": "eq",
                                        "value": "PENDING"
                                    }
                                ]
                            }                       
                        

The query is an array of objects. Each object has a field, operator, and value. The field is the name of the attribute to query. The operator is the comparison operator. The value is the value to compare the attribute to.

The following operators are supported:
'ne' - Not Equal
'eq' - Equal
'lt' - Less Than
'gt' - Greater Than
'le' - Less Than or Equal
'ge' - Greater Than or Equal

**Queries can only be made on data attributes, not relationships. We will futher develop this feature in the future to allow for queries on relationships.

Sample Code


import requests
import json

headers = {
"Content-Type" : "application/json",
"Authorization" : "API_KEY << API_KEY >>"
}

payload = json(
{ "JSON DATA" : "JSON DATA" }
)

r = requests.post(
headers = headers,
url ='https://www.grileyair.com/api/v1/<< RESOURCE >>',
json = payload
)

results = r.json()

Note: In the headers['Authorization'] there should be one space between API_KEY and << ACTUAL KEY >>. If you are using OAuth2 you will replace API_KEY with OAUTH.