ntrs

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ntrs asks NASA's Technical Reports Server for citations, one search a call, and for the PDF a citation holds.

Public documents need no account and no key. NTRS states no limit, but when it answers 429 it is asking us to stop: nothing more is asked. There are no retries here, and no loops.

How often NTRS is asked, and whether a failure with no word from it is asked again, is the web package's gentle's to say, by Policy; a Doer that goes through it, as web.Through gives, asks gently.

The shape of what NTRS asks and answers is the one its own OpenAPI description gives, at https://ntrs.nasa.gov/api/openapi-yaml.

A search is a POST of JSON to /api/citations/search. A citation is a GET of /api/citations/{id}. A citation lists the files it holds, each with the address it is downloaded from.

Index

Constants

View Source
const Host = "ntrs.nasa.gov"

Host is NTRS's host, as the web package names a host: in lower case, with no dot at its end. A search, a citation and a PDF are all asked of it.

Variables

View Source
var ErrNotFound = errors.New("ntrs: NTRS answered 404, there is no " +
	"such page")

ErrNotFound is what a lookup's error wraps when NTRS answers 404: it has no such citation.

Functions

func AnswerLimit

func AnswerLimit() int64

AnswerLimit is the most bytes the answer to a search or a lookup may hold, as ntrs-answer-most says.

func ParseID

func ParseID(text string) (string, error)

ParseID is an NTRS id from the text given. An id is digits and nothing else: it is put into an address, so nothing more is let in.

func Policy

func Policy() web.Policy

Policy is how NTRS is asked: the pace, the rest, the tries and the opens its numbers say, and the rest the web package's default.

A search is a POST, and the policy says it may be sent again after a failure with no word from NTRS, because it only asks a question. See ntrs-repeats-posts in numbers.yaml for why.

A PDF is a large answer, so the gate is held until its body is closed: a slow download is still the only request to NTRS. That is this package's code saying so, as arXiv's does.

Types

type Archive

type Archive struct{}

Archive is NTRS as celestial-data lists it. NTRS holds reports, not observations of a place on the sky, so a circle finds nothing in it: it is asked by words, through Search and Lookup.

func New

func New() *Archive

New is the archive of NTRS, asked by name only.

func (*Archive) ByNameOnly

func (*Archive) ByNameOnly() bool

ByNameOnly says the archive is asked only when it is named.

func (*Archive) Find

func (*Archive) Find(*celestialdata.Near) ([]*celestialdata.Product,
	error)

Find is what NTRS holds near a position: nothing, since its citations have no place.

func (*Archive) Name

func (*Archive) Name() string

Name is the archive's name as the command line takes it.

type Citation

type Citation struct {
	// contains filtered or unexported fields
}

Citation is a citation NTRS found.

func Lookup

func Lookup(ctx context.Context, doer Doer, id, agent string) (*Citation,
	error)

Lookup asks NTRS for one citation by its id, which it takes only as ParseID does. It sends one request and does not retry. A 404 is an error that wraps ErrNotFound, and a 429 a *Stopped.

func (Citation) FirstAuthor

func (cited Citation) FirstAuthor() string

FirstAuthor is the author NTRS puts first, or none when it names no author.

func (Citation) HasPDF

func (cited Citation) HasPDF() bool

HasPDF is whether the citation lists a PDF to download.

func (Citation) ID

func (cited Citation) ID() string

ID is NTRS's number for the citation, as digits.

func (Citation) PDF

func (cited Citation) PDF() (string, error)

PDF is the address the citation's PDF is downloaded from, or none when it has none. It refuses an address that NTRS wrote that is not a file in this citation's own folder of downloads, so no other address is ever fetched for it.

func (Citation) Title

func (cited Citation) Title() string

Title is the citation's title.

func (Citation) Year

func (cited Citation) Year() string

Year is the year the citation was published, as NTRS writes it, or none when NTRS gave no date.

type Doer

type Doer interface {
	Do(request *http.Request) (*http.Response, error)
}

Doer is what a request is sent through. An *http.Client is one.

type Found

type Found struct {
	// contains filtered or unexported fields
}

Found is what a search found.

func Search(ctx context.Context, doer Doer, query string, asked int,
	agent string) (*Found, error)

Search asks NTRS one question and gives what it found: at most so many citations, in the order NTRS ranks them. It sends one request and does not retry. It refuses an empty query, and a number of citations below one or above what NTRS gives, before it sends anything.

A 429 is NTRS asking us to stop: its error is a *Stopped, for errors.As. Any other status but 200 is an error that names it. The agent is how the request names itself.

func (*Found) Citations

func (found *Found) Citations() []Citation

Citations are the citations NTRS gave, in its order. The list is a copy.

func (*Found) Count

func (found *Found) Count() int

Count is how many citations NTRS says match the query. It may be more than the citations it gave.

type Stopped

type Stopped struct {
	// contains filtered or unexported fields
}

Stopped is NTRS asking us to stop: it answered 429. It holds the wait NTRS asked, as it wrote it, or none.

func (*Stopped) Error

func (stopped *Stopped) Error() string

Error says NTRS asked us to stop, and for how long if it said.

func (*Stopped) Wait

func (stopped *Stopped) Wait() string

Wait is the Retry-After NTRS gave, as it wrote it, or none.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL