Crate adsabs[][src]

Expand description

adsabs

A Rust client for the SAO/NASA Astrophysics Data System API.

Usage

To use adsabs as a library, add it as a dependency in your Cargo.toml:

[dependencies]
adsabs = "0.1"

For now, only the /search endpoint is supported, as described below. Other endpoints could be manually accessed using Ads::get directly, and pull requests would be welcome!

Examples

To search for highly cited supernova papers, something like the following should do the trick:

use adsabs::prelude::*;

let client = Ads::new("ADS_API_TOKEN")?;
for doc in client.search("supernova")
    .sort("citation_count")
    .iter_docs()
    .limit(5)
{
    println!("{:?}", doc?.title);
}

Don’t forget to replace ADS_API_TOKEN with your ADS settings page, or using another method as described in the API token section below.

The query parameter passed to Ads::search supports all the usual ADS search syntax. So, for example, if you want to search for papers by a particular first author, use something like the following:

use adsabs::prelude::*;

let client = Ads::new("ADS_API_TOKEN")?;
for doc in client.search("author:\"^Dalcanton, J\"").iter_docs().limit(5) {
    println!("{:?}", doc?.title);
}

You can find executable examples of these and other sample usage in the examples directory of the repository on GitHub.

API token

All queries to the ADS API must be authenticated with your API token from the ADS settings page. You can pass your token as a string directly to the client:

let client = Ads::new("ADS_API_TOKEN")?;

Or you can load the token automatically from your environment using AdsBuilder::from_env:

let client = Ads::from_env()?;

In this case, the following locations are checked, in the listed order:

  1. The ADS_API_TOKEN environment variable,
  2. The ADS_DEV_KEY environment variable,
  3. The contents of the ~/.ads/token file, and
  4. The contents of the ~/.ads/dev_key file.

Where these were chosen to be compatible with the locations supported by the Python client ads.

Modules

An interface to the Search endpoint of the ADS API.

Structs

An interface to the NASA ADS API.

A builder that can be used to create an Ads interface with custom settings.

Enums

Type Definitions