Skill Tracer
Skills › Scientific Agent Skills › database-lookup › uniprot.md

uniprot.md

292 lines · skills/database-lookup/references/uniprot.md at 5f2bc03

Open on GitHub
1# UniProt REST API
2

UniProt REST API

Raw lines 1 to 2
3## Base URL
4
5```
6https://rest.uniprot.org
7```
8

Base URL

https://rest.uniprot.org
Raw lines 3 to 8
9## Identifier handling
11UniProtKB accessions contain 6 or 10 alphanumeric characters under the official accession patterns; do not restrict them to `P`/`Q` plus five digits. Preserve the submitted accession and record the resolved primary accession when a secondary accession redirects. Isoform identifiers such as `P04637-2` add a suffix and require an endpoint that supports isoforms; do not silently strip it and return the canonical sequence.

Identifier handling

UniProtKB accessions contain 6 or 10 alphanumeric characters under the official accession patterns; do not restrict them to P/Q plus five digits. Preserve the submitted accession and record the resolved primary accession when a secondary accession redirects. Isoform identifiers such as P04637-2 add a suffix and require an endpoint that supports isoforms; do not silently strip it and return the canonical sequence.

Raw lines 9 to 12
13## Authentication
15No API key required. All endpoints are public.

Authentication

No API key required. All endpoints are public.

Raw lines 13 to 16
17## Key Endpoints

Key Endpoints

Raw lines 17 to 18
19### 1. Search proteins
21```
22GET /uniprotkb/search
23```
25**Parameters:**
27| Parameter | Type | Description |
28|-----------|--------|-------------|
29| `query` | string | **Required.** Search query using UniProt query syntax (field:value pairs, boolean operators). |
30| `format` | string | `json` (default), `tsv`, `fasta`, `xml`, `list`, `xlsx`, `obo` |
31| `fields` | string | Comma-separated list of columns to return. Key fields: `accession`, `id`, `protein_name`, `gene_names`, `organism_name`, `organism_id`, `length`, `sequence`, `cc_function`, `go_id`, `go`, `xref_pdb`, `reviewed`, `ec`, `cc_subcellular_location`, `ft_domain`, `lineage` |
32| `size` | int | Results per page (max 500, default 25) |
33| `cursor` | string | Pagination cursor (returned in `Link` response header) |
34| `sort` | string | Sort field and direction, e.g. `gene asc`, `length desc`, `annotation_score desc` |
36**Example calls:**
38Search for reviewed human TP53:
39```
40https://rest.uniprot.org/uniprotkb/search?query=(gene:TP53) AND (organism_id:9606) AND (reviewed:true)&format=json&fields=accession,protein_name,gene_names,organism_name,length,cc_function&size=10
41```
43Search by protein name keyword:
44```
45https://rest.uniprot.org/uniprotkb/search?query=(protein_name:insulin) AND (reviewed:true)&format=json&size=5
46```
48Search by EC number (enzyme classification):
49```
50https://rest.uniprot.org/uniprotkb/search?query=(ec:2.7.11.1) AND (organism_id:9606)&format=json&size=25
51```
53Search by Gene Ontology:
54```
55https://rest.uniprot.org/uniprotkb/search?query=(go:0006915) AND (organism_id:9606) AND (reviewed:true)&format=json&size=25
56```
58**Response (JSON):**
59```json
61 "results": [
62 {
63 "entryType": "UniProtKB reviewed (Swiss-Prot)",
64 "primaryAccession": "P04637",
65 "uniProtkbId": "P53_HUMAN",
66 "organism": {
67 "scientificName": "Homo sapiens",
68 "taxonId": 9606
69 },
70 "proteinDescription": {
71 "recommendedName": {
72 "fullName": { "value": "Cellular tumor antigen p53" }
73 }
74 },
75 "genes": [
76 {
77 "geneName": { "value": "TP53" },
78 "synonyms": [{ "value": "P53" }]
79 }
80 ],
81 "sequence": {
82 "value": "MEEPQSDP...",
83 "length": 393,
84 "molWeight": 43653,
85 "crc64": "..."
86 },
87 "comments": [...],
88 "features": [...],
89 "references": [...]
90 }
91 ]
93```
95**Pagination:** The `Link` response header contains the next page URL with the cursor parameter. Follow it to get subsequent pages.
97---

1. Search proteins

GET /uniprotkb/search

Parameters:

ParameterTypeDescription
querystringRequired. Search query using UniProt query syntax (field:value pairs, boolean operators).
formatstringjson (default), tsv, fasta, xml, list, xlsx, obo
fieldsstringComma-separated list of columns to return. Key fields: accession, id, protein_name, gene_names, organism_name, organism_id, length, sequence, cc_function, go_id, go, xref_pdb, reviewed, ec, cc_subcellular_location, ft_domain, lineage
sizeintResults per page (max 500, default 25)
cursorstringPagination cursor (returned in Link response header)
sortstringSort field and direction, e.g. gene asc, length desc, annotation_score desc

Example calls:

Search for reviewed human TP53:

https://rest.uniprot.org/uniprotkb/search?query=(gene:TP53) AND (organism_id:9606) AND (reviewed:true)&format=json&fields=accession,protein_name,gene_names,organism_name,length,cc_function&size=10

Search by protein name keyword:

https://rest.uniprot.org/uniprotkb/search?query=(protein_name:insulin) AND (reviewed:true)&format=json&size=5

Search by EC number (enzyme classification):

https://rest.uniprot.org/uniprotkb/search?query=(ec:2.7.11.1) AND (organism_id:9606)&format=json&size=25

Search by Gene Ontology:

https://rest.uniprot.org/uniprotkb/search?query=(go:0006915) AND (organism_id:9606) AND (reviewed:true)&format=json&size=25

Response (JSON):

{
  "results": [
    {
      "entryType": "UniProtKB reviewed (Swiss-Prot)",
      "primaryAccession": "P04637",
      "uniProtkbId": "P53_HUMAN",
      "organism": {
        "scientificName": "Homo sapiens",
        "taxonId": 9606
      },
      "proteinDescription": {
        "recommendedName": {
          "fullName": { "value": "Cellular tumor antigen p53" }
        }
      },
      "genes": [
        {
          "geneName": { "value": "TP53" },
          "synonyms": [{ "value": "P53" }]
        }
      ],
      "sequence": {
        "value": "MEEPQSDP...",
        "length": 393,
        "molWeight": 43653,
        "crc64": "..."
      },
      "comments": [...],
      "features": [...],
      "references": [...]
    }
  ]
}

Pagination: The Link response header contains the next page URL with the cursor parameter. Follow it to get subsequent pages.


Raw lines 19 to 98
99### 2. Fetch single entry by accession
101```
102GET /uniprotkb/{accession}
103```
105**Parameters:**
107| Parameter | Type | Description |
108|-----------|--------|-------------|
109| `format` | string | `json`, `tsv`, `fasta`, `xml`, `gff` |
111**Example calls:**
113```
114https://rest.uniprot.org/uniprotkb/P04637?format=json
115https://rest.uniprot.org/uniprotkb/P04637.fasta
116```
118---

2. Fetch single entry by accession

GET /uniprotkb/{accession}

Parameters:

ParameterTypeDescription
formatstringjson, tsv, fasta, xml, gff

Example calls:

https://rest.uniprot.org/uniprotkb/P04637?format=json
https://rest.uniprot.org/uniprotkb/P04637.fasta

Raw lines 99 to 119
120### 3. FASTA sequence retrieval
122Append `.fasta` to the accession or use `format=fasta`:
124```
125https://rest.uniprot.org/uniprotkb/P04637.fasta
126```
128Batch FASTA from search:
129```
130https://rest.uniprot.org/uniprotkb/search?query=(gene:BRCA1) AND (organism_id:9606) AND (reviewed:true)&format=fasta
131```
133---

3. FASTA sequence retrieval

Append .fasta to the accession or use format=fasta:

https://rest.uniprot.org/uniprotkb/P04637.fasta

Batch FASTA from search:

https://rest.uniprot.org/uniprotkb/search?query=(gene:BRCA1) AND (organism_id:9606) AND (reviewed:true)&format=fasta

Raw lines 120 to 134
135### 4. ID Mapping (convert between ID types)
137ID mapping is a two-step async process.
139**Step 1: Submit job**
140```
141POST /idmapping/run
142Content-Type: application/x-www-form-urlencoded
144from={dbFrom}&to={dbTo}&ids={comma-separated-ids}
145```
147Common `from`/`to` database names:
148- `UniProtKB_AC-ID` (UniProt accession)
149- `Gene_Name`
150- `GeneID` (NCBI Gene / Entrez Gene)
151- `Ensembl`, `Ensembl_Genomes`
152- `RefSeq_Protein`
153- `PDB`
154- `ChEMBL`
155- `EMBL-GenBank-DDBJ`
156- `STRING`
158Returns:
159```json
160{ "jobId": "abc123def456" }
161```
163**Step 2: Poll and retrieve results**
164```
165GET /idmapping/status/{jobId}
166```
167Poll the status response until no longer running. Then request
168`GET /idmapping/details/{jobId}` and follow its `redirectURL` for the correct
169result resource. A typical result path is:
170```
171GET /idmapping/results/{jobId}?format=json&size=500
172```
174**Example:**
176Map Ensembl gene IDs to UniProt accessions:
177```
178POST /idmapping/run
179from=Ensembl&to=UniProtKB&ids=ENSG00000141510,ENSG00000012048
180```
182Map UniProt to PDB:
183```
184POST /idmapping/run
185from=UniProtKB_AC-ID&to=PDB&ids=P04637,P38398
186```
188**Response (results):**
189```json
191 "results": [
192 {
193 "from": "ENSG00000141510",
194 "to": {
195 "primaryAccession": "P04637",
196 "uniProtkbId": "P53_HUMAN",
197 ...
198 }
199 }
200 ]
202```
204---

4. ID Mapping (convert between ID types)

ID mapping is a two-step async process.

Step 1: Submit job

POST /idmapping/run
Content-Type: application/x-www-form-urlencoded

from={dbFrom}&to={dbTo}&ids={comma-separated-ids}

Common from/to database names:

  • UniProtKB_AC-ID (UniProt accession)
  • Gene_Name
  • GeneID (NCBI Gene / Entrez Gene)
  • Ensembl, Ensembl_Genomes
  • RefSeq_Protein
  • PDB
  • ChEMBL
  • EMBL-GenBank-DDBJ
  • STRING

Returns:

{ "jobId": "abc123def456" }

Step 2: Poll and retrieve results

GET /idmapping/status/{jobId}

Poll the status response until no longer running. Then request GET /idmapping/details/{jobId} and follow its redirectURL for the correct result resource. A typical result path is:

GET /idmapping/results/{jobId}?format=json&size=500

Example:

Map Ensembl gene IDs to UniProt accessions:

POST /idmapping/run
from=Ensembl&to=UniProtKB&ids=ENSG00000141510,ENSG00000012048

Map UniProt to PDB:

POST /idmapping/run
from=UniProtKB_AC-ID&to=PDB&ids=P04637,P38398

Response (results):

{
  "results": [
    {
      "from": "ENSG00000141510",
      "to": {
        "primaryAccession": "P04637",
        "uniProtkbId": "P53_HUMAN",
        ...
      }
    }
  ]
}

Raw lines 135 to 205
206### 5. UniRef (clustered sequences)
208```
209GET /uniref/search?query={query}&format=json
210GET /uniref/{id}
211```
213Cluster IDs: `UniRef100_P04637`, `UniRef90_P04637`, `UniRef50_P04637`
215---

5. UniRef (clustered sequences)

GET /uniref/search?query={query}&format=json
GET /uniref/{id}

Cluster IDs: UniRef100_P04637, UniRef90_P04637, UniRef50_P04637


Raw lines 206 to 216
217### 6. UniParc (sequence archive)
219```
220GET /uniparc/search?query={query}&format=json
221GET /uniparc/{upi}
222```
224---

6. UniParc (sequence archive)

GET /uniparc/search?query={query}&format=json
GET /uniparc/{upi}

Raw lines 217 to 225
226### 7. Proteomes
228```
229GET /proteomes/search?query=(organism_id:9606)&format=json
230GET /proteomes/{upid}
231```
233Example — human reference proteome:
234```
235https://rest.uniprot.org/proteomes/UP000005640?format=json
236```
238---

7. Proteomes

GET /proteomes/search?query=(organism_id:9606)&format=json
GET /proteomes/{upid}

Example — human reference proteome:

https://rest.uniprot.org/proteomes/UP000005640?format=json

Raw lines 226 to 239
240### 8. Taxonomy
242```
243GET /taxonomy/search?query={query}&format=json
244GET /taxonomy/{taxonId}
245```
247---

8. Taxonomy

GET /taxonomy/search?query={query}&format=json
GET /taxonomy/{taxonId}

Raw lines 240 to 248
249## Query Syntax
251UniProt search queries support field:value syntax with boolean operators:
253- `(gene:TP53)` -- gene name
254- `(organism_id:9606)` -- NCBI taxonomy ID (9606 = human, 10090 = mouse)
255- `(organism_name:"Homo sapiens")` -- organism name
256- `(reviewed:true)` -- Swiss-Prot only (manually reviewed)
257- `(protein_name:kinase)` -- protein name contains keyword
258- `(ec:2.7.11.1)` -- enzyme classification
259- `(go:0006915)` -- Gene Ontology term ID
260- `(xref:pdb-4HHB)` -- cross-reference
261- `(length:[100 TO 300])` -- sequence length range
262- `(cc_disease:cancer)` -- disease involvement
263- `(ft_domain:SH2)` -- domain annotation
264- `(cc_subcellular_location:nucleus)` -- subcellular location
265- `(date_modified:[2024-01-01 TO *])` -- modification date
267Combine with `AND`, `OR`, `NOT`:
268```
269(gene:BRCA1) AND (organism_id:9606) AND (reviewed:true)
270```

Query Syntax

UniProt search queries support field:value syntax with boolean operators:

  • (gene:TP53) -- gene name
  • (organism_id:9606) -- NCBI taxonomy ID (9606 = human, 10090 = mouse)
  • (organism_name:"Homo sapiens") -- organism name
  • (reviewed:true) -- Swiss-Prot only (manually reviewed)
  • (protein_name:kinase) -- protein name contains keyword
  • (ec:2.7.11.1) -- enzyme classification
  • (go:0006915) -- Gene Ontology term ID
  • (xref:pdb-4HHB) -- cross-reference
  • (length:[100 TO 300]) -- sequence length range
  • (cc_disease:cancer) -- disease involvement
  • (ft_domain:SH2) -- domain annotation
  • (cc_subcellular_location:nucleus) -- subcellular location
  • (date_modified:[2024-01-01 TO *]) -- modification date

Combine with AND, OR, NOT:

(gene:BRCA1) AND (organism_id:9606) AND (reviewed:true)
Raw lines 249 to 271
272## Rate Limits
274- No hard published rate limit, but excessive requests will be throttled.
275- Use pagination (`size` + `cursor`) to batch results.
276- Batch ID mapping jobs instead of one-at-a-time lookups.
277- For large downloads, use the streaming endpoints or FTP site.
278- Respect `Retry-After` headers if you receive HTTP 429.

Rate Limits

  • No hard published rate limit, but excessive requests will be throttled.
  • Use pagination (size + cursor) to batch results.
  • Batch ID mapping jobs instead of one-at-a-time lookups.
  • For large downloads, use the streaming endpoints or FTP site.
  • Respect Retry-After headers if you receive HTTP 429.
Raw lines 272 to 279
280## Error Format
282```json
284 "url": "https://rest.uniprot.org/...",
285 "messages": ["Error message here"]
287```
289HTTP 400 for bad queries, 404 for not found, 429 for rate limiting, 500 for server errors.
291Mapping namespaces are directional: check `https://rest.uniprot.org/configure/idmapping/fields`
292for allowed `from`/`to` values. Preserve unmapped IDs and one-to-many mappings.

Error Format

{
  "url": "https://rest.uniprot.org/...",
  "messages": ["Error message here"]
}

HTTP 400 for bad queries, 404 for not found, 429 for rate limiting, 500 for server errors.

Mapping namespaces are directional: check https://rest.uniprot.org/configure/idmapping/fields for allowed from/to values. Preserve unmapped IDs and one-to-many mappings.

Raw lines 280 to 292