FAIR Data Services has been designed with an API-driven approach where all actions that can be performed in the user interface are possible by using the API.
The FAIR API is split into a number of sub-APIs:
- Search API: discover data.
- Datasets API: browse, create, update, and delete datasets.
- Requests API: browse, create and review data access requests.
- Files API: upload attachments to datasets
- Metrics API: obtain metrics from FAIR such as the number of datasets or searches performed.
- Role API: create and/or assign roles to users.
- Configuration Vocabulary API: add or modify links to external locations (e.g. Terms and Conditions)
- Other endpoints (such as selection) are in a beta phase.
The API documentation can be found at your FAIR instance’s /api/docs/ path. For example: https://fair.aridhia.io/api/docs/. The API is described using the OpenAPI v3 specification.
Authenticating against the API
To authenticate against the API, your user’s session access token is required. You must log in to the FAIR user interface to obtain an access token. Note this is not an access key with a defined lifetime which is usable independent of being logged into FAIR. Access tokens periodically refresh (approximately every hour) therefore ensure you have the latest access token when using the API. Access key authentication will be available in a future release. To obtain you access token, you can grab it from your browser’s session storage or directly from the FAIR user interface directly. Navigate to the user avatar, select the ‘About’ dialog and copy your API access token.
Links to your FAIR instance endpoint and API documentation are also provided.
A number of example API calls using Python exist in our FAIR API examples repository. These examples cover searching for data, viewing dataset metadata, creating a dataset and uploading attachments.