Documentation ¶
Overview ¶
Package wikimedia is an interface to the Wikimedia (Wikipedia, Wiktionary, etc.) API built in Go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiPage ¶
type ApiPage struct { PageId int `json:"pageid"` Ns int `json:"ns"` Title string `json:"title"` Extract string `json:"extract"` Thumbnail Thumbnail `json:"thumbnail"` Original Original `json:"original"` }
ApiPage model struct as defined by any Wikimedia API JSON response.
type ApiQuery ¶
type ApiQuery struct { Pages map[string]ApiPage `json:"pages"` Search []ApiSearch `json:"search"` SearchInfo ApiSearchInfo `json:"searchinfo"` }
ApiQuery model struct as defined by any Wikimedia API JSON response.
type ApiQueryContinue ¶
type ApiQueryContinue struct {
Search ApiQueryContinueSearch `json:"search"`
}
ApiQueryContinue model struct as defined by any Wikimedia API JSON response.
type ApiQueryContinueSearch ¶
type ApiQueryContinueSearch struct {
SrOffset int `json:"sroffset"`
}
ApiQueryContinueSearch model struct as defined by any Wikimedia API JSON response.
type ApiResponse ¶
type ApiResponse struct { Query ApiQuery `json:"query"` QueryContinue ApiQueryContinue `json:"query-continue"` }
ApiResponse model struct as defined by any Wikimedia API JSON response.
type ApiSearch ¶
type ApiSearch struct { Ns int `json:"ns"` Title string `json:"title"` Snippet string `json:"snippet"` Size int `json:"size"` WordCount int `json:"wordcount"` Timestamp time.Time `json:"timestamp"` }
ApiSearch model struct as defined by any Wikimedia API JSON response.
type ApiSearchInfo ¶
type ApiSearchInfo struct {
TotalHits int `json:"source"`
}
ApiSearchInfo model struct as defined by any Wikimedia API JSON response.
type Options ¶
type Options struct { // Full URL of the Wikimedia API, e.g. url.Parse("https://en.wikipedia.org/w/api.php") URL string // HTTP client to use (defaults to http.DefaultClient) Client *http.Client // User-Agent header to provide UserAgent string }
Options is a collection of configurable options for the Wikimedia client.
type Original ¶
type Original struct {
Source string `json:"source"`
}
Original model struct as defined by any Wikimedia API JSON response.
type Thumbnail ¶
type Thumbnail struct {
Source string `json:"source"`
}
Thumbnail model struct as defined by any Wikimedia API JSON response.
type Wikimedia ¶
type Wikimedia struct {
Options Options
}
Wikimedia is an API client struct.
func New ¶
New initializes a Wikimedia object that queries the specified API URL, e.g. http://en.wikipedia.org/w/api.php or http://da.wiktionary.org/w/api.php. Returns a pointer to a Wikimedia struct and an error.
func (*Wikimedia) Query ¶
func (wiki *Wikimedia) Query(query url.Values) (*ApiResponse, error)
Query quires the Wikimedia API using the user-specified query. See https://en.wikipedia.org/w/api.php for a reference. Returns a pointer to an ApiResponse and an error.