Skip to main content

Test suite status codecov Documentation Status Language grade: Python

pyAstroApi

Low level library interfacing with NASA's ADSABS api.

Installation

PyPi

pip install pyAstroApi

From source

Install dependencies:

pip install -r requirements.txt

Build and install software

pip install .

Testing locally

Install dependencies:

pip install -r requirements_dev.txt

and then to run with one python version

pytest

or use tox to test multiple versions of python

tox

Getting started

Full documentation can be found at readthedocs.

Here is a quick start guide for the very basics.

ADS Key

First you will need your own ADS api key: https://ui.adsabs.harvard.edu/user/settings/token

This can be saved to the file:

~/.ads/dev_key

Basic searching

To quickly just search and get a set of papers back from ADS:

import pyastroapi.articles

a = articles.journal(search="^farmer year:2020")

The search field can be any standard ADS query. The object a is now a journal which is a dict-like object of article's.

You can also constrcut a journal from a list of bibcodes:

a = articles.journal(bibcodes=["2020ApJ...902L..36F","2021ApJ...923..214F"])

A journal can be accessed either by specifying the bibcode:

paper = a["2020ApJ...902L..36F"]

or iterated over like a list (or accessed with an index, e.g., a[0])

for paper in a:
    print(paper.title)

The object paper is an article which encapsulates all the methods needed to access the information ADS has on a paper. The initial search (Either via access through a journal or by creating an article with: articles.article("2020ApJ...902L..36F")) will fetch a set of standard fields from ADS. Non-standard fields will require additional fetch's to ADS servers, but this is wrapped so all you need to do is try to access the field and the data will be fetched for you.

Most fields can be accessed as properties:

paper.title
paper.author
paper.abstract

Though some fields are function calls:

paper.citations()
paper.references()

Extra information

An article also contains wrappers into some of the other ADS features:

paper.url.journal()

Get the publisher HTML url

paper.pdf.arxiv()

Download the Arxiv pdf to a file given by the papers bibcode (e.g., 2020ApJ...902L..36F.pdf)

paper.export.bibtex()

Get the papers BibTex

paper.metrics.histograms()

Return a histogram of the metric data for the paper

paper.visual.author()

Return the author network visualization for the paper.

API

Functions and classes inside the pyastroapi namespace are provided to provide convenient wrappers around the output of ADSABS API. Though at this time not ever endpoint has a wrapper.

However, the pyastroapi.api namespace provides a low-level API that handles setting all the arguments necessary for each of the API end points.

List of the ADSABS API's are currently implemented inside the pyastroapi.api namespace

  • Search (Including big queries)
  • Stored Search
  • Libraries (apart from editing an existing library)
  • Export
  • Metrics
  • Author Affiliation
  • Citation Helper
  • Classic import (Caveat: I don't have a classic account to test with)
  • Objects
  • Recommender (Except matchdoc)
  • Reference
  • Notifications
  • Visualizations

Contributing

Contributions are welcome either as pull requests or as bug reports. If reporting a bug please include the exact code you used and if applicable the bibcodes for any paper you where trying to access.

Acknowledgements

This project is not affiliated with NASA or ADSABS.

This research has made use of NASA’s Astrophysics Data System Bibliographic Services.

Metadata

Release files for pyastroapi 2.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyastroapi 2.0.4
File Size Uploaded
pyastroapi-2.0.4.tar.gz 25.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyastroapi 2.0.4
File Interpreter ABI Platform
pyastroapi-2.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 56.9 kB

Release files / pyastroapi-2.0.4.tar.gz

Download URL pyastroapi-2.0.4.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5f5acdb4a1bd2f7b3b7d44d8c59bfd3c723330ddf3ba036af1881442dab694de
BLAKE2b-256 checksum
How to use checksums
41c57f3e7a2c1f3a9927a3d6c2ab8acd5fc5cfddef93bbebc7cad7edd9da93e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.1

Release files / pyastroapi-2.0.4-py3-none-any.whl

Download URL pyastroapi-2.0.4-py3-none-any.whl
Size 31.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae0fdc37a711c37aee3bd385e38a889d9dd90f81a14ddcac4202492fe21f4b41
BLAKE2b-256 checksum
How to use checksums
d57bc00fb2ae9d521334f53ffd2a6bbf9ecb924263aa3a7d9c0c182d1e40817d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.1

Release history Release notifications | RSS feed

This release

2.0.4 This release

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page