API Overview
API Overview
The UniBind RESTful API provides programmatic and human-browsable access to the UniBind database. This is implemented in Python using the Django REST Framework.
API Versioning
Currently, the UniBind API is at version 1, being available at https://unibind.uio.no/api/v1/. New versions will be released here with new URLs and there will be a prior notice before obsoleting any older API version.
Throttling
Our API is using throttling in order to control the rate of requests that clients can make to the API. We allow 25 requests per second from the same IP address, but no limit on the total number of requests.
Please feel free to write to us if you need higher request.
Pagination
To provide a faster response to each request and to prevent larger
accidental downloads, the API provides pagination. Users can increase or
decrease the number of records per pages by setting
page_size
. By default page_size=10
, which can
be increased up to 1000.
https://unibind.uio.no/api/v1/datasets/?page=1&page_size=25
To jump from one page to another, modify the page
parameter:
https://unibind.uio.no/api/v1/datasets/?page=2
Ordering
This supports simple query parameter controlled ordering of results.
The query parameter is named order
.
For example, to order datasets by transcription factor name:
https://unibind.uio.no/api/v1/datasets/?order=tf_name
The client may also specify reverse order by prefixing the field name with '-', like this:
https://unibind.uio.no/api/v1/datasets/?order=-tf_name
Multiple orderings may also be specified:
https://unibind.uio.no/api/v1/datasets/?order=tf_name,version
Output formats
The REST API provides several data renderer types that allow you to
return responses with various media types. The query parameter is named
format
.
Currently, available data formats are json
,
jsonp
, yaml
, api
.
For example, to return all the datasets in JSON format:
https://unibind.uio.no/api/v1/datasets/?format=json
You can set the output format type in three different ways:
- By setting
?format=format
url parameter. For example:- https://unibind.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3/?format=json
- https://unibind.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3/?format=jsonp
- https://unibind.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3/?format=yaml
- https://unibind.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3/?format=api
- By adding
.format
suffix. For example: By using the Accept headers. For example:
curl 'https://unibind.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3' -H 'Accept: application/json' curl 'https://unibind.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3' -H 'Accept: application/javascript' curl 'https://unibind.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3' -H 'Accept: application/yaml' curl 'https://unibind.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3' -H 'Accept: text/html'
If there is a conflict between the Accept headers and the format parameter, the following error message will be returned:
curl 'https://unibind.uio.no/api/v1/datasets/?format=jsonp' -H 'Accept: application/json' { "detail": "Could not satisfy the request's Accept header" }
CORS requests
UniBind API also supports Cross-Origin Resource Sharing (CORS), which enables users to make cross-origin API requests directly from their web application.
Caching
Setting up the cache is very useful to enhance the performance of the API. For this API, we are using Memcached, which is a fast, efficient and entirely memory-based cache server. It is used by sites such as Facebook and Wikipedia to reduce database access and dramatically increase site performance. Memcached runs as a daemon and is allotted a specified amount of RAM. All it does is provide a fast interface for adding, retrieving and deleting data in the cache. All data is stored directly in memory, so there’s no overhead of database or filesystem usage. We are using a Python Memcached binding python-memcached, which is running on localhost (127.0.0.1) port 11211.