Documentation
¶
Overview ¶
Package paradoxmods is a client for the Paradox Mods catalogue: search a game's mods, read one mod's details, its versions and its download address.
Index ¶
Constants ¶
const ( // BaseURL is the public API root. BaseURL = "https://api.paradox-interactive.com" // MaxPageSize is the API's largest page. MaxPageSize = 100 )
Variables ¶
This section is empty.
Functions ¶
func DownloadURL ¶
DownloadURL is the anonymous archive address of version n of the mod whose opaque file name is name, or "" when game or name is not a single path segment or n is below 1.
Types ¶
type APIError ¶
type APIError struct {
// Code is the API's errorCode, e.g. "bad-input".
Code string
// Message is the API's errorMessage, the reason in words.
Message string
}
APIError is an answer the API refused. A refusal arrives with a 200 status and its own result field, so it is not a *httpkit.StatusError.
type ChangeEntry ¶
type ChangeEntry struct {
// ModVersion is the version number the notes belong to.
ModVersion int `json:"modVersion"`
// UserVersion is the author's own label for that version; empty when the author set none.
UserVersion string `json:"userModVersion"`
// Released is when the version was published, "YYYY-MM-DD HH:MM:SS", the date first.
Released string `json:"released"`
// Details is the notes: Markdown, sometimes HTML.
Details string `json:"details"`
}
ChangeEntry is one version's release notes, as a mod's changelog holds them.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls the Paradox Mods API. It holds no state beyond its configuration, so it is safe for concurrent use.
func (*Client) Mod ¶
Mod reads one mod as published for an operating system. A non-empty game refuses an answer for another game, since mod ids are global across Paradox's games.
type Config ¶
type Config struct {
// BaseURL replaces the API root; empty means BaseURL. Trailing slashes are trimmed.
BaseURL string
// HTTP sends every request; nil means a client with a timeout. Redirects to another origin are refused.
HTTP *http.Client
// UserAgent is sent with every request when set; the caller names itself.
UserAgent string
}
Config is what a Client is built from.
type Mod ¶
type Mod struct {
// Game is the API's name for the game the mod belongs to.
Game string `json:"game"`
// ID is the mod's numeric id, as a string.
ID string `json:"modId"`
// Name is the opaque file name the download address carries, not a display name.
Name string `json:"name"`
// DisplayName is the title the author gave it.
DisplayName string `json:"displayName"`
// Author is the author's account name.
Author string `json:"author"`
// ShortDescription is the listing's one-line summary.
ShortDescription string `json:"shortDescription"`
// LongDescription is the page's full description: Markdown, often with HTML in it.
LongDescription string `json:"longDescription"`
// ModVersion is the newest version's number, as a string.
ModVersion string `json:"modVersion"`
// UserModVersion is the newest version's label as the author set it; empty when the author set none.
UserModVersion string `json:"userModVersion"`
// Tags are the mod's categories.
Tags []string `json:"tags"`
// Requirements are what the newest version needs: other mods, and the game's own downloadable content.
Requirements []Requirement `json:"requirements"`
// Changelog holds every version's notes, in no particular order.
Changelog []ChangeEntry `json:"changelog"`
// Image is the listing picture's address.
Image string `json:"displayImagePath"`
// InstalledCount is how many players have the mod installed.
InstalledCount int `json:"installedCount"`
// RatingsTotal is how many players rated it.
RatingsTotal int `json:"ratingsTotal"`
// Updated is when the mod last changed, as the API formats it.
Updated string `json:"updated"`
}
Mod is one mod as a listing or a details answer gives it; a listing leaves the details fields empty.
type ModList ¶
type ModList struct {
// Total is how many mods the whole query matches, not just this page.
Total int
// Mods is the page's mods in the API's order.
Mods []Mod
}
ModList is one page of a listing.
type Requirement ¶
type Requirement struct {
// ProductType is "MOD" for another mod, and the game's own kind for downloadable content.
ProductType string `json:"productType"`
// ID is the required product's id, opaque unless ProductType is "MOD".
ID string `json:"id"`
}
Requirement is one product a version needs.
type SearchQuery ¶
type SearchQuery struct {
// Game is the API's game name, e.g. "cities_skylines_2".
Game string
// Text matches names and descriptions; empty lists the game's mods.
Text string
// Page is the 1-based page to read; anything below 1 reads the first.
Page int
// Size is the page length; zero, and anything above MaxPageSize, reads MaxPageSize.
Size int
// Tags asks for mods carrying the listed tags.
Tags []string
// Sort is one of the Sort values; the zero value keeps the API's own order.
Sort Sort
}
SearchQuery is one page of a mods listing.
type Sort ¶
type Sort string
Sort is one order a listing can take.
const ( // SortBest is the API's relevance order, which needs no search text to be meaningful. SortBest Sort = "best" // SortDownloads is most installed first. SortDownloads Sort = "downloads" // SortRating is highest rated first. SortRating Sort = "rating" // SortUpdated is most recently changed first. SortUpdated Sort = "updated" // SortNewest is most recently published first. SortNewest Sort = "newest" // SortName is by display name, A first. SortName Sort = "name" )
The listing's orders. Their meaning is the API's; the zero value asks for none and keeps the API's own order.
type Version ¶
type Version struct {
// ID is the version number, and the number the download address carries.
ID int `json:"id"`
// Name is the author's label for the version; empty when the author set none.
Name string `json:"userVersion"`
// Created is when it was published, as the API formats it.
Created string `json:"created"`
// Size is the archive's size in bytes.
Size int64 `json:"size"`
}
Version is one published version of a mod.