igdb-atlas
An asynchronous Rust wrapper for the IGDB v4 video game database API.
Overview
igdb-atlas is a strongly-typed, async-first Rust library for interacting with the IGDB v4 API. It handles Twitch OAuth 2.0 authentication, proactive rate limiting, and provides an ergonomic query builder for constructing Apicalypse queries. The crate is designed with extensibility in mind — adding support for new IGDB endpoints requires minimal boilerplate.
Features
- Async by default — Built on
tokioandreqwestfor non-blocking I/O - Automatic authentication — Twitch OAuth 2.0 client credentials flow with transparent token caching and refresh
- Proactive rate limiting — Token bucket algorithm to stay within IGDB's 4 requests/second limit
- Exponential backoff with jitter — Automatic retry logic when 429 errors are encountered
- Ergonomic query builder — Fluent builder pattern supporting the full Apicalypse query syntax
- Strongly-typed models — Domain-organized model modules with proper handling of nullable fields
- Extensible architecture — Generic traits and modular design make adding new endpoints straightforward
- Comprehensive documentation — Full rustdoc coverage with inline examples
Prerequisites
- Rust toolchain (stable, 1.85+)
- A Twitch Developer account with an application registered at https://dev.twitch.tv/console
- Your Twitch Client ID and Client Secret
Note: IGDB requires valid Twitch credentials for all API requests. See Authentication Setup for details.
Installation
Add igdb-atlas to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
Authentication Setup
IGDB authentication is handled via Twitch OAuth 2.0. You will need a Client ID and Client Secret from your Twitch Developer application.
Credentials are passed directly when constructing the client via ClientConfig:
use ;
async
The token manager handles fetching, caching, and refreshing the OAuth token transparently. You do not need to manage token lifecycle manually.
Quick Start
use ;
use ;
async
Query Builder
The query builder supports the full Apicalypse query syntax used by IGDB. Queries are constructed using a fluent builder pattern:
| Method | Apicalypse Equivalent | Description |
|---|---|---|
.select(&[...]) |
fields name, rating; |
Select which fields to return |
.where_clause("...") |
where rating > 80; |
Filter results |
.sort("field", Sort::Asc) |
sort rating asc; |
Sort results |
.limit(n) |
limit 10; |
Limit number of results |
.offset(n) |
offset 20; |
Offset for pagination |
.search("...") |
search "zelda"; |
Full-text search (Searchable endpoints only) |
All methods are optional and can be chained in any order. Note that .search() is only available on endpoints that implement the Searchable trait — see the Supported Endpoints table for details.
Examples
Fetching a Game by ID
use ;
async
Filtering and Sorting
use ;
async
Nested Field Expansion
use ;
async
Pagination
use ;
async
Handling Errors
use ;
async
Rate Limiting
IGDB enforces a limit of 4 requests per second. igdb-atlas handles this in two ways:
- Proactive limiting — A token bucket algorithm ensures requests are spaced appropriately and never exceed the 4/second threshold under normal conditions.
- Reactive backoff — If a
429 Too Many Requestsresponse is received (e.g., due to clock skew or bursts), the client will automatically retry using exponential backoff with jitter. No action is required on your part.
Testing
All tests live in the tests/ directory. Mock response fixtures are provided under tests/fixtures/ to allow tests to run without hitting the live API.
To run the full test suite:
License
This project is dual-licensed under your choice of:
Disclaimer
igdb-atlas is an unofficial, community-maintained wrapper. It is not affiliated with or endorsed by IGDB or Twitch. Usage of this library is subject to the IGDB Terms of Service and the Twitch Developer Agreement. Please ensure your use of the IGDB API complies with their policies.