Technical details of ADS API access and IDL routines


ADS API support

Information about the API is available at: https://github.com/adsabs/adsabs-dev-api.

There's a Google group for the ADS API, available at https://groups.google.com/forum/#!forum/adsabs-dev-api.

Conference data

The standard API query does not return some useful information about conference proceedings. For example, the "booktitle", "series" and "editor" tags that are found in the Bibtex entries for the articles. To get this information, I need to download the Bibtex entry, e.g.,

IDL> bib=cit_get_ads_bibtex('1998ASPC..143..390D')

which is just a string array. I then extract the conference information into a structure by doing:

IDL> info=cit_process_bibtex(bib)

(Since Bibtex text is in Latex format, then I need to do some processing to convert Latex to html format. I do this with the routine cit_convert_latex.pro.)

Constructing an API query

The query is represented simply by a URL. For my purposes, I already have a list of bibcodes corresponding to the papers that I want in my publication list. For these bibcodes I want to send a query to ADS that returns information about these papers, such as titles, authors and citations.

An example of an html query that returns the title of the paper represented by 2015ApJ...799..218Y is:

https://api.adsabs.harvard.edu/v1/search/query?bibcode=2015ApJ...799..218Y&fl=title

However, it's necessary to specify your ADS key for this to work. With the Unix curl command, the query is:

curl -H "Authorization: Bearer [KEY GOES HERE]" \\
"https://api.adsabs.harvard.edu/v1/search/query?bibcode=2015ApJ...799..218Y&fl=title"

Constructing an IDL query

The curl call above can be reproduced in Solarsoft IDL by:

IDL> sock_list, url, json, headers=headers

where json is the output, and url is, for example:

IDL> url='https://api.adsabs.harvard.edu/v1/search/query?bibcode=2015ApJ...799..218Y&fl=title'

and headers is

IDL> headers=['Authorization: Bearer '+ads_key, 'Content-Type: application/json']

where ads_key is a string containing your ADS key.

The output, json, can be converted to an IDL structure with:

IDL> s=json_parse(json,/tostruct)

The output returned from the API varies depending on the query. I have an IDL routine to extract most of the important information for an article into an IDL structure - see cit_get_ads_entry.pro below.

NOTE: the query part of URL (i.e., after "query?") is restricted to 1000 characters. This effectively limits the number of bibcodes you can specify in one query to about 40. The ADS API webpage mentions a "bigquery" alternative option, but I couldn't get this to work. For the routine cit_get_ads_entry.pro, if many bibcodes are specified then I break the query into multiple queries to get around the restriction.

Other routines

The following routines are used by cit_get_ads_entry and cit_author_html:

cit_get_ads_key: checks to see if the user has his/her ADS key set up.

cit_get_ads_bibtex: for a specified bibcode (or codes) returns the bibtex entry.

cit_bbl2str: reads a local bibtex bibliography file (bbl) and converts to an IDL structure. Latex strings are converted to html format.

cit_jour_abbrev: abbreviates some ADS journal names (e.g., ApJ, A&A).

The following routines do conversions from latex to html for various elements of bibtex entries:

cit_process_bibtex: extracts certain elements from a bibtex entry.

cit_conv_latex_jnl: converts a bibtex journal abbreviation (e.g., \apj) to the journal name.

cit_conv_latex_auth: converts bibtex author formats to html.

cit_convert_latex: converts latex symbols (e.g., Greek letters, accents) into html format.



Page maintained by Dr Peter R Young.