Documentation
¶
Overview ¶
httpclient implements an API client for NewsAPI https://newsapi.org/docs
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct {
Source Source `json:"source"`
Title string `json:"title"`
Author string `json:"author,omitempty"`
Description string `json:"description,omitempty"`
Url string `json:"url,omitempty"`
ImageUrl string `json:"urlToImage,omitempty"`
PublishedAt time.Time `json:"publishedAt"`
Content string `json:"content,omitempty"`
}
Article is a news article
type ArticlesRequest ¶
type ArticlesRequest struct {
Query string `json:"q,omitempty" help:"Search keywords or phrases"`
SearchIn string `` /* 137-byte string literal not displayed */
Sources string `` /* 134-byte string literal not displayed */
Domains string `json:"domains,omitempty" help:"A comma-separated string of domains (eg bbc.co.uk, techcrunch.com) to restrict the search to"`
ExcludeDomains string `json:"excludeDomains,omitempty" help:"A comma-separated string of domains to remove from the results"`
From string `` /* 142-byte string literal not displayed */
To string `json:"to,omitempty" help:"A date and optional time for the newest article allowed. ISO 8601 format"`
Language string `json:"language,omitempty" help:"The 2-letter ISO-639-1 code of the language you want to get articles for"`
SortBy string `json:"sortBy,omitempty" help:"The order to sort the articles in" enum:"relevancy,popularity,publishedAt"`
PageSize int `json:"pageSize,omitempty" help:"The number of results to return per page (1-100)" min:"1" max:"100"`
Page int `json:"page,omitempty" help:"Use this to page through the results" min:"1"`
}
ArticlesRequest is a request to search for articles
func (*ArticlesRequest) Values ¶
func (r *ArticlesRequest) Values() url.Values
Values returns the request as URL query parameters
type Client ¶
func New ¶
New returns a client for NewsAPI with the API key. The endpoint can be replaced with client.OptEndpoint, for example for testing.
type HeadlinesRequest ¶
type HeadlinesRequest struct {
Query string `json:"q,omitempty" help:"Keywords or phrases to search for in the article title and body"`
Category string `` /* 146-byte string literal not displayed */
Country string `json:"country,omitempty" help:"The 2-letter ISO 3166-1 code of the country you want to get headlines for"`
Sources string `` /* 178-byte string literal not displayed */
Language string `json:"language,omitempty" help:"The 2-letter ISO-639-1 code of the language you want to get headlines for"`
PageSize int `json:"pageSize,omitempty" help:"The number of results to return per page (1-100)" min:"1" max:"100"`
Page int `json:"page,omitempty" help:"Use this to page through the results" min:"1"`
}
HeadlinesRequest is a request for the top headlines
func (*HeadlinesRequest) Values ¶
func (r *HeadlinesRequest) Values() url.Values
Values returns the request as URL query parameters
type Source ¶
type Source struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Url string `json:"url,omitempty"`
Category string `json:"category,omitempty"`
Language string `json:"language,omitempty"`
Country string `json:"country,omitempty"`
}
Source is a news source, such as a newspaper or blog
type SourcesRequest ¶
type SourcesRequest struct {
Category string `` /* 144-byte string literal not displayed */
Language string `json:"language,omitempty" help:"The 2-letter ISO-639-1 code of the language you want to get sources for"`
Country string `json:"country,omitempty" help:"The 2-letter ISO 3166-1 code of the country you want to get sources for"`
}
SourcesRequest is a request for news sources
func (*SourcesRequest) Values ¶
func (r *SourcesRequest) Values() url.Values
Values returns the request as URL query parameters