Documentation
¶
Overview ¶
Package usgs exposes the USGS Earthquake catalog as a kit Domain driver.
A multi-domain host (ant) enables it with a single blank import:
import _ "github.com/tamnd/usgs-cli/usgs"
The same Domain also builds the standalone usgs binary (see cli.NewApp).
Package usgs is the library behind the usgs command line: the HTTP client, request shaping, and typed data models for the USGS FDSNWS Earthquake Event Web Service (earthquake.usgs.gov/fdsnws/event/1).
The USGS API is free and requires no API key. It returns seismic events worldwide in GeoJSON format with magnitude, location, depth, and metadata.
Index ¶
Constants ¶
const Host = "earthquake.usgs.gov"
Host is the API host this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the USGS earthquake API over HTTP.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, p QueryParams) ([]Earthquake, error)
Query calls /fdsnws/event/1/query and returns a slice of Earthquake records.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type Domain ¶
type Domain struct{}
Domain is the usgs driver.
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.
type Earthquake ¶
type Earthquake struct {
Place string `kit:"id" json:"place"`
Magnitude string `json:"magnitude"` // "%.1f"
Time string `json:"time"` // RFC3339 UTC
Depth string `json:"depth_km"` // "%.1f"
Latitude string `json:"latitude"` // "%.4f"
Longitude string `json:"longitude"` // "%.4f"
Type string `json:"type"`
}
Earthquake is one seismic event from the USGS catalog, with all numeric fields pre-formatted as strings for clean JSON/tabular output.