Export service to output ADS records with various formats
500K+
This microservice exports ADS records with various formats including BibTex, AASTex, and multiple fielded and xml options.
$ virtualenv python
$ source python/bin/activate
$ pip install -r requirements.txt
$ pip install -r dev-requirements.txt
$ vim local_config.py # edit, edit
On your desktop run:
$ py.test
To get e.g. BibTeX for a set of records you do a POST request to the endpoint
https://api.adsabs.harvard.edu/v1/export/bibtex
within the POST header payload is defined as
{"bibcode":["<bibcode1>","<bibcode2>", ...]}
For example to get the BibTeX for the record with bibcode 2015ApJS..219...21Z, you would do
curl -H "Authorization: Bearer <your API token>" -H "Content-Type: application/json" -X POST -d '{"bibcode":["2015ApJS..219...21Z"]}' https://api.adsabs.harvard.edu/v1/export/bibtex
and the API then responds in JSON with
{u'msg': u'Retrieved 1 abstracts, starting with number 1. Total number selected: 1.', u'export': u'@ARTICLE{2015ApJS..219...21Z,\n author = {{Zhang}, M. and {Fang}, M. and {Wang}, H. and {Sun}, J. and \n\t{Wang}, M. and {Jiang}, Z. and {Anathipindika}, S.},\n title = "{A Deep Near-infrared Survey toward the Aquila Molecular Cloud. I. Molecular Hydrogen Outflows}",\n journal = {\\apjs},\narchivePrefix = "arXiv",\n eprint = {1506.08372},\n primaryClass = "astro-ph.SR",\n keywords = {infrared: ISM, ISM: jets and outflows, shock waves, stars: formation, stars: winds, outflows},\n year = 2015,\n month = aug,\n volume = 219,\n eid = {21},\n pages = {21},\n doi = {10.1088/0067-0049/219/2/21},\n adsurl = {http://adsabs.harvard.edu/abs/2015ApJS..219...21Z},\n adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n}\n\n'}
Note that there is an optional parameter sort for sorting the records from solr. The default sort option (if omitted) is by date desc, bibcode desc. For example
curl -H "Authorization: Bearer <your API token>" -H "Content-Type: application/json" -X POST -d '{"bibcode":["2015ApJS..219...21Z", "2018AAS...23221409A"], "sort":"bibcode desc"}' https://api.adsabs.harvard.edu/v1/export/bibtex
Note that for endpoints /bibtex and /bibtexabs optional parameters maxauthor and keyformat can be passed in.
maxauthor is maxinum number of users displayed. The default values for maxauthor for /bibtex and /bibtexabs respectivley are 10 and 0, where 0 means all.
keyformat allows user to customize bibtex key and could contain some combination of authors' last name(s), publication year, journal, and bibcode. User is now able to pick the key generation algorithm by specifying a custom format for it. To provide a specific example, this is our default format for 2019AAS...23338108A:
@INPROCEEDINGS{2019AAS...23338108A,
author = {{Accomazzi}, Alberto and {Kurtz}, Michael J. and {Henneken}, Edwin and
...
Now user can define one of the following:
Accomazzi:2019 -- %1H:%Y
Accomazzi:2019:AAS -- %1H:%Y:%q
Accomazzi2019 -- %1H%Y
Accomazzi2019AAS -- %1H%Y%q
AccomazziKurtz2019 -- %2H%Y
Note that for endpoint /rss an optional parameter link can be passed in. link is the query url that generated the bibcodes.
For example querying ADS Bumblebee for
author:"accomazzi" and year:2018
at the end of March 2018, returns the following 4 bibcodes, and generates the url as specified below:
{"bibcode":["2018arXiv180303598K","2018arXiv180101021FB","2018AAS...23136217A","2018AAS...23130709A"], "link":"https://ui.adsabs.harvard.edu/#search/q=author%3A%22accomazzi%22%20and%20year%3A2018&sort=date%20desc%2C%20bibcode%20desc"}
which can be passed as payload to /rss endpoint.
{"bibcode":["1980ApJS...44..137K","1980ApJS...44..489B"], "style":"", "format":"", sort:"date desc, bibcode, desc"}
where style can be: aastex, icarus, mnras, soph, aspc, apj, rhrv and format can be: 1, 2 or 3, for output formats Unicode, HTML or LaTeX respectively.
{"bibcode":["1980ApJS...44..137K","1980ApJS...44..489B"], "format":"%ZEncoding:latex%ZLinelength:0\bibitem[%4m(%Y)]{%R} %5.3l\ %Y, %j, %V, %p.\n"}
GET endpoints are similar to the POSTS endpoints. The curl command has the following syntax:
curl -H "Authorization: Bearer <your API token>" <endpoint>/<bibcode>`
curl -H "Authorization: Bearer <your API token>" -H "Content-Type: application/json" -X POST -d <payload> <endpoint>
where <endpoint> is /convert and <payload> is formatted as:
{"format":}
For example:
curl -H "Authorization: Bearer <your API token>" -H "Content-Type: application/json" -X POST -d '{"format":"\\\\bibitem[%\\2m%(y)]\\{%za1%y} %\\8l %\\Y,%\\j,%\\V,%\\p"}' https://api.adsabs.harvard.edu/v1/export/convert
Golnaz, Edwin
Content type
Image
Digest
Size
274.7 MB
Last updated
about 7 years ago
docker pull adsabs/export_service