API code exmaples

Below are code snippets for using API from R and python languages.

R framework

Data can be imported directly as CSV or JSON formats. Please refer to the API documentation for instructions on how to specify the output format.

Fetch data as CSV

The code below downloads all Protein data, and plot a histogram of the experiment count.
  protein_data = read.csv(url(""))

Fetch data as JSON

Similar to the code above, we can use jsonlite library to read JSON data into R.
  json_data = fromJSON(url(""))
  protein_data = json_data$results


The easiest way to import data into python is through JSON format, which is natively supported. CSV and XML formats can also be parsed using specialized modules, but will require more elaborate data processing, and thus omitted from this guide. For details refer to CSV and XML.

Fetch data as JSON

We can read JSON data from urls in different ways into python. Here, we use built-in requests library.

  import requests
  r = requests.get('')
  protein_data = r.json()["results"]
  len(protein_data) # print the number of proteins in the database