{"id":13414061,"url":"https://github.com/Henry-Sarabia/igdb","last_synced_at":"2025-03-14T20:31:06.250Z","repository":{"id":37979871,"uuid":"101272466","full_name":"Henry-Sarabia/igdb","owner":"Henry-Sarabia","description":"Go client for the Internet Game Database API","archived":false,"fork":false,"pushed_at":"2023-01-30T22:35:49.000Z","size":1152,"stargazers_count":80,"open_issues_count":3,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-07-31T20:53:20.995Z","etag":null,"topics":["api","api-client","client","game","games","go","golang","igdb","igdb-api","video-game"],"latest_commit_sha":null,"homepage":"https://api.igdb.com/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Henry-Sarabia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-24T08:31:53.000Z","updated_at":"2024-06-01T15:13:47.000Z","dependencies_parsed_at":"2023-02-16T12:16:02.532Z","dependency_job_id":null,"html_url":"https://github.com/Henry-Sarabia/igdb","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Henry-Sarabia%2Figdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Henry-Sarabia%2Figdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Henry-Sarabia%2Figdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Henry-Sarabia%2Figdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Henry-Sarabia","download_url":"https://codeload.github.com/Henry-Sarabia/igdb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243642087,"owners_count":20323954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","client","game","games","go","golang","igdb","igdb-api","video-game"],"created_at":"2024-07-30T20:01:56.607Z","updated_at":"2025-03-14T20:31:05.896Z","avatar_url":"https://github.com/Henry-Sarabia.png","language":"Go","funding_links":[],"categories":["Third-party APIs","第三方api","Go","第三方API","Utility"],"sub_categories":["Utility/Miscellaneous","实用程序/Miscellaneous","交流","HTTP Clients","Fail injection","查询语","Advanced Console UIs"],"readme":"# IGDB \n\n[![GoDoc](https://godoc.org/github.com/Henry-Sarabia/igdb?status.svg)](https://pkg.go.dev/github.com/Henry-Sarabia/igdb?tab=doc) [![Build Status](https://travis-ci.org/Henry-Sarabia/igdb.svg?branch=master)](https://travis-ci.org/Henry-Sarabia/igdb) [![Coverage Status](https://coveralls.io/repos/github/Henry-Sarabia/igdb/badge.svg?branch=master)](https://coveralls.io/github/Henry-Sarabia/igdb?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/Henry-Sarabia/igdb)](https://goreportcard.com/report/github.com/Henry-Sarabia/igdb) [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)  \n\n\u003cimg align=\"right\" src=\"https://raw.githubusercontent.com/Henry-Sarabia/igdb/master/img/gopherigdb.png\"\u003e\n\nCommunicate with the [Internet Game Database API](https://www.igdb.com/api) quickly and easily\nwith the **igdb** package. With the **igdb** client, you can retrieve\nextensive information on any number of video games, characters, companies, media, artwork\nand [much more](https://api-docs.igdb.com/#endpoints). Every IGDB API endpoint is supported!\n\nIf you would like to help the Go **igdb** project, please submit a pull request - it's always\ngreatly appreciated.\n\n## Installation\n\nIf you do not have [Go](https://golang.org/) installed yet, you can find installation instructions \n[here](https://golang.org/doc/install). Please note that the package requires Go version\n1.13 or later for module support.\n\nTo pull the most recent version of **igdb**, use `go get`.\n\n```\ngo get github.com/Henry-Sarabia/igdb\n```\n\nThen import the package into your project as you normally would.\n\n```go\nimport \"github.com/Henry-Sarabia/igdb\"\n```\n\nNow you're ready to Go.\n\n## Usage\n\n### Creating A Client\n\nBefore using the **igdb** package, you need to have an IGDB API key. If you do\nnot have a key yet, you can sign up [here](https://api-docs.igdb.com/#account-creation).\n\nCreate a client with your Client-ID and App Access Token to start communicating with the IGDB API.\n\n```go\nclient, err := igdb.NewClient(\"YOUR_CLIENT_ID\", \"YOUR_APP_ACCESS_TOKEN\", nil)\n```\n\nIf you need to use a preconfigured HTTP client, simply pass its address to the\n`NewClient` function.\n\n```go\nclient, err := igdb.NewClient(\"YOUR_CLIENT_ID\", \"YOUR_APP_ACCESS_TOKEN\", \u0026custom)\n```\n\n### Services\n\nThe client contains a distinct service for working with each of the IGDB API\nendpoints. Each service has a set of service functions that make specific API\ncalls to their respective endpoint.  \n\nTo start communicating with the IGDB, choose a service and call its service\nfunction. Take the Games service for example.\n\nTo search for a Game, use the Search service function.\n```go\ngames, err := client.Games.Search(\"zelda\")\n```\n\nTo retrieve several Games by their IGDB ID, use the List service function.\n```go\ngames, err := client.Games.List([]int{7346, 1721, 2777})\n```\n\nThe rest of the service functions work much the same way; they are concise and\nbehave as you would expect. The [documentation](https://godoc.org/github.com/Henry-Sarabia/igdb#pkg-examples)\ncontains several examples on how to use each service function.\n\nService functions by themselves allow you to retrieve a considerable amount of\ninformation from the IGDB but sometimes you need more control over the results\nbeing returned. For this reason, the **igdb** package provides a set of \nflexible functional options for customizing a service function's API query.\n\n### Functional Options\n\nThe **igdb** package uses what are called functional options to apply different \nquery parameters to service function's API call. Functional options themselves\nare merely first order functions that are passed to a service function.\n\nLet's walk through a few different functional option examples.\n\nTo set the limit of the amount of results returned from an API query, pass \nSetLimit to the service function.\n```go\ngames, err := client.Games.Search(\"megaman\", SetLimit(15))\n```\nAs you can see, you simply need to pass the functional option as an argument \nto the service function.\n\nTo offset the results returned from an API call, pass SetOffset to the service\nfunction.\n```go\ngames, err := client.Games.Search(\"megaman\", SetOffset(15))\n```\nSetOffset is used to iterate through a large set of results that cannot be \nretrieved in a single API call. In this case, the first 15 results are ignored\nso we effectively iterated through to the next set of results by 15.\n\nTo set the order of the results returned from an API call, pass SetOrder much\nin the same way as the previous examples.\n```go\ngames, err := client.Games.Search(\"megaman\", SetOrder(\"hypes\", igdb.OrderDescending))\n```\nSetOrder is used to specify in what order you want the results to be retrieved \nin and by what criteria. Here, SetOrder will retrieve the results with the \nhighest hypes first.\n\nThe remaining functional options are not unlike the examples we covered and \nare further described in the [documentation](https://godoc.org/github.com/Henry-Sarabia/igdb#Option).\n\n### Functional Option Composition\n\nMore often than not, you will need to set more than one option for an API query.\nFortunately, this functionality is supported through variadic functions and\nfunctional option composition.\n\nFirst, service functions are variadic so you can pass in any number of \nfunctional options.\n```go\nchars, err := client.Characters.Search(\n    \"mario\",\n    SetFields(\"id\", \"name\", \"games\"),\n    SetFilter(\"gender\", \"1\"),\n    SetLimit(5), \n    )\n```\nThis API call will search the Characters endpoint using the query \"mario\",\nfilter out any character that does not have a gender code of 1 (which in this\ncase represents male), retrieve the id, name, and games fields, and return\nonly up to 5 of these results.\n\nSecond, the **igdb** package provides a `ComposeOptions` function which takes any \nnumber of functional options as its parameters, composes them into a single\nfunctional option, and returns that composed functional option.\n```go\nhypeOpt := igdb.ComposeOptions(\n    igdb.SetLimit(5),\n    igdb.SetFields(\"name\"),\n\tigdb.SetOrder(\"hypes\", igdb.OrderDescending),\n)\n```\nThis call to ComposeOptions creates a single functional option that will allow\nyou to retrieve the names of the top 5 most popular games when passed to the\nappropriate service function.\n\nFunctional option composition allows you to create custom functional options\nthat can be reused in different API calls.\n\nTaking the previous example, this can be done in the following way.\n```go\nPS4, err := c.Games.Index(\n\t\tpopularOpt,\n\t\tigdb.SetFilter(\"platforms\", igdb.OpEquals, \"48\"),    // filter out games not on PS4\n    )\n    \nXBOX, err := c.Games.Index(\n\t\tpopularOpt, \n\t\tigdb.SetFilter(\"platforms\", igdb.OpEquals, \"49\"),    // filter out games not on XB1\n    )\n```\nThis example has two service function calls that each utilize the previously\ncomposed functional option in the same way but for different platforms. The \nfirst function retrieves the top 5 most popular PS4 games while the second\nfunction retrieves the top 5 most popular XB1 games.\n\nFunctional option composition reduces duplicate code and helps keep your code\nDRY. You can even compose newly composed functional options for even more\nfinely grained control over similar API calls.\n\n## Examples\n\nThe repository contains several example mini-applications that demonstrate\nhow one might use the **igdb** package.\n\n* [Mini Applications](https://github.com/Henry-Sarabia/igdb/tree/master/examples)\n* [Documentation Examples](https://godoc.org/github.com/Henry-Sarabia/igdb#pkg-examples)\n\nIf you have used the **igdb** package for a project and would like to have it\nfeatured here as a reference for new users, please submit an issue and I'll be\nsure to add it.\n\n## Contributions\n\nIf you would like to contribute to this project, please adhere to the following\nguidelines.\n\n* Submit an issue describing the problem.\n* Fork the repo and add your contribution.\n* Add appropriate tests.\n* Run go fmt, go vet, and golint.\n* Prefer idiomatic Go over non-idiomatic code.\n* Follow the basic Go conventions found [here](https://github.com/golang/go/wiki/CodeReviewComments).\n* If in doubt, try to match your code to the current codebase.\n* Create a pull request with a description of your changes.\n\nAgain, contributions are greatly appreciated!\n\n## Special Thanks\n\n\u003cimg align=\"right\" src=\"https://github.com/Henry-Sarabia/igdb/blob/master/img/gopherthanks.png\"\u003e\n\n* You for your interest\n* John for the IGDB Gopher\n* Peter for the \"Thank You\" Gopher\n* Dave Cheney for his [article](https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis)\non functional options\n* The [DiscordGo](https://github.com/bwmarrin/discordgo) and Go [Spotify](https://github.com/zmb3/spotify)\nprojects for inspiring me to create my own open source package for others to enjoy\n* The [Awesome Go](https://github.com/avelino/awesome-go) project for so many\nreferences to admire\n* The awesome people in the [IGDB community](https://discord.gg/JKsh9R7) who are always open to questions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHenry-Sarabia%2Figdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHenry-Sarabia%2Figdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHenry-Sarabia%2Figdb/lists"}