API Introduction
UniFi has a powerful API that allows a wide variety of actions to be automated. This includes:
-
Starting transactions
-
Creating and updating reference data
-
Submitting transactions
-
Reading transaction details
-
Reading reference data for use in other applications
You can use the API to integrate your application with UniFi for seamless data transfer.
Use of API's does require some technical knowledge, although this largely depends on the capabilities of the application you are integrating with.
Generating an API Key
The first step in using the UniFi API is to generate an API key. This is used to validate communications with API. To do this go into the 'Settings' option via the cog icon at the top of the UniFi screen and select 'Organisations & Divisions' and then the 'API Key' tab from the right hand pane. If one already exists you can use that, or click the 'Add' button to create a new one.
The API key is the check that calls to the API for your UniFi account are legitimate so it should only be made available to users within your organisation or trusted 3rd parties.
The API key is sent as part of the request header, with the key 'x-api-key'.
JSON
The UniFi API uses JavaScript Object Notation (JSON) to receive data and respond to requests. JSON is a commonly used data-interchange format that is also easy for humans to read and write. Essentially data is a collection of name and value pairs enclosed within curly brackets or "braces", so an example JSON might look something like:
{ "invoice_reference": "INV-1234", "total_value": 123.45 }
If you are not familiar with JSON there are many resources to help you fully understand it, including https://www.w3schools.com/js/js_json_intro.asp. The level of understanding you will required depends on what use you are intending to make of the API and the capabilities of the software you are calling the API from.
Base URL
The base URL for all API calls is
https://<customer_account>.unifiplatform.com/api/
Your customer account is usually the organisation name, and can be checked by viewing any UniFi URL after logging in.