I would like to be able to batch download FASTA files from ENSEMBL. I normally would use the API to download them from the ENSEMBL gene IDs. However, the IDs aren't ones I know, only ones I would get from searching on the ENSEMBL website and collecting the IDs manually.

Is there a way I can use the API to query search terms and collect all results that are returned?

So for example, if I use the ENSEMBL website to search "HLA" I could collect the list of IDs (ENSG00000204252 etc. etc.) manually. HLA works okay using the API to query gene IDs because there's only a few terms (A, B, C plus non-classical for class I) but I was wondering if there was a way to directly access the search query one the homepage programmatically, as I may need to do it for some messier examples.

  • $\begingroup$ Can you give an example of the sort of search you're running? There's lots of things in the API that might do what you want but don't think there's a generic "search" call. $\endgroup$
    – agapow
    Jul 13, 2017 at 12:54
  • 1
    $\begingroup$ Yes, sorry I didn't think to do that. I want to search a term associated with a gene family, say "HLA" and retrieve ENSEMBL IDs (or the sequences associated with, but I already have some code to do that) of the results that come up from the search. $\endgroup$
    – TW93
    Jul 13, 2017 at 13:26
  • $\begingroup$ What kind of terms are you looking for: Diseases terms, protein family names (KRT7,, KRT19, KRT11), ...? Why do you need to do so (maybe we can work around this problem) ? $\endgroup$
    – llrs
    Jul 13, 2017 at 15:24
  • 1
    $\begingroup$ Please edit your question and give us a few example IDs and the output you would like to get from them. $\endgroup$
    – terdon
    Jul 13, 2017 at 16:33
  • 2
    $\begingroup$ Yes, but it's hard to understand what you need without an example. You say you want to download FASTA, but also that you want to retrieve IDs. If you give us an example, we can show you how to do it in a way that is applicable to anything but we need an example to understand exactly what you need. $\endgroup$
    – terdon
    Jul 17, 2017 at 8:49

1 Answer 1


I would download the complete geneset FASTA file from ensembl and then parse out the genes you want with a script.

Alternatively, you could do similarly with API. Get all the gene names, select the ones you want, and then pull down each sequence.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.