igdb

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 11 Imported by: 0

README

go-igdb

A Go client library for the IGDB (Internet Game Database) API v4. This library provides a convenient way to interact with IGDB's protobuf-based API endpoints.

Features

  • Full support for IGDB API v4 endpoints
  • Protobuf-based communication for efficient data transfer
  • Rate limiting support
  • Automatic token management for Twitch authentication
  • Retry mechanism for failed requests
  • Optional FlareSolverr integration for handling Cloudflare protection

Installation

go get git.nite07.com/nite/go-igdb

Quick Start

package main

import (
	"log"

	"git.nite07.com/nite/go-igdb"
)

func Test1(c *igdb.Client) {
	game, err := c.Games.GetByID(1942)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Name of game %d: %s\n", 1942, game.Name)
}

func Test2(c *igdb.Client) {
	games, err := c.Games.GetByIDs([]uint64{119171, 119133})
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Names of games %d and %d: %s and %s\n", 119171, 119133, games[0].Name, games[1].Name)
}

func Test3(c *igdb.Client) {
	total, err := c.Games.Count()
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Total number of games: %d\n", total)
}

func Test4(c *igdb.Client) {
	games, err := c.Games.Paginated(0, 10)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Names of ids 0 to 10 games:\n")
	for _, game := range games {
		log.Println(game.Name)
	}
}

func Test5(c *igdb.Client) {
	game, err := c.Games.Query("fields name,rating; sort rating desc; limit 1;")
	if err != nil {
		log.Fatalf("failed to get game: %s", err)
	}
	log.Printf("Name of first game with highest rating: %s\n", game[0].Name)
}

func Test6(c *igdb.Client) {
	games, err := c.Games.Query("fields *; where rating > 70; limit 10;")
	if err != nil {
		panic(err)
	}
	log.Printf("Names of games with rating > 70 limit 10:\n")
	for _, game := range games {
		log.Println(game.Name)
	}
}

func main() {
	client := igdb.New("your-client-id", "your-client-secret")
	Test1(client)
	Test2(client)
	Test3(client)
	Test4(client)
	Test5(client)
	Test6(client)
}

Example Projects

Dependencies

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRestyClient

func NewRestyClient() *resty.Client

Types

type Client

type Client struct {
	AgeRatingCategories            *endpoint.AgeRatingCategories
	AgeRatingContentDescriptions   *endpoint.AgeRatingContentDescriptions
	AgeRatingContentDescriptionsV2 *endpoint.AgeRatingContentDescriptionsV2
	AgeRatingOrganizations         *endpoint.AgeRatingOrganizations
	AgeRatings                     *endpoint.AgeRatings
	AlternativeNames               *endpoint.AlternativeNames
	Artworks                       *endpoint.Artworks
	CharacterGenders               *endpoint.CharacterGenders
	CharacterMugShots              *endpoint.CharacterMugShots
	Characters                     *endpoint.Characters
	CharacterSpecies               *endpoint.CharacterSpecies
	CollectionMemberships          *endpoint.CollectionMemberships
	CollectionMembershipTypes      *endpoint.CollectionMembershipTypes
	CollectionRelations            *endpoint.CollectionRelations
	CollectionRelationTypes        *endpoint.CollectionRelationTypes
	Collections                    *endpoint.Collections
	CollectionTypes                *endpoint.CollectionTypes
	Companies                      *endpoint.Companies
	CompanyLogos                   *endpoint.CompanyLogos
	CompanyStatuses                *endpoint.CompanyStatuses
	CompanyWebsites                *endpoint.CompanyWebsites
	Covers                         *endpoint.Covers
	DateFormats                    *endpoint.DateFormats
	EventLogos                     *endpoint.EventLogos
	EventNetworks                  *endpoint.EventNetworks
	Events                         *endpoint.Events
	ExternalGames                  *endpoint.ExternalGames
	ExternalGameSources            *endpoint.ExternalGameSources
	Franchises                     *endpoint.Franchises
	GameEngineLogos                *endpoint.GameEngineLogos
	GameEngines                    *endpoint.GameEngines
	GameLocalizations              *endpoint.GameLocalizations
	GameModes                      *endpoint.GameModes
	GameReleaseFormats             *endpoint.GameReleaseFormats
	Games                          *endpoint.Games
	GameStatuses                   *endpoint.GameStatuses
	GameTimeToBeats                *endpoint.GameTimeToBeats
	GameTypes                      *endpoint.GameTypes
	GameVersionFeatures            *endpoint.GameVersionFeatures
	GameVersionFeatureValues       *endpoint.GameVersionFeatureValues
	GameVersions                   *endpoint.GameVersions
	GameVideos                     *endpoint.GameVideos
	Genres                         *endpoint.Genres
	InvolvedCompanies              *endpoint.InvolvedCompanies
	Keywords                       *endpoint.Keywords
	Languages                      *endpoint.Languages
	LanguageSupports               *endpoint.LanguageSupports
	LanguageSupportTypes           *endpoint.LanguageSupportTypes
	MultiplayerModes               *endpoint.MultiplayerModes
	NetworkTypes                   *endpoint.NetworkTypes
	PlatformFamilies               *endpoint.PlatformFamilies
	PlatformLogos                  *endpoint.PlatformLogos
	Platforms                      *endpoint.Platforms
	PlatformTypes                  *endpoint.PlatformTypes
	PlatformVersionCompanies       *endpoint.PlatformVersionCompanies
	PlatformVersionReleaseDates    *endpoint.PlatformVersionReleaseDates
	PlatformVersions               *endpoint.PlatformVersions
	PlatformWebsites               *endpoint.PlatformWebsites
	PlayerPerspectives             *endpoint.PlayerPerspectives
	PopularityPrimitives           *endpoint.PopularityPrimitives
	PopularityTypes                *endpoint.PopularityTypes
	Regions                        *endpoint.Regions
	ReleaseDateRegions             *endpoint.ReleaseDateRegions
	ReleaseDates                   *endpoint.ReleaseDates
	ReleaseDateStatuses            *endpoint.ReleaseDateStatuses
	Screenshots                    *endpoint.Screenshots
	Search                         *endpoint.Search
	Themes                         *endpoint.Themes
	Webhooks                       *endpoint.Webhooks
	Websites                       *endpoint.Websites
	WebsiteTypes                   *endpoint.WebsiteTypes
	// contains filtered or unexported fields
}

func New

func New(clientID, clientSecret string) *Client

func NewWithFlaresolverr

func NewWithFlaresolverr(clientID, clientSecret string, f *flaresolverr.Flaresolverr) *Client

func (*Client) Request

func (g *Client) Request(ctx context.Context, method string, requestURL string, dataBody any) (*resty.Response, error)

type RequestFunc

type RequestFunc func(method string, URL string, dataBody any) (*resty.Response, error)

type SilentLogger

type SilentLogger struct{}

func (SilentLogger) Debugf

func (s SilentLogger) Debugf(string, ...any)

func (SilentLogger) Errorf

func (s SilentLogger) Errorf(string, ...any)

func (SilentLogger) Warnf

func (s SilentLogger) Warnf(string, ...any)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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