itchio

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 12 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-itchio

Go


A client for the itch.io game pages and uploads, as mod managers read them. Package itchio, module github.com/Rethunk-Tech/go-itchio.

Reads the itch.io server-side API with a user's own API key, and answers the one question a pasted game page address raises: is it a page, and which page is it. Errors a caller can tell apart: no key, rejected key, anything else.

Quick start

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

A worked example and the contracts: HUMANS.md.

Features

  • Search games by text, and read the signed-in account.
  • A game's uploads with filename, size, kind and demo flag, and the time-limited download address of one upload.
  • Page helpers: validate a user/game id, build its address, and parse a pasted page address into that id.
  • Answers capped at 16 MiB, a redirect off the API's origin refused, and the key in a header only.

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 itchio is a client for the itch.io server-side API and its game page addresses.

Index

Constants

View Source
const (
	// BaseURL is the server-side API root (itch.io/docs/api/serverside). Only this host reads the key from the
	// Authorization header; itch.io/api/1 wants it in the address, where an error quoting the address would leak it.
	BaseURL = "https://api.itch.io"
)

Variables

View Source
var (
	// ErrNeedsKey means the Client has no API key; nothing is sent.
	ErrNeedsKey = errors.New("needs an itch.io API key")
	// ErrBadKey means itch.io rejected the key: it is mistyped or revoked.
	ErrBadKey = errors.New("itch.io rejected the API key")
)

Functions

func PageURL

func PageURL(id string) string

PageURL is the canonical address of a page, or "" for an id that is not one.

func ParsePageURL

func ParsePageURL(text string) (string, bool)

ParsePageURL reads a pasted game page address: https only, host <user>.itch.io with no user name or port, and a path of the one game slug. It returns "user/game"; the address that opens is always rebuilt from it, so a query, fragment or look-alike host never reaches the browser.

func ValidPage

func ValidPage(id string) bool

ValidPage reports whether id is a page name as ParsePageURL returns it.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client calls the itch.io API. It holds no state beyond its configuration, so it is safe for concurrent use and cheap to build again when the key changes.

func New

func New(cfg Config) *Client

New builds a Client.

func (*Client) DownloadURL

func (c *Client) DownloadURL(ctx context.Context, uploadID string) (string, error)

DownloadURL asks for an upload's file and returns the short-lived signed address itch.io answers with. The API sends that address as a redirect rather than as JSON, so the redirect is read and not followed: the key never travels to the file host.

func (*Client) Me

func (c *Client) Me(ctx context.Context) (User, error)

Me reads the key's account.

func (*Client) SearchGames

func (c *Client) SearchGames(ctx context.Context, query string, page int) ([]Game, error)

SearchGames lists the games matching query. itch.io answers every hit on the first page and ignores a page number, so a later page is empty and asks for nothing.

func (*Client) Uploads

func (c *Client) Uploads(ctx context.Context, gameID string) ([]Upload, error)

Uploads lists the files attached to a game.

type Config

type Config struct {
	// Key is the user's own itch.io API key, sent as a bearer token. Empty makes every call that needs one fail with
	// ErrNeedsKey.
	Key string
	// BaseURL replaces the API root.
	BaseURL string
	// HTTP sends every request; nil means a client with a default timeout. A redirect to another origin is refused
	// so the key stays with the API.
	HTTP *http.Client
	// UserAgent is sent with every request when set.
	UserAgent string
}

Config is what a Client is built from.

type Game

type Game struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
	// ShortText is the one-line summary the game's page opens with.
	ShortText string `json:"short_text"`
	URL       string `json:"url"`
	CoverURL  string `json:"cover_url"`
	// PublishedAt is the API's own timestamp, unparsed.
	PublishedAt string `json:"published_at"`
	// User is the account that published the game.
	User User `json:"user"`
}

Game is one search hit.

type Upload

type Upload struct {
	ID       int    `json:"id"`
	Filename string `json:"filename"`
	Size     int64  `json:"size"`
	// Type is the upload's kind; a soundtrack is not a mod.
	Type string `json:"type"`
	// Demo marks a demo build, which is not a mod either.
	Demo bool `json:"demo"`
	// UpdatedAt is the API's own timestamp, unparsed.
	UpdatedAt string `json:"updated_at"`
}

Upload is one file attached to a game.

type User

type User struct {
	Username string `json:"username"`
}

User is an itch.io account.

Jump to

Keyboard shortcuts

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