nasacmr

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package nasacmr is the library behind the nasacmr command line: the HTTP client, request shaping, and the typed data models for NASA's Common Metadata Repository (CMR), which indexes Earth science data collections and granules.

The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load. Build your endpoint calls and JSON decoding on top of it.

Index

Constants

View Source
const BaseURL = "https://cmr.earthdata.nasa.gov/search"

BaseURL is the CMR search endpoint every request is built from.

View Source
const DefaultUserAgent = "nasacmr-cli/0.1.0"

DefaultUserAgent identifies the client to CMR.

View Source
const Host = "cmr.earthdata.nasa.gov"

Host is the CMR hostname this client talks to, and the host the URI driver in domain.go claims.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to CMR over HTTPS.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client using the given Config.

func (*Client) GetCollection added in v0.1.1

func (c *Client) GetCollection(ctx context.Context, conceptID string) (*Collection, error)

GetCollection fetches a single CMR collection by its concept ID (e.g. "C2826848343-LPCLOUD").

func (*Client) SearchCollections

func (c *Client) SearchCollections(ctx context.Context, keyword, provider string, limit, page int) ([]Collection, int, error)

SearchCollections searches CMR for collections matching keyword. It returns the matching collections, the total hit count from CMR-Hits, and any error.

func (*Client) SearchGranules added in v0.1.1

func (c *Client) SearchGranules(ctx context.Context, shortName, version, temporal string, limit, page int) ([]Granule, int, error)

SearchGranules lists granules for the given short_name. temporal is an optional "start,end" string (e.g. "2024-01-01,2024-02-01"). It returns the matching granules, the total hit count from CMR-Hits, and any error.

type Collection

type Collection struct {
	ID          string `json:"id"           kit:"id"`
	Title       string `json:"title"`
	ShortName   string `json:"short_name"`
	Version     string `json:"version"`
	DataCenter  string `json:"data_center"`
	Summary     string `json:"summary"`
	TimeStart   string `json:"time_start"`
	TimeEnd     string `json:"time_end"`
	CloudHosted bool   `json:"cloud_hosted"`
}

Collection is a single NASA CMR collection (dataset) record.

type Config

type Config struct {
	BaseURL   string
	Rate      time.Duration
	Retries   int
	Timeout   time.Duration
	UserAgent string
}

Config holds the runtime settings for the CMR client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the NASA CMR driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns any accepted input into the canonical (type, id). A concept ID starts with "C" and contains "-"; anything else is treated as a collection keyword search reference.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Granule

type Granule struct {
	ID         string  `json:"id"          kit:"id"`
	Title      string  `json:"title"`
	TimeStart  string  `json:"time_start"`
	TimeEnd    string  `json:"time_end"`
	DataCenter string  `json:"data_center"`
	DayNight   string  `json:"day_night"`
	CloudCover float64 `json:"cloud_cover"`
	SizeMB     float64 `json:"size_mb"`
	Online     bool    `json:"online"`
}

Granule is a single NASA CMR granule (file-level) record.

Jump to

Keyboard shortcuts

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