nexusmods

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

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 wraps the NexusMods REST API v1 and GraphQL v2 APIs

func NewClient

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

NewClient creates a new NexusMods API client

func (c *Client) GetDownloadLinks(ctx context.Context, gameDomain string, modID, fileID int) ([]DownloadLink, error)

GetDownloadLinks fetches download URLs for a mod file

func (*Client) GetLatestAdded

func (c *Client) GetLatestAdded(ctx context.Context, gameDomain string) ([]ModData, error)

GetLatestAdded fetches the latest added mods for a game

func (*Client) GetLatestUpdated

func (c *Client) GetLatestUpdated(ctx context.Context, gameDomain string) ([]ModData, error)

GetLatestUpdated fetches the latest updated mods for a game

func (*Client) GetMod

func (c *Client) GetMod(ctx context.Context, gameDomain string, modID int) (*ModData, error)

GetMod fetches a mod by ID

func (*Client) GetModFiles

func (c *Client) GetModFiles(ctx context.Context, gameDomain string, modID int) (*ModFileList, error)

GetModFiles fetches files for a mod

func (*Client) GetModRequirements

func (c *Client) GetModRequirements(ctx context.Context, gameDomain string, modID int) ([]ModRequirement, error)

GetModRequirements fetches mod dependencies using the GraphQL API

func (*Client) GetTrending

func (c *Client) GetTrending(ctx context.Context, gameDomain string) ([]ModData, error)

GetTrending fetches the trending mods for a game

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, gameDomain, query string, limit, offset int) ([]ModData, error)

SearchMods searches for mods using the NexusMods GraphQL v2 API.

func (*Client) SetAPIKey

func (c *Client) SetAPIKey(key string)

SetAPIKey sets the API key for authentication

func (*Client) ValidateAPIKey

func (c *Client) ValidateAPIKey(ctx context.Context, key string) error

ValidateAPIKey validates an API key by calling the NexusMods validate endpoint

type DownloadLink struct {
	Name      string `json:"name"`
	ShortName string `json:"short_name"`
	URI       string `json:"URI"`
}

DownloadLink represents a download URL response

type FileData

type FileData struct {
	FileID          int       `json:"file_id"`
	Name            string    `json:"name"`
	FileName        string    `json:"file_name"`
	Version         string    `json:"version"`
	CategoryID      int       `json:"category_id"`
	CategoryName    string    `json:"category_name"`
	IsPrimary       bool      `json:"is_primary"`
	Size            int64     `json:"size"`
	SizeKB          int64     `json:"size_kb"`
	SizeInBytes     *int64    `json:"size_in_bytes"`
	UploadedTime    time.Time `json:"uploaded_time"`
	ModVersion      string    `json:"mod_version"`
	ExternalVirusID string    `json:"external_virus_scan_url"`
	Description     string    `json:"description"`
	Changelog       string    `json:"changelog_html"`
}

FileData represents a mod file from the NexusMods REST API

type FileUpdate

type FileUpdate struct {
	OldFileID    int    `json:"old_file_id"`
	NewFileID    int    `json:"new_file_id"`
	OldFileName  string `json:"old_file_name"`
	NewFileName  string `json:"new_file_name"`
	UploadedTime string `json:"uploaded_time"`
}

FileUpdate represents file version relationships

type ModData

type ModData struct {
	ModID                int       `json:"mod_id"`
	GameID               int       `json:"game_id"`
	DomainName           string    `json:"domain_name"`
	Name                 string    `json:"name"`
	Summary              string    `json:"summary"`
	Description          string    `json:"description"`
	Version              string    `json:"version"`
	Author               string    `json:"author"`
	UploadedBy           string    `json:"uploaded_by"`
	UploadedByProfileURL string    `json:"uploaded_users_profile_url"`
	CategoryID           int       `json:"category_id"`
	PictureURL           string    `json:"picture_url"`
	ContainsAdultContent bool      `json:"contains_adult_content"`
	Status               string    `json:"status"`
	Available            bool      `json:"available"`
	EndorsementCount     int       `json:"endorsement_count"`
	CreatedTime          time.Time `json:"created_time"`
	UpdatedTime          time.Time `json:"updated_time"`
	AllowRating          bool      `json:"allow_rating"`
}

ModData represents a mod from the NexusMods REST API

type ModFileList

type ModFileList struct {
	Files       []FileData   `json:"files"`
	FileUpdates []FileUpdate `json:"file_updates"`
}

ModFileList represents the response from the mod files endpoint

type ModRequirement

type ModRequirement struct {
	ModID   int
	ModName string
}

ModRequirement represents a dependency returned from the GraphQL API

type NexusMods

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

NexusMods implements the ModSource interface

func New

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

New creates a new NexusMods source

func (*NexusMods) AuthURL

func (n *NexusMods) AuthURL() string

AuthURL returns the OAuth authorization URL

func (*NexusMods) CheckUpdates

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

CheckUpdates checks for available updates by comparing installed versions against NexusMods

func (*NexusMods) ExchangeToken

func (n *NexusMods) ExchangeToken(ctx context.Context, code string) (*source.Token, error)

ExchangeToken exchanges an OAuth code for tokens. NexusMods uses API key authentication instead of OAuth. Use SetAPIKey() or the NEXUSMODS_API_KEY environment variable.

func (*NexusMods) GetDependencies

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

GetDependencies returns mod dependencies from NexusMods

func (*NexusMods) GetDownloadURL

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

GetDownloadURL gets the download URL for a mod file

func (*NexusMods) GetMod

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

GetMod retrieves a specific mod

func (*NexusMods) GetModFiles

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

GetModFiles returns the available download files for a mod

func (*NexusMods) ID

func (n *NexusMods) ID() string

ID returns the source identifier

func (*NexusMods) IsAuthenticated

func (n *NexusMods) IsAuthenticated() bool

IsAuthenticated returns true if an API key is configured

func (*NexusMods) Name

func (n *NexusMods) Name() string

Name returns the display name

func (*NexusMods) Search

func (n *NexusMods) Search(ctx context.Context, query source.SearchQuery) ([]domain.Mod, error)

Search finds mods matching the query

func (*NexusMods) SetAPIKey

func (n *NexusMods) SetAPIKey(key string)

SetAPIKey sets the API key for authentication

func (*NexusMods) ValidateAPIKey

func (n *NexusMods) ValidateAPIKey(ctx context.Context, key string) error

ValidateAPIKey validates an API key with the NexusMods API

type UpdateEntry

type UpdateEntry struct {
	ModID             int   `json:"mod_id"`
	LatestFileUpdate  int64 `json:"latest_file_update"`
	LatestModActivity int64 `json:"latest_mod_activity"`
}

UpdateEntry represents a mod update from the updated mods endpoint

Jump to

Keyboard shortcuts

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