Skip to content

Api-Wrappers/igdb-wrapper

Repository files navigation

igdb-wrapper

npm version npm downloads license CI

A type-safe TypeScript client for the IGDB API with a fluent query builder, automatic retries, and built-in rate limiting.

const games = await client.games
  .query()
  .select((g) => ({ name: g.name, rating: g.rating }))
  .where((g, { or }) => or(g.rating.gte(90), g.aggregated_rating.gte(90)))
  .sort((g) => g.rating, "desc")
  .limit(10)
  .execute();

Features

  • All current IGDB v4 endpoints — every endpoint listed in the official API docs is exposed on IGDBClient
  • Fully type-safe — field selection and where conditions are inferred from model types where available, with raw field helpers for new IGDB fields
  • Fluent query builder — chainable .select(), .fields(), .exclude(), .where(), .whereRaw(), .sort(), .limit(), .offset(), .search()
  • Automatic retries — exponential backoff on transient failures, configurable
  • Rate limiting — respects IGDB's concurrency limits out of the box
  • Pagination — async generator via .paginate(), plus .count() for UI pagination
  • Multi-query and webhooks — helpers for /multiquery and IGDB webhook management
  • Reference helpers — image URL and tag-number helpers, endpoint /meta, and protobuf response access
  • Structured errorsIGDBAuthError, IGDBRateLimitError, IGDBNotFoundError, IGDBValidationError

Installation

npm install @api-wrappers/igdb-wrapper
# or
yarn add @api-wrappers/igdb-wrapper
# or
pnpm add @api-wrappers/igdb-wrapper
# or
bun add @api-wrappers/igdb-wrapper

Requirements: Node.js 18+ (uses native fetch). TypeScript 5+ recommended.


Quick Start

You'll need a Twitch Developer application to obtain a client_id and client_secret.

import { IGDBClient } from "@api-wrappers/igdb-wrapper";

const client = new IGDBClient({
  clientId: process.env.TWITCH_CLIENT_ID!,
  clientSecret: process.env.TWITCH_CLIENT_SECRET!,
});

const game = await client.games
  .query()
  .where((g) => g.slug.eq("elden-ring"))
  .first();

console.log(game?.name); // "Elden Ring"

Documentation

Guide Description
Getting Started Installation, credentials, and your first query
Querying Full query builder API — select, where, sort, paginate
Endpoints All IGDB v4 endpoint properties and raw endpoint access
Error Handling All error types and how to handle them
Configuration Retry, rate limiting, and advanced options
API Reference Complete method signatures

License

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


❤️

❤️ Reminder that you are great, you are enough, and your presence is valued. If you are struggling with your mental health, please reach out to someone you love and consult a professional. You are not alone. ❤️

About

Type-safe TypeScript client for the IGDB API — fluent query builder, automatic retries, and built-in rate limiting

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors