Programmatic access to On-Line Encyclopedia of Integer Sequences

The OEIS now provides several points of access, not just ones using their internal format. These seem largely undocumented, so here are all of the endpoints that I have found:

https://oeis.org/search?fmt=json&q=<sequenceTerm>&start=<itemToStartAt>

Returns a JSON formatted response of the results found from the sequenceTerm given. If too many results were returned, count will be > 0 whilst results will be null. If no results were returned, count will be 0. itemToStartAt is used for pagination of results, as only a maximum of 10 are ever returned. This starts at 0. If you wanted to return a second page of results, this would equal 10. Information about what each of the entries means can be found here.

https://oeis.org/search?fmt=text&q=<sequenceTerm>&start=<itemToStartAt>

Exactly the same arguments as before, however this returns it in the OEIS internal format. Which is largely written about here. Unless your project requires it, I’d highly recommend using the JSON format over this.

https://oeis.org/search?fmt=<json|text>&q=id:A<sequenceNumber>

Will return a single result if the sequenceNumber is found. This is the suggested method for obtaining single sequences, as it appears to be far more optimised than some of the alternative methods that can be used as queries. Requests often take under a second. Alternative search query methods can be found on this page.

https://oeis.org/A<sequenceNumber>/graph?png=1

This endpoint can be used to grab the images used to graph the data points. Alternatively, setting png to equal to zero returns the HTML page containing a graph of it.

https://oeis.org/recent.txt

This returns a list of recently updated entries in the OEIS internal format. There are no parameters available, or JSON format, as this seems like a static text file that is simply being served to the client. Due to the length of replies from the OEIS database (for some sequences replies can take above five seconds), I’d highly recommend heavily caching requests and using the above endpoint to update them when they change.

Leave a Comment