Documentation
¶
Overview ¶
Package wikigo provides a production-quality, type-safe Go SDK for the Wikimedia REST API. It wraps pages, search, revisions, and media APIs with context propagation, structured error handling, rate limiting, and exponential backoff retry logic.
Index ¶
- type Client
- type MediaClient
- type Option
- func WithBaseURL(url string) Option
- func WithHTTPClient(client *http.Client) Option
- func WithLanguage(lang string) Option
- func WithMaxRetries(retries int) Option
- func WithProject(proj string) Option
- func WithRateLimit(limit rate.Limit, burst int) Option
- func WithTimeout(d time.Duration) Option
- func WithUserAgent(ua string) Option
- type PagesClient
- type RevisionsClient
- type SearchClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Pages provides operations related to reading page content and summaries.
Pages *PagesClient
// Search provides endpoints to query the wiki index.
Search *SearchClient
// Revisions provides endpoints to inspect page history revisions.
Revisions *RevisionsClient
// Media provides operations to retrieve media file details.
Media *MediaClient
// contains filtered or unexported fields
}
Client is the primary entrypoint for the Wikimedia REST API SDK. It organizes API methods into resource-scoped sub-clients.
type MediaClient ¶
type MediaClient struct {
// contains filtered or unexported fields
}
MediaClient groups API operations related to media files.
type Option ¶
type Option func(*config)
Option represents a configuration function for customizing the client.
func WithBaseURL ¶
WithBaseURL overrides the constructed host URL entirely. Useful for custom deployments or local mock servers during tests. E.g., "http://127.0.0.1:8080".
func WithHTTPClient ¶
WithHTTPClient overrides the underlying http.Client used by the SDK. The SDK wraps the client's transport with its own retry and rate-limiting transport.
func WithLanguage ¶
WithLanguage sets the language sub-domain for the Wikimedia project (e.g., "en", "de"). Default is "en".
func WithMaxRetries ¶
WithMaxRetries sets the maximum number of retry attempts for failed requests. Only HTTP 429 and 503 errors are retried. Default is 3.
func WithProject ¶
WithProject sets the Wikimedia project domain (e.g., "wikipedia", "wiktionary", "wikibooks"). Default is "wikipedia".
func WithRateLimit ¶
WithRateLimit sets the parameters for the client rate limiter. rateLimit specifies the maximum requests per second, and burst specifies the token burst size.
func WithTimeout ¶
WithTimeout sets the timeout duration for client-wide request execution. Default is 30 seconds.
func WithUserAgent ¶
WithUserAgent overrides the HTTP User-Agent header value sent on all requests. A descriptive User-Agent is required under the Wikimedia API usage guidelines.
type PagesClient ¶
type PagesClient struct {
// contains filtered or unexported fields
}
PagesClient groups API operations related to pages.
func (*PagesClient) Get ¶
Get retrieves metadata for a specific wiki page by its title using the Core REST API. It maps to the GET /page/{title}/bare endpoint.
func (*PagesClient) GetSummary ¶
GetSummary retrieves a structured page summary for previews using the legacy REST API. It maps to the GET /page/summary/{title} endpoint.
type RevisionsClient ¶
type RevisionsClient struct {
// contains filtered or unexported fields
}
RevisionsClient groups API operations related to revisions history.
func (*RevisionsClient) List ¶
func (r *RevisionsClient) List(ctx context.Context, title string, limit int, olderThan string) (*models.RevisionList, error)
List retrieves a segment of the revision history for a specific page. It maps to the GET /page/{title}/history endpoint using the Core REST API. It handles cursor-based pagination explicitly by returning a Continue token.
type SearchClient ¶
type SearchClient struct {
// contains filtered or unexported fields
}
SearchClient groups API operations related to search.
func (*SearchClient) Pages ¶
func (s *SearchClient) Pages(ctx context.Context, query string, limit int) (*models.SearchResponse, error)
Pages searches for pages matching the query string in title or content. It maps to the GET /search/page endpoint using Core REST API.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package errors defines standard sentinel errors and structured error types for the wikigo Wikimedia REST API client.
|
Package errors defines standard sentinel errors and structured error types for the wikigo Wikimedia REST API client. |
|
Package main provides a runnable example of using the wikigo SDK to interact with the live Wikimedia REST API.
|
Package main provides a runnable example of using the wikigo SDK to interact with the live Wikimedia REST API. |
|
Package models defines the strongly typed data models used by the wikigo Wikimedia REST API client.
|
Package models defines the strongly typed data models used by the wikigo Wikimedia REST API client. |