npsapi

package module
v0.0.0-...-a36b627 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

README

NPS API (National Park Service API)

Build Status GoDoc Go Report Card GitHub

NPS API provides a Go client for accessing the US National Park Service API. The API provides information about parks / monuments / historical sites throughout the US.

An API Key is required and can be obtained at https://www.nps.gov/subjects/developer/get-started.htm.

Usage

go get github.com/bamnet/npsapi

Documentation

Overview

Package npsapi provides an API to access National Park Service (NPS) data.

Index

Constants

This section is empty.

Variables

View Source
var ErrFetchingData = errors.New("error talking to NPS API")

ErrFetchingData is a type of generic error when the NPS API does not return a valid response.

View Source
var ErrParkNotFound = errors.New("park not found")

ErrParkNotFound is a type of error returned when no parks were found.

Functions

This section is empty.

Types

type Client

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

Client connects to the NPS API backend.

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a new NPS API client.

An API Key is required for use and can be obtained at: https://www.nps.gov/subjects/developer/get-started.htm

func (*Client) GetPark

func (c *Client) GetPark(ctx context.Context, code string) (*Park, error)

GetPark finds a specific park with a 4-character code.

func (*Client) ListParks

func (c *Client) ListParks(ctx context.Context) ([]Park, error)

ListParks finds all the parks.

type LatLng

type LatLng struct {
	// Latitude.
	Lat float64
	// Longitude
	Lng float64
}

LatLng cooordinate.

type Park

type Park struct {
	// UUID-style identifier for the park.
	ID string
	// Park name.
	Name string
	// Longer park name.
	FullName string
	// 4-character code to identify the park.
	Code string
	// States the park is in.
	States []string
	// Geospatial location of the park.
	Location *LatLng
	// Decription of the park.
	Description string
	// URL of the park website.
	URL string
}

Park basics include location, contact, and operating hours for each national park.

Directories

Path Synopsis
cmd
demo
demo application to exercise features of the API.
demo application to exercise features of the API.

Jump to

Keyboard shortcuts

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