Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel #62

Open
wants to merge 51 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
84f4125
README: andycasey/ads -> adsabs/ads
vsudilov Jul 22, 2015
10de3e5
Update README.md
aaccomazzi Sep 23, 2015
163c1db
Update README.md
aaccomazzi Sep 23, 2015
e112fb2
Update README.md
romanchyla Oct 5, 2015
347ac7d
Update search.md
aaccomazzi Oct 5, 2015
ecd3ad8
Update README.md
jonnybazookatone Oct 18, 2015
ac6c631
Documentation for metrics
ehenneken Oct 19, 2015
0e8ac34
Merge pull request #17 from ehenneken/metrics_documentation
ehenneken Oct 19, 2015
b2dfef1
Documentation for export
ehenneken Oct 19, 2015
09a1c8f
Merge pull request #18 from ehenneken/export_documentation
ehenneken Oct 19, 2015
6239f4d
Typo correction
ehenneken Oct 22, 2015
b77a410
Merge pull request #19 from ehenneken/export_README_fix
ehenneken Oct 22, 2015
9ee834f
Closes issue #20 biblib api documentation
jonnybazookatone Nov 3, 2015
acb3ded
Merge pull request #21 from jonnybazookatone/feature/issue#20/biblib-api
jonnybazookatone Nov 3, 2015
bd5cca6
Update README.md
jonnybazookatone Nov 3, 2015
42946f4
Fixed typo
andycasey Nov 4, 2015
138ebc2
Merge pull request #22 from andycasey/master
jonnybazookatone Nov 4, 2015
d08de5d
metrics doc update: proper quoting sample JSON output
ehenneken Nov 18, 2015
923b60c
Merge pull request #24 from ehenneken/metrics_doc_update
ehenneken Nov 18, 2015
8de66d2
Improved search.md
romanchyla Nov 24, 2015
49d7faf
Improved search.md
romanchyla Nov 24, 2015
27bd8b1
Update README.md
aaccomazzi Dec 15, 2015
562db8b
Update search.md
aaccomazzi Feb 18, 2016
54eb976
Updated the list of fields
jonnybazookatone May 27, 2016
edd8962
Added another URL
jonnybazookatone May 27, 2016
7b918e2
Updated fields, with links
jonnybazookatone May 27, 2016
9470566
Merge pull request #27 from jonnybazookatone/enhancement/field-consol…
jonnybazookatone May 27, 2016
47b1b2d
Update README.md
jonnybazookatone Jun 8, 2016
8036328
Point to readthedocs site for ads python client
aaccomazzi Mar 27, 2017
f16010b
Update search.md
romanchyla Apr 10, 2017
3c6a6ca
Update search.md
aaccomazzi May 12, 2017
f1e79c1
Fixed extra space in the Authorization header example
romanchyla Jun 13, 2017
2815a69
Update search.md
aaccomazzi Jun 26, 2017
b65914b
Update search.md
romanchyla May 22, 2018
93b5bda
Fix quotes typo in curl statement in docs
kelockhart Jun 12, 2018
bca6224
Updated documentation and converted it to Jupyter notebooks
kelockhart Jun 29, 2018
04017a5
Merge pull request #41 from kelockhart/jupyter-notebooks
ehenneken Jul 2, 2018
b996a62
Added set operations to libraries notebook
kelockhart Mar 18, 2019
81f1189
Added info on how to download PDFs via the API
kelockhart Mar 19, 2019
9bcd908
Added max number of rows to search API docs
kelockhart Apr 8, 2019
a689911
Added content-type to big query example
kelockhart May 3, 2019
2a79e4a
Added Linux date syntax
kelockhart Oct 15, 2019
4f4ac9e
Updated permissions schema to match microservice
kelockhart Nov 1, 2019
390f058
Update README.md
marblestation Nov 4, 2019
e2033ce
Added info on returning search highlights
kelockhart Nov 22, 2019
c16b1bd
Merge pull request #54 from kelockhart/highlights
kelockhart Nov 22, 2019
b072981
Merge pull request #53 from kelockhart/library-permissions
kelockhart Jan 29, 2020
872c50e
Updated info on sorting by date
kelockhart Feb 21, 2020
1cce361
Merge pull request #60 from kelockhart/date-sort
kelockhart Feb 21, 2020
f49ab22
Minor clarification about export payload format
kelockhart Mar 2, 2020
8b5a66b
Merge pull request #61 from kelockhart/export-format
kelockhart Mar 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 327 additions & 0 deletions Converting_curl_to_python.ipynb

Large diffs are not rendered by default.

183 changes: 183 additions & 0 deletions Export_API.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Export service\n",
"This notebook explains how to retrieve data in BibTeX and other formats for one or more bibcodes.\n",
"\n",
"The base URL for export queries is:\n",
"```\n",
"https://api.adsabs.harvard.edu/v1/export/<format>\n",
"```\n",
"\n",
"where `<format>` should be replaced by the desired export format. For example, to get BibTeX for a set of records, send a request with the POST method to the URL `https://api.adsabs.harvard.edu/v1/export/bibtex`. The following formats are currently supported:\n",
"* BibTeX (`/bibtex`)\n",
"* BibTeX ABS (`/bibtexabs`)\n",
"* ADS (`/ads`)\n",
"* EndNote (`/endnote`)\n",
"* ProCite (`/procite`)\n",
"* RIS (`/ris`)\n",
"* RefWorks (`/refworks`)\n",
"* RSS (`/rss`)\n",
"* MEDLARS (`/medlars`)\n",
"* DC-XML (`/dcxml`)\n",
"* REF-XML (`/refxml`)\n",
"* REFABS-XML (`/refabsxml`)\n",
"* AASTeX (`/aastex`)\n",
"* Icarus (`/icarus`)\n",
"* MNRAS (`/mnras`)\n",
"* Solar Physics (`/soph`)\n",
"* VOTable (`/votable`)\n",
"* Custom format (`/custom`)\n",
"\n",
"The POST payload (set via the `-d` flag) should be in JSON format. To indicate the payload format, you must add the following header to your `curl` request: `-H \"Content-Type: application/json\"`. For the export, the payload accepts the following keys: \n",
"* `bibcode`: **required**; set the value to a list of the bibcodes to export\n",
"* `sort`: optional; set the value to a combination of the field to sort on (see the Fields section in the Search API notebook), followed by a space plus `asc` or `desc` to indicate ascending or descending order. If the sort order is not specified, the default sort is by date, then by bibcode \n",
"* `format`: **required when using custom format**; set the value to a string with the [desired formatting codes](http://adsabs.github.io/help/actions/export)\n",
"\n",
"For example, for most formats the POST payload would take this format: `{\"bibcode\": [\"<bibcode1>\",\"<bibcode2>\", ...], \"sort\": \"<field> <asc or desc>\"}`. For custom format exports, the POST payload would take this format: `{\"bibcode\": [\"<bibcode1>\",\"<bibcode2>\", ...], \"sort\": \"<field> <asc or desc>\", \"format\": \"<custom format string>\"}`\n",
"\n",
"The complete `curl` request should also include your personal API access token, as described in the top-level [README](https://github.com/adsabs/adsabs-dev-api/blob/master/README.md). The complete `curl` request follows this format:\n",
"```\n",
" curl -H \"Authorization: Bearer <your API token>\" -H \"Content-Type: application/json\" https://api.adsabs.harvard.edu/v1/export/<format> -X POST -d '{\"bibcode\":[\"<bibcode1>\",\"<bibcode2>\", ...]}' \n",
"```\n",
"\n",
"Note: the API examples in this notebook assume you're using `curl` statements from the shell command line--you'll see `%%bash` at the top of a cell if its contents should be run in the shell instead of in Python. Guidelines for translating bash `curl` statements into Python can be found in the [converting curl to python notebook](Converting_curl_to_python.ipynb). If you prefer, you can use the unofficial Python package instead; see the top-level [README](https://github.com/adsabs/adsabs-dev-api/blob/master/README.md) for more information."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Examples"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"msg\": \"Retrieved 1 abstracts, starting with number 1.\", \"export\": \"@ARTICLE{2015RaSc...50..916A,\\n author = {{Ads}, A.~G. and {Bergad{\\\\`a}}, P. and {Regu{\\\\'e}}, J.~R. and {Alsina-\\n Pag{\\\\`e}s}, R.~M. and {Pijoan}, J.~L. and {Altadill}, D. and\\n {Badia}, D. and {Graells}, S.},\\n title = \\\"{Vertical and oblique ionospheric soundings over the long haul HF link\\n between Antarctica and Spain}\\\",\\n journal = {Radio Science},\\n keywords = {VIS, OIS, ionosphere},\\n year = 2015,\\n month = Sep,\\n volume = {50},\\n pages = {916-930},\\n doi = {10.1002/2015RS005773},\\n adsurl = {https://ui.adsabs.harvard.edu/#abs/2015RaSc...50..916A},\\n adsnote = {Provided by the SAO/NASA Astrophysics Data System}\\n}\\n\\n\"}"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
" Dload Upload Total Spent Left Speed\n",
"\r",
" 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r",
"100 833 100 798 100 35 798 35 0:00:01 --:--:-- 0:00:01 3062\n"
]
}
],
"source": [
"%%bash\n",
"token=\"your-token-here\"\n",
"# get the BibTeX entry for a single bibcode\n",
"curl -H \"Authorization: Bearer $token\" -H \"Content-Type: application/json\" \\\n",
" https://api.adsabs.harvard.edu/v1/export/bibtex \\\n",
" -X POST -d '{\"bibcode\":[\"2015RaSc...50..916A\"]}'"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"msg\": \"Retrieved 3 abstracts, starting with number 1.\", \"export\": \"\\\\bibitem[Accomazzi, et al.(2000)]{2000A&AS..143...85A} Accomazzi, A., Eichhorn, G., Kurtz, M.~J., et al.\\\\ 2000, Astronomy and Astrophysics Supplement Series, 143, 85.\\n\\\\bibitem[Grant, et al.(2000)]{2000A&AS..143..111G} Grant, C.~S., Accomazzi, A., Eichhorn, G., et al.\\\\ 2000, Astronomy and Astrophysics Supplement Series, 143, 111.\\n\\\\bibitem[Kurtz, et al.(2000)]{2000A&AS..143...41K} Kurtz, M.~J., Eichhorn, G., Accomazzi, A., et al.\\\\ 2000, Astronomy and Astrophysics Supplement Series, 143, 41.\\n\"}"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
" Dload Upload Total Spent Left Speed\n",
"\r",
" 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r",
"100 684 100 574 100 110 574 110 0:00:01 --:--:-- 0:00:01 915\r",
"100 684 100 574 100 110 574 110 0:00:01 --:--:-- 0:00:01 914\n"
]
}
],
"source": [
"%%bash\n",
"token=\"your-token-here\"\n",
"# get the AASTeX entries for multiple bibcodes, sorting by first author\n",
"curl -H \"Authorization: Bearer $token\" -H \"Content-Type: application/json\" \\\n",
" https://api.adsabs.harvard.edu/v1/export/aastex \\\n",
" -X POST \\\n",
" -d '{\"bibcode\": [\"2000A&AS..143...41K\", \"2000A&AS..143...85A\", \"2000A&AS..143..111G\"], \"sort\": \"first_author asc\"}'"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"msg\": \"Retrieved 3 abstracts, starting with number 1.\", \"export\": \"Accomazzi, Eichhorn, Kurtz, Grant \\\\& Murray 2000\\nGrant, Accomazzi, Eichhorn, Kurtz \\\\& Murray 2000\\nKurtz, Eichhorn, Accomazzi, Grant, Murray \\\\& Watson 2000\\n\\n\"}"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
" Dload Upload Total Spent Left Speed\n",
"\r",
" 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r",
"100 363 100 234 100 129 234 129 0:00:01 --:--:-- 0:00:01 1354\n"
]
}
],
"source": [
"%%bash\n",
"token=\"your-token-here\"\n",
"# same as above, but exported using a custom format\n",
"curl -H \"Authorization: Bearer $token\" -H \"Content-Type: application/json\" \\\n",
" https://api.adsabs.harvard.edu/v1/export/custom \\\n",
" -X POST \\\n",
" -d '{\"format\": \"%m %Y\", \"bibcode\": [\"2000A&AS..143...41K\", \"2000A&AS..143...85A\", \"2000A&AS..143..111G\"], \"sort\": \"first_author asc\"}'"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading