nyt

package
v0.0.0-...-150a0ce Latest Latest
Warning

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

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

README

This is a simple client for the Top Stories API from The New York Times that is used in our examples.

Documentation

Index

Constants

View Source
const DefaultHost = "https://api.nytimes.com"

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Section           string        `json:"section"`
	Subsection        string        `json:"subsection"`
	Title             string        `json:"title"`
	Abstract          string        `json:"abstract"`
	URL               string        `json:"url"`
	Byline            string        `json:"byline"`
	ItemType          string        `json:"item_type"`
	UpdatedDate       string        `json:"updated_date"`
	CreatedDate       string        `json:"created_date"`
	PublishedDate     string        `json:"published_date"`
	MaterialTypeFacet string        `json:"material_type_facet"`
	Kicker            string        `json:"kicker"`
	DesFacet          []string      `json:"des_facet"`
	OrgFacet          []string      `json:"org_facet"`
	PerFacet          []string      `json:"per_facet"`
	GeoFacet          []interface{} `json:"geo_facet"`
	Multimedia        []struct {
		URL       string `json:"url"`
		Format    string `json:"format"`
		Height    int    `json:"height"`
		Width     int    `json:"width"`
		Type      string `json:"type"`
		Subtype   string `json:"subtype"`
		Caption   string `json:"caption"`
		Copyright string `json:"copyright"`
	} `json:"multimedia"`
	ShortURL string `json:"short_url"`
}

type Client

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

func NewClient

func NewClient(host, key string, opts ...kithttp.ClientOption) Client

func (Client) GetTopStories

func (c Client) GetTopStories(ctx context.Context, section string) (*TopStoriesResponse, error)

type TopStoriesResponse

type TopStoriesResponse struct {
	Status      string    `json:"status"`
	Copyright   string    `json:"copyright"`
	Section     string    `json:"section"`
	LastUpdated string    `json:"last_updated"`
	NumResults  int       `json:"num_results"`
	Results     []Article `json:"results"`
}

Jump to

Keyboard shortcuts

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