Example 1: Search by a UniProt accession in the proteins service

Click on the proteins sub-section on the home page, type ‘P21802’ into the ‘accession’ pameter box and click ‘Try it Out!’, as illustrated in Figure 1.

Figure 1: Proteins service interactive documentation. Searching using a UniProt accession, P21802.

The UniProtKB information for P21802 is returned in the ‘Response Body’ window, Figure 2, along with dynamically generated scripting or programming code; Python code illustrated.

Figure 2: Example data returned from the search along with dynamically generated scripting or programming code; Python code illustrated.

Proteins Python example script:

import requests, sys

    requestURL = "https://www.ebi.ac.uk/proteins/api/proteins?offset=0&size=100&accession=P21802"

    r = requests.get(requestURL, headers={ "Accept" : "application/xml"})

    if not r.ok:
        r.raise_for_status()
        sys.exit()

    responseBody = r.text
    print(responseBody)

Example 2: Coordinates search using a gene name

Click on the coordinates sub-section on the home page, add ‘FGFR2’ to the ‘gene’ parameter box the coordinates service and click on ‘Try it Out!’, as illustrated in Figure 3.

Note: optionally add 9606 to the taxid filter box to return only human mapped genomic coordinates.

Figure 3: Coordinates service interactive documentation. Searching using by gene name, FGFR2.

The genomic coordinates for all mapped FGFR2 genes are returned in the response window along with dynamically generated scripting or programming code; Python code illustrated, Figure 4.

Figure 4: Example data returned from the search along with dynamically generated scripting or programming code; Python code illustrated.

Coordinates Python example script:

import requests, sys

    requestURL = "https://www.ebi.ac.uk/proteins/api/coordinates?offset=0&size=100&gene=FGFR2"

    r = requests.get(requestURL, headers={ "Accept" : "application/json"})

    if not r.ok:
        r.raise_for_status()
        sys.exit()

    responseBody = r.text
    print(responseBody)

Example 3: Pagination for coordinates search using a gene name

By default, your search results will be returned using pagination. The url in example 2 will be the same as the following url even if offset and page size parameters not given:

https://www.ebi.ac.uk/proteins/api/coordinates?gene=FGFR2

The first page will be returned with page size 100.

The following url will return the second page of data, records from 101 to 200.

https://www.ebi.ac.uk/proteins/api/coordinates?offset=100&size=100&gene=FGFR2

By checking the response header, you can see the total number of your searching results, showing in Figure 5 as 'x-pagination-totalrecords'. In this case, 250 records in total.

Figure 5: Response header from coordinates search using a gene name.

Please DO NOT send too many requests to get different pages of data if the search results are too large.

You can set page size = -1 and all the searching results will be streamed back to you. In this case, offset value will be ignored. Please see the following curl command to get all the coordinates results searching by a gene name:

curl -X GET --header 'Accept:application/json' 'https://www.ebi.ac.uk/proteins/api/coordinates?size=-1&gene=FGFR2'