paradoxmods

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-paradoxmods

Go


A client for the Paradox Mods catalogue: search, mod details and releases. Package paradoxmods, module github.com/Rethunk-Tech/go-paradoxmods.

For mod managers and launchers that browse Paradox Mods. It speaks the public API directly: one type per answer, orders named by a constant rather than the API's field names, and every failure an error rather than a zero value. An oversized or hostile answer fails instead of exhausting memory.

Quick start

go get github.com/Rethunk-Tech/go-paradoxmods

A worked example and the contracts: HUMANS.md.

Features

  • Client.Search lists a game's mods by text, tag and one of six orders, with the page capped at the API's largest.
  • Client.Mod reads one mod's page, refusing an id that is not a mod id and a mod of another game.
  • Mod.Required gives the mods the newest version needs, leaving out the game's downloadable content.
  • Client.Versions lists a mod's versions newest first; Version.Label is the author's name or the number.
  • PageURL and DownloadURL build the site page and the archive address; ValidID checks an id first.
  • Answers are size-capped, redirects off the API's origin are refused, and a refusal is an *APIError carrying its code and message.

Documentation

Doc Audience
HUMANS.md Running and using the package
AGENTS.md Internals, invariants, and why
CONTRIBUTING.md Process — commits, tests, docs
SECURITY.md Vulnerability disclosure
CHANGELOG.md Release notes

License

MIT — see LICENSE. © 2026 Rethunk.Tech, LLC.

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

View Source
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

func DownloadURL(game, name string, n int) string

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.

func PageURL

func PageURL(id string) string

PageURL is the mod's page on the site, or "" when id is not a mod id.

func ValidID

func ValidID(id string) bool

ValidID reports whether id is a Paradox Mods mod id: up to nine digits.

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.

func (*APIError) Error

func (e *APIError) Error() string

Error names the code and the reason.

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 New

func New(cfg Config) *Client

New builds a Client.

func (*Client) Mod

func (c *Client) Mod(ctx context.Context, game, id, os string) (Mod, error)

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.

func (*Client) Search

func (c *Client) Search(ctx context.Context, q SearchQuery) (ModList, error)

Search lists the game's mods.

func (*Client) Versions

func (c *Client) Versions(ctx context.Context, id string) ([]Version, error)

Versions lists the mod's versions, newest first.

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.

func (Mod) Required

func (m Mod) Required() []string

Required is the ids of the mods the newest version needs: its requirements that are mods with well-formed ids, minus the mod's own entry. The API files the game's downloadable content under the same field, under another product type, so it is left out here.

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.

func (Version) Label

func (v Version) Label() string

Label is the version's name, or its number when the author set none.

Jump to

Keyboard shortcuts

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