Skip to content

APIs (Application Programming Interfaces)

An API (Application Programming Interface) is a set of rules and protocols that allow one application to interact with another. APIs are used to define how software components should interact and are essential for building modern applications. Most biology data portals expose REST APIs over HTTP that return JSON — the same JSON you can load into pandas.

We will be interacting with APIs in order to dynamically retrieve datasets from different sources.

Try it: GET a JSON dataset

UK Bank Holidays is a simple public JSON API with no key required:

Bash
curl https://www.gov.uk/bank-holidays.json | head -c 500
Text Only
curl https://www.gov.uk/bank-holidays.json

Same request in Python (run inside your venv with pip install requests pandas):

Python
import requests
import pandas as pd

r = requests.get("https://www.gov.uk/bank-holidays.json", timeout=30)
r.raise_for_status()  # raises on 4xx/5xx
data = r.json()

# England-and-Wales events -> DataFrame
df = pd.DataFrame(data["england-and-wales"]["events"])
print(df.head())
print(df.shape)

Going further

Real biology APIs need the same pattern plus: an API key sent in a header (Authorization: Bearer ...), pagination (?page=... / ?limit=...), and rate limits (pause between calls). Always read the API docs for auth and usage limits, and never commit keys to git.

Verify it worked

You should see HTTP 200 OK, valid JSON, and a table with title / date columns. If you see 401/403, you need an API key. If you see 429, you hit a rate limit — wait and retry.

Public APIs