Introduction
Uphance exposes a REST API that allows programmatic access to various data from a Uphance account. Datasets currently exposed include product, SKU, orders, invoices, payments, inventory, pick tickets and receiving tickets. Uphance API also provides webhooks that allow you to execute code in your application after specific events in Uphance.
All API requests will be over HTTPS. All webhook endpoints need to be HTTPS also.
Establishing a Connection With the Uphance API
Prior to making API requests, your application will have to establish a connection with the Uphance API. This is achieved through three calls performed in sequential order.
1. Get an authorization token
Send the user's Uphance username and password to the Uphance API and receive an authorization access token.
POST https://api.uphance.com/oauth/token
This request should include a header "Content-type: application/json" and the following Params:
email: the user's email address
password: the user's password
grant_type: password
Example response:
{
"access_token":"02cd3516f456e7246d0ae013e21ee20b335ed3db68d1c450624e63",
"token_type": "Bearer",
"expires_in": 31536000,
"created_at": 1542214280
}
2. Get a list of Organizations the user has access
A user can have access to multiple organizations. The second step in establishing a connection is to get a list of organizations. This may return one or more organizations.
GET https://api.uphance.com/organisations
This request should include the following headers.
Authorization: Bearer ACCESS_TOKEN
Content-type: application/json
Example response:
{
"organisations": [
{
"id": 9579,
"name": "Uphance Demo"
}
]
}
3. Register the organization with the API
The final step in establishing the connection is to register the organization. This is done through the call Set Current Organization.
POST https://api.uphance.com/organisations/set_current_org
This request should include headers as in step 2 and the following Param:
organizationId: the ID of the organization from Step 2.
Example response:
{
"Status": "Updated"
}
That completes the process of establishing a connection with the API and subsequent requests only need the bearer token. A re-authorization is needed only when the token expires.
Authentication
Each request made to the Uphance API must include a Authorization
header, containing your access token returned above. For example:
Authorization: Bearer ACCESS_TOKEN
You can tell curl to add the header by appending the following to your curl command:
curl -H "Content-type: application/json" "Authorization: Bearer ACCESS_TOKEN"
You must access the API with HTTPS requests. HTTP requests to the API will always fail. Requests without an Authorization header will also fail.
Pagination
GET API endpoints that return multiple records use pagination to limit the number of records returned in a single request. You should use the paging metadata included in the response JSON body to navigate to the subsequent page if you require all records. To avoid rate limiting, you should download each page sequentially and not in parallel.
The metadata is included in a meta
hash at the top level of the JSON document. The following example shows the metadata for the first page in a two page collection.
"meta": {
"current_page": 1,
"next_page": 2,
"prev_page": null,
"total_pages": 2,
"total_count": 128
}
To fetch the second or subsequent pages, repeat the same call with a page parameter. For example, to get page 2 on Get all SKUs, your call would look like this:
GET https://api.uphance.com/skus?page=2
If no meta
hash is present in the response, you can assume that responses from that endpoint are not paginated.