Programmatic access to On-Line Encyclopedia of Integer Sequences
Asked Answered
N

6

38

Is there a way to search and retrieve the results from On-Line Encyclopedia of Integer Sequences (http://oeis.org) programmatically?

I have searched their site and the results are always returned in html. They do not seem to provide an API but in the policy statement they say its acceptable to access the database programmatically. But how to do it without screen scraping?

Thanks a lot for your help.

Ninth answered 13/5, 2011 at 12:23 Comment(0)
N
11

A URL of the form http://oeis.org/search?fmt=text&q=2,5,14,50,233 gives a nicely formatted text output.

But it seems there is no way to get a single sequence in text form.

Ninth answered 16/5, 2011 at 13:59 Comment(2)
Using oeis.org/search?q=id:A000109&fmt=text solves the latter issue as well. Thanks for your help.Ninth
Is this a custom format or something special that I don't recognize?Oakum
D
26

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.

Despite answered 17/7, 2016 at 13:11 Comment(1)
you can find some documentation here : oeis.org/wiki/JSON_Format,_Compressed_Files However I have not been able to use the API due to CORS problem.Footwork
N
11

A URL of the form http://oeis.org/search?fmt=text&q=2,5,14,50,233 gives a nicely formatted text output.

But it seems there is no way to get a single sequence in text form.

Ninth answered 16/5, 2011 at 13:59 Comment(2)
Using oeis.org/search?q=id:A000109&fmt=text solves the latter issue as well. Thanks for your help.Ninth
Is this a custom format or something special that I don't recognize?Oakum
M
1

If you happen to use Mathematica, it sounds like the following notebook might help. It allows you to specify a sequence and automatically import a detailed list of matching entries from the OEIS:

http://www.brotherstechnology.com/math/oeis_mathematica.html

Marxist answered 29/5, 2013 at 5:35 Comment(0)
Z
0

It looks like direct use of their CGI program is the only API they provide.

URL for Searching the Database

Zebrass answered 15/5, 2011 at 14:50 Comment(0)
C
0

https://oeis.org/search?q=id:A000032&fmt=text

gives the plain text form of an entry in their internal format

https://oeis.org/eishelp1.html

Crossfade answered 26/6, 2016 at 0:35 Comment(0)
H
0

The OEIS website now has json formatted files, enter link description here

Harber answered 27/5, 2023 at 19:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.