From Clicking to Scripting · Subtopic 5 of 7 · 12 min
UniProt, KEGG and RCSB PDB APIs
The Ensembl REST API taught you one shape of programmatic access; this lesson gives you three more, so that "fetch BRCA1 from UniProt / KEGG / PDB" stops meaning "open a browser tab" and starts meaning "run a script."
UniProt REST: one accession, any format you want
UniProt's current REST API lives at rest.uniprot.org, and its simplest trick is content negotiation by URL suffix: append a file extension to an accession and get that format back, no query parameters needed. For BRCA1's entry P38398 (BRCA1_HUMAN, the Swiss-Prot record you met in UniProt: Swiss-Prot vs TrEMBL):
https://rest.uniprot.org/uniprotkb/P38398.fasta # sequence only
https://rest.uniprot.org/uniprotkb/P38398.txt # full flat file
https://rest.uniprot.org/uniprotkb/P38398.gff # feature table (domains, sites)
https://rest.uniprot.org/uniprotkb/P38398.json # structured, script-friendly
https://rest.uniprot.org/uniprotkb/P38398.xml # same data, XML shapeEvery one of those is a plain, bookmarkable URL — paste it into a browser and it works exactly as a script sees it, which makes debugging trivial. In Python, a GET request is all you need:
import requests
entry = requests.get("https://rest.uniprot.org/uniprotkb/P38398.json").json()
name = entry["proteinDescription"]["recommendedName"]["fullName"]["value"]
print(name) # Breast cancer type 1 susceptibility proteinFor anything bigger than one accession — say every reviewed human DNA-repair protein — you switch to the /uniprotkb/search endpoint with a query string and format=tsv, which streams results as a flat table instead of one JSON blob per hit.
KEGG REST: three verbs, one strict rule
KEGG (Kyoto Encyclopedia of Genes and Genomes) exposes pathway, gene, and compound data through rest.kegg.jp, a deliberately minimal API: a handful of operations, no API key, plain text back. The three you will use constantly are get (retrieve a full record), list (enumerate entries in a category), and link (find cross-references between databases). BRCA1's KEGG gene identifier is hsa:672 — hsa for Homo sapiens, 672 matching the same NCBI Gene ID you met when you looked up the gene record directly:
from Bio.KEGG import REST
gene_record = REST.kegg_get("hsa:672").read()
print(gene_record[:200]) # ENTRY, NAME, DEFINITION, ORTHOLOGY...
pathways = REST.kegg_link("pathway", "hsa:672").read()
print(pathways) # tab-separated hsa:672 <-> path:hsa* rowsBiopython's Bio.KEGG.REST module wraps these calls directly — no manual URL building needed. This pairs naturally with Pathways: KEGG and Reactome, where you saw which pathway maps BRCA1 turns up in; now you have the code to pull that list yourself.
Read KEGG's terms of use before you script anything. The REST API is provided for academic use by users at academic institutions — commercial use requires a separate license from Pathway Solutions. KEGG also asks that automated access stay modest, commonly cited as no more than 3 req/s; hammer it faster and you risk being blocked outright, with no API key to fall back on.
RCSB PDB: two APIs for two different questions
The Protein Data Bank splits its programmatic access into two purposes. The Data API, at data.rcsb.org, answers "give me everything about a structure I already know the ID for" — a GET to /rest/v1/core/entry/{id} (REST) or a query to /graphql (GraphQL, letting you request only the fields you need in one round trip). The Search API, at search.rcsb.org, answers the opposite question — "which structures match this criterion?" — accepting a JSON query body describing sequence, resolution, organism, or text filters.
For the BRCA1 structures introduced in PDB: 3D Structures at RCSB and PDBe — 1JNX, the BRCT-repeat region, and 1JM7, the BRCA1/BARD1 RING-domain heterodimer — the Data API call is a single line:
curl -s "https://data.rcsb.org/rest/v1/core/entry/1JM7" | head -c 300That returns the deposition's resolution, experimental method, and citation as JSON. To instead find structures — every human BRCA1 entry solved by X-ray at 2.5 Å or better, say — you would POST a query to the Search API rather than guess IDs by hand.
Comparing the three at a glance
| Provider | Base URL | Auth | Stated rate guidance |
|---|---|---|---|
| UniProt | rest.uniprot.org | none | generous; batch large jobs via /search + format=tsv |
| KEGG | rest.kegg.jp | none, academic-use ToS | commonly cited 3 req/s |
| RCSB PDB | data.rcsb.org / search.rcsb.org | none | no fixed cap published; batch politely |
The pattern underneath all three
Every one of these APIs, like the Ensembl endpoint before it, is a thin wrapper over the same lookups the website performs — a URL suffix instead of a format dropdown, a JSON body instead of a search form. The one habit worth carrying forward is reading each provider's own rate-limit and terms-of-use page before you write a loop, not after it gets your IP blocked. UniProt, KEGG, and RCSB each publish theirs separately, and they do not agree with each other or with NCBI's 3 req/s E-utilities limit from the earlier lesson. Whichever endpoint you call, the payload that comes back is still just FASTA, JSON, or a flat file waiting to be parsed — the same handful of shapes you have already learned to read by eye.