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.

Currently, the UniBind API is at version 1, being available at https://unibind2018.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.

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.

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://unibind2018.uio.no/api/v1/datasets/?page=1&page_size=25

To jump from one page to another, modify the page parameter:

https://unibind2018.uio.no/api/v1/datasets/?page=2

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://unibind2018.uio.no/api/v1/datasets/?order=tf_name

The client may also specify reverse order by prefixing the field name with '-', like this:

https://unibind2018.uio.no/api/v1/datasets/?order=-tf_name

Multiple orderings may also be specified:

https://unibind2018.uio.no/api/v1/datasets/?order=tf_name,version

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://unibind2018.uio.no/api/v1/datasets/?format=json

You can set the output format type in three different ways:

  1. By setting ?format=format url parameter. For example:
  2. By adding .format suffix. For example:
  3. By using the Accept headers. For example:

    curl 'https://unibind2018.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3' -H 'Accept: application/json'
    curl 'https://unibind2018.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3' -H 'Accept: application/javascript'
    curl 'https://unibind2018.uio.no/api/v1/datasets/GSE38103.lx2_tgfb1.SMAD3' -H 'Accept: application/yaml'
    curl 'https://unibind2018.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://unibind2018.uio.no/api/v1/datasets/?format=jsonp' -H 'Accept: application/json'
    {
    "detail": "Could not satisfy the request's Accept header"
    }
    

UniBind API also supports Cross-Origin Resource Sharing (CORS), which enables users to make cross-origin API requests directly from their web application.

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.