contentdb

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package contentdb provides a minimal client for the ContentDB REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a minimal ContentDB API client.

func New

func New() *Client

New returns a Client pointed at the production ContentDB API.

func NewWithClient

func NewWithClient(baseURL string, c *http.Client) *Client

NewWithClient returns a Client that uses the provided base URL and *http.Client. Pass the httptest.Server URL and ts.Client() in tests.

func (*Client) GetDependencies

func (c *Client) GetDependencies(ctx context.Context, author, name string) (DependenciesResponse, error)

GetDependencies returns the full transitive dependency graph for a package. The map key is "author/name"; the value is that package's dependency list.

func (*Client) GetPackage

func (c *Client) GetPackage(ctx context.Context, author, name string) (*Package, error)

GetPackage fetches metadata for a single package by author/name.

func (*Client) GetReleases

func (c *Client) GetReleases(ctx context.Context, author, name string) ([]Release, error)

GetReleases returns the release list for a package.

func (*Client) Install

func (c *Client) Install(ctx context.Context, author, name, destDir string) (string, error)

Install downloads the latest release of author/name and unpacks it into destDir. Returns the path to the extracted mod directory.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query, pkgType string, limit int) ([]Package, error)

Search queries packages. pkgType may be "mod", "game", "txp", or "" for all.

type DependenciesResponse

type DependenciesResponse map[string][]Dependency

DependenciesResponse is returned by the ContentDB /dependencies/ endpoint. Each key is an "author/name" package ID; the value is that package's dependency list. The response covers the full transitive dep graph.

type Dependency

type Dependency struct {
	IsOptional bool     `json:"is_optional"`
	Name       string   `json:"name"`
	Packages   []string `json:"packages"`
}

Dependency describes one dependency entry for a package.

type Package

type Package struct {
	Author           string   `json:"author"`
	Name             string   `json:"name"`
	Title            string   `json:"title"`
	ShortDescription string   `json:"short_description"`
	Type             string   `json:"type"`
	Score            float64  `json:"score"`
	Downloads        int      `json:"downloads"`
	Thumbnail        string   `json:"thumbnail"`
	Tags             []string `json:"tags"`
	License          string   `json:"license"`
	Repo             string   `json:"repo"`
	// Provides lists every mod name shipped by this package.
	// For modpacks this enumerates all sub-mod directory names.
	Provides []string `json:"provides"`
}

Package represents a ContentDB package (mod, game, or texture pack).

type PackageListResponse

type PackageListResponse struct {
	Page      int       `json:"page"`
	PerPage   int       `json:"per_page"`
	PageCount int       `json:"page_count"`
	Total     int       `json:"total"`
	Items     []Package `json:"items"`
}

PackageListResponse is returned by paginated list endpoints.

type Release

type Release struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Title       string `json:"title"`
	ReleaseDate string `json:"release_date"`
	URL         string `json:"url"`
	Downloads   int    `json:"downloads"`
}

Release represents a single ContentDB release for a package.

Jump to

Keyboard shortcuts

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