curseforge

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RelationEmbeddedLibrary    = 1
	RelationOptionalDependency = 2
	RelationRequiredDependency = 3
	RelationTool               = 4
	RelationIncompatible       = 5
	RelationInclude            = 6
)

Dependency relation types

View Source
const (
	ReleaseTypeRelease = 1
	ReleaseTypeBeta    = 2
	ReleaseTypeAlpha   = 3
)

Release types

View Source
const (
	ModLoaderAny        = 0
	ModLoaderForge      = 1
	ModLoaderCauldron   = 2
	ModLoaderLiteLoader = 3
	ModLoaderFabric     = 4
	ModLoaderQuilt      = 5
	ModLoaderNeoForge   = 6
)

Mod loader types

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse[T any] struct {
	Data T `json:"data"`
}

APIResponse wraps all CurseForge API responses

type Author

type Author struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

Author represents a mod author

type Category

type Category struct {
	ID               int       `json:"id"`
	GameID           int       `json:"gameId"`
	Name             string    `json:"name"`
	Slug             string    `json:"slug"`
	URL              string    `json:"url"`
	IconURL          string    `json:"iconUrl"`
	DateModified     time.Time `json:"dateModified"`
	IsClass          bool      `json:"isClass"`
	ClassID          int       `json:"classId"`
	ParentCategoryID int       `json:"parentCategoryId"`
	DisplayIndex     int       `json:"displayIndex"`
}

Category represents a mod category

type Client

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

Client wraps the CurseForge REST API v1

func NewClient

func NewClient(httpClient *http.Client, apiKey string) *Client

NewClient creates a new CurseForge API client

func (*Client) GetCategories

func (c *Client) GetCategories(ctx context.Context, gameID int) ([]Category, error)

GetCategories fetches categories for a game

func (*Client) GetDownloadURL

func (c *Client) GetDownloadURL(ctx context.Context, modID, fileID int) (string, error)

GetDownloadURL fetches the download URL for a mod file

func (*Client) GetGame

func (c *Client) GetGame(ctx context.Context, gameID int) (*Game, error)

GetGame fetches a single game by ID

func (*Client) GetGames

func (c *Client) GetGames(ctx context.Context) ([]Game, error)

GetGames fetches all available games with pagination

func (*Client) GetMod

func (c *Client) GetMod(ctx context.Context, modID int) (*Mod, error)

GetMod fetches a single mod by ID

func (*Client) GetModFile

func (c *Client) GetModFile(ctx context.Context, modID, fileID int) (*File, error)

GetModFile fetches a specific file for a mod

func (*Client) GetModFiles

func (c *Client) GetModFiles(ctx context.Context, modID int) ([]File, error)

GetModFiles fetches files for a mod

func (*Client) GetMods

func (c *Client) GetMods(ctx context.Context, modIDs []int) ([]Mod, error)

GetMods fetches multiple mods by ID (batch request)

func (*Client) IsAuthenticated

func (c *Client) IsAuthenticated() bool

IsAuthenticated returns true if an API key is configured

func (*Client) SearchMods

func (c *Client) SearchMods(ctx context.Context, gameID int, query string, categoryID int, pageSize, index int) ([]Mod, *Pagination, error)

SearchMods searches for mods with the given parameters

func (*Client) SetAPIKey

func (c *Client) SetAPIKey(key string)

SetAPIKey sets the API key for authentication

func (*Client) SetBaseURL added in v1.3.9

func (c *Client) SetBaseURL(u string)

SetBaseURL overrides the REST API base URL — primarily used by tests that front the client with an httptest server.

type CurseForge

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

CurseForge implements the ModSource interface

func New

func New(httpClient *http.Client, apiKey string) *CurseForge

New creates a new CurseForge source

func (*CurseForge) AuthInstructions added in v1.21.0

func (c *CurseForge) AuthInstructions() string

AuthInstructions implements source.AuthInstructionsProvider.

func (*CurseForge) AuthURL

func (c *CurseForge) AuthURL() string

AuthURL returns the authentication URL. CurseForge uses API key authentication obtained from console.curseforge.com.

func (*CurseForge) Capabilities added in v1.21.0

func (c *CurseForge) Capabilities() source.Capabilities

Capabilities implements source.CapabilityReporter. CurseForge supports all ModSource operations.

func (*CurseForge) CheckUpdates

func (c *CurseForge) CheckUpdates(ctx context.Context, installed []domain.InstalledMod) ([]domain.Update, error)

CheckUpdates checks for available updates.

func (*CurseForge) EnvKey added in v1.21.0

func (c *CurseForge) EnvKey() string

EnvKey implements source.EnvKeyProvider: the legacy environment variable name, preserved exactly.

func (*CurseForge) ExchangeToken

func (c *CurseForge) ExchangeToken(ctx context.Context, code string) (*source.Token, error)

ExchangeToken exchanges an OAuth code for tokens. CurseForge uses API key authentication instead of OAuth.

func (*CurseForge) GetDependencies

func (c *CurseForge) GetDependencies(ctx context.Context, mod *domain.Mod) ([]domain.ModReference, error)

GetDependencies returns mod dependencies from CurseForge. Dependencies are extracted from the latest file's dependency list.

func (*CurseForge) GetDownloadURL

func (c *CurseForge) GetDownloadURL(ctx context.Context, mod *domain.Mod, fileID string) (string, error)

GetDownloadURL gets the download URL for a mod file

func (*CurseForge) GetMod

func (c *CurseForge) GetMod(ctx context.Context, gameID, modID string) (*domain.Mod, error)

GetMod retrieves a specific mod

func (*CurseForge) GetModFiles

func (c *CurseForge) GetModFiles(ctx context.Context, mod *domain.Mod) ([]domain.DownloadableFile, error)

GetModFiles returns the available download files for a mod

func (*CurseForge) ID

func (c *CurseForge) ID() string

ID returns the source identifier

func (*CurseForge) IsAuthenticated

func (c *CurseForge) IsAuthenticated() bool

IsAuthenticated returns true if an API key is configured

func (*CurseForge) ListGames added in v1.21.0

func (c *CurseForge) ListGames(ctx context.Context) ([]source.GameEntry, error)

ListGames implements source.GameCatalog by wrapping the CurseForge games listing, mapping the numeric game ID to its string form.

func (*CurseForge) Name

func (c *CurseForge) Name() string

Name returns the display name

func (*CurseForge) Search

Search finds mods matching the query. gameID can be either a numeric CurseForge game ID (e.g., "432") or a slug (e.g., "minecraft").

func (*CurseForge) SetAPIKey

func (c *CurseForge) SetAPIKey(key string)

SetAPIKey sets the API key for authentication

func (*CurseForge) TypeLabel added in v1.21.0

func (c *CurseForge) TypeLabel() string

TypeLabel implements source.TypeLabeler.

func (*CurseForge) ValidateKey added in v1.21.0

func (c *CurseForge) ValidateKey(ctx context.Context, key string) error

ValidateKey implements source.KeyValidator by probing the CurseForge API with key via GetGames, discarding the result. Uses a client scoped to this call (same underlying HTTP client and base URL as c.client) so validation is independent of any key already configured on this source.

type File

type File struct {
	ID                   int                   `json:"id"`
	GameID               int                   `json:"gameId"`
	ModID                int                   `json:"modId"`
	IsAvailable          bool                  `json:"isAvailable"`
	DisplayName          string                `json:"displayName"`
	FileName             string                `json:"fileName"`
	ReleaseType          int                   `json:"releaseType"` // 1=Release, 2=Beta, 3=Alpha
	FileStatus           int                   `json:"fileStatus"`
	Hashes               []FileHash            `json:"hashes"`
	FileDate             time.Time             `json:"fileDate"`
	FileLength           int64                 `json:"fileLength"`
	DownloadCount        int64                 `json:"downloadCount"`
	DownloadURL          string                `json:"downloadUrl"`
	GameVersions         []string              `json:"gameVersions"`
	SortableGameVersions []SortableGameVersion `json:"sortableGameVersions"`
	Dependencies         []FileDependency      `json:"dependencies"`
	AlternateFileID      int                   `json:"alternateFileId"`
	IsServerPack         bool                  `json:"isServerPack"`
	FileFingerprint      int64                 `json:"fileFingerprint"`
	Modules              []FileModule          `json:"modules"`
}

File represents a downloadable mod file

type FileDependency

type FileDependency struct {
	ModID        int `json:"modId"`
	RelationType int `json:"relationType"` // 1=EmbeddedLibrary, 2=OptionalDependency, 3=RequiredDependency, 4=Tool, 5=Incompatible, 6=Include
}

FileDependency represents a file's dependency on another mod

type FileHash

type FileHash struct {
	Value string `json:"value"`
	Algo  int    `json:"algo"` // 1=SHA1, 2=MD5
}

FileHash contains hash info for a file

type FileIndex

type FileIndex struct {
	GameVersion       string `json:"gameVersion"`
	FileID            int    `json:"fileId"`
	Filename          string `json:"filename"`
	ReleaseType       int    `json:"releaseType"`
	GameVersionTypeID int    `json:"gameVersionTypeId"`
	ModLoader         int    `json:"modLoader"` // 0=Any, 1=Forge, 2=Cauldron, 3=LiteLoader, 4=Fabric, 5=Quilt, 6=NeoForge
}

FileIndex contains file index info for latest files

type FileModule

type FileModule struct {
	Name        string `json:"name"`
	Fingerprint int64  `json:"fingerprint"`
}

FileModule represents a module within a mod file

type Game

type Game struct {
	ID           int        `json:"id"`
	Name         string     `json:"name"`
	Slug         string     `json:"slug"`
	DateModified time.Time  `json:"dateModified"`
	Assets       GameAssets `json:"assets"`
	Status       int        `json:"status"`
	APIStatus    int        `json:"apiStatus"`
}

Game represents a game from the CurseForge API

type GameAssets

type GameAssets struct {
	IconURL  string `json:"iconUrl"`
	TileURL  string `json:"tileUrl"`
	CoverURL string `json:"coverUrl"`
}

GameAssets contains image assets for a game

type Mod

type Mod struct {
	ID                   int         `json:"id"`
	GameID               int         `json:"gameId"`
	Name                 string      `json:"name"`
	Slug                 string      `json:"slug"`
	Links                ModLinks    `json:"links"`
	Summary              string      `json:"summary"`
	Status               int         `json:"status"`
	DownloadCount        int64       `json:"downloadCount"`
	IsFeatured           bool        `json:"isFeatured"`
	PrimaryCategoryID    int         `json:"primaryCategoryId"`
	Categories           []Category  `json:"categories"`
	ClassID              int         `json:"classId"`
	Authors              []Author    `json:"authors"`
	Screenshots          []ModAsset  `json:"screenshots"`
	MainFileID           int         `json:"mainFileId"`
	LatestFiles          []File      `json:"latestFiles"`
	LatestFilesIndexes   []FileIndex `json:"latestFilesIndexes"`
	DateCreated          time.Time   `json:"dateCreated"`
	DateModified         time.Time   `json:"dateModified"`
	DateReleased         time.Time   `json:"dateReleased"`
	AllowModDistribution *bool       `json:"allowModDistribution"`
	GamePopularityRank   int         `json:"gamePopularityRank"`
	IsAvailable          bool        `json:"isAvailable"`
	ThumbsUpCount        int         `json:"thumbsUpCount"`
}

Mod represents a mod from the CurseForge API

type ModAsset

type ModAsset struct {
	ID           int    `json:"id"`
	ModID        int    `json:"modId"`
	Title        string `json:"title"`
	Description  string `json:"description"`
	ThumbnailURL string `json:"thumbnailUrl"`
	URL          string `json:"url"`
}

ModAsset represents an image asset (logo, screenshot)

type ModLinks struct {
	WebsiteURL string `json:"websiteUrl"`
	WikiURL    string `json:"wikiUrl"`
	IssuesURL  string `json:"issuesUrl"`
	SourceURL  string `json:"sourceUrl"`
}

ModLinks contains URLs associated with a mod

type PaginatedResponse

type PaginatedResponse[T any] struct {
	Data       T          `json:"data"`
	Pagination Pagination `json:"pagination"`
}

PaginatedResponse wraps paginated CurseForge API responses

type Pagination

type Pagination struct {
	Index       int `json:"index"`
	PageSize    int `json:"pageSize"`
	ResultCount int `json:"resultCount"`
	TotalCount  int `json:"totalCount"`
}

Pagination contains pagination info from CurseForge API

type SortableGameVersion

type SortableGameVersion struct {
	GameVersionName        string    `json:"gameVersionName"`
	GameVersionPadded      string    `json:"gameVersionPadded"`
	GameVersion            string    `json:"gameVersion"`
	GameVersionReleaseDate time.Time `json:"gameVersionReleaseDate"`
	GameVersionTypeID      int       `json:"gameVersionTypeId"`
}

SortableGameVersion contains structured version info

type StringDownloadURL

type StringDownloadURL struct {
	Data string `json:"data"`
}

StringDownloadURL is the response for the download URL endpoint

Jump to

Keyboard shortcuts

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