API Clients
API clients handle the underlying details of how network requests are made and how responses are decoded. We are using Core API which is a format-independent Document Object Model for representing Web APIs. It is recommended to use the Core API clients described below for a more robust and intuitive way to interact with the UniBind API rather than constructing HTTP requests and decoding responses.
Currently, Core API provides three clients:
As a way of getting started, you can interact with the UniBind API using the sample calls provided below.
Command line client
# Install the command line client $ pip install coreapi-cliTo interact with the API:
# Load the schema document $ coreapi get https://unibind.uio.no/api/v1/docs # Interact with the API endpoint $ coreapi action datasets list -p page=... -p page_size=... -p search=... -p order=... -p biological_condition=... -p cell_line=... -p collection=... -p data_source=... -p has_pvalue=... -p identifier=... -p jaspar_id=... -p model=... -p species=... -p summary=... -p tf_name=... -p threshold_pvalue=... # For example coreapi action datasets list -p collection=Robust -p species=Homo\ sapiens -p tf_name=SMAD3
Python client
# Install the Python client library $ pip install coreapiTo interact with the API:
import coreapi # Initialize a client & load the schema document client = coreapi.Client() schema = client.get("https://unibind.uio.no/api/v1/docs") # Interact with the API endpoint action = ["datasets", "list"] params = { "page": ..., "page_size": ..., "search": ..., "order": ..., "biological_condition": ..., "cell_line": ..., "collection": ..., "data_source": ..., "has_pvalue": ..., "identifier": ..., "jaspar_id": ..., "model": ..., "species": ..., "summary": ..., "tf_name": ..., "threshold_pvalue": ..., } result = client.action(schema, action, params=params) # For example params = { "collection": 'Robust', "tf_name": 'SMAD3', "species": 'Homo sapiens', } result = client.action(schema, action, params=params)
JavaScript client
<!-- Load the JavaScript client library -->
<script src="https://unibind.uio.no/static/rest_framework/js/coreapi-0.1.1.js"></script>
<script src="https://unibind.uio.no/api/v1/docs/schema.js"></script>
To interact with the API:
var coreapi = window.coreapi // Loaded by `coreapi.js` var schema = window.schema // Loaded by `schema.js` // Initialize a client var client = new coreapi.Client() // Interact with the API endpoint var action = ["datasets", "list"] var params = { page: ..., page_size: ..., search: ..., order: ..., biological_condition: ..., cell_line: ..., collection: ..., data_source: ..., has_pvalue: ..., identifier: ..., jaspar_id: ..., model: ..., species: ..., summary: ..., tf_name: ..., threshold_pvalue: ..., } client.action(schema, action, params).then(function(result) { // Return value is in 'result' })
Sample calls
These are sample calls to API from different languages. You can create the query url by using our Live API