I think this is more suited to what I actually wanted. A GET request with single id would return what I wanted. However these ids are UIDs (gene id) for NCBI. I wonder whether it is possible to submit transcript ids (for instance NM_XYZ) and receive similar input? I was not able to locate any specs that refer to transcript ids in the help page you linked.
I am looking at NCBI’s api page and I cannot seem to find any endpoint that returns the cDNA by transcript id.
In fact NCBI nuccore has a webpage for this. and if I want to i can scrape the part coming after ORIGIN. however I guess they do not want this (which I really disagree).
Then the question is, where is their REST api that clearly states how to fetch cDNA by transcript id?
2 answers
You can use something like this: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=34577062,24475906&rettype=fasta&retmode=text. Check the help page at https://www.ncbi.nlm.nih.gov/books/NBK25500/.
OMG I just replaced id with 'NM_014491.4', guessing it would return empty string because it is a RefSeq id, not a gene id, but it worked!
I have no idea whether they intended that, because obviously it is not stated in their docs, but I guess I am happy with it. Thank you!
PS: For those who want to do something similar:
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=NM_014491.4&rettype=fasta&retmode=text
so the id can be BOTH gene id or RefSeq , and does not seem to require API key, perfect.
You can use Entrezdirect (sequence truncated):
$ efetch -db nuccore -id "NM_014491.4" -format fasta
>NM_014491.4 Homo sapiens forkhead box P2 (FOXP2), transcript variant 1, mRNA
ACAGACATGAAAGCTAACCGAGGACTTGAGAGACTCAAACTGGTGCTTTTGTCTCTCTCTCTCTGTCTTT
CTCTCTCTCACACACACACTCACACACTCACACACATGCACACACACACATACACACACACAAAAATGAA
GCACTTACTTTAGAAAGATTATGGTAAGCATGCTGGCTCAGTCTTGAACCTTTGTCACCCCTCACGTTGC
I don't think NCBI provides a direct API to access sequence data. You could use Entrezpi (LINK) or Bio.Entrez (LINK) if you need programmatic access.
aah I see, i was hoping for an end point where I could cURL without any dependencies. I will need to install some packages I guess. Thank you.
Log in to answer this question.