/discord-openapi-client

Autogenerated OpenAPI client for discord

Primary LanguageTypeScriptMIT LicenseMIT

discord-openapi-client

Warning

This is work in progress.

Autogenerated OpenAPI client for Discord, generated from discord/discord-api-spec.

This should contain almost everything you will need to interact with the Discord API, atleast whatever their OpenAPI spec has.

There are absolutely no dependencies apart from the presence of fetch(), which should just be supported in all modern runtimes. I would also recommend using a bundler if you're using this in size-constraint environments like Cloudflare Workers, as this package is quite big.

Usage

Note

This package is ESM only.

Install package:

# @antfu/ni
ni discord-openapi-client

Import:

import {
  getUser /* Import functions you need */,
  getGetUserUrl /* functions that will return the absolute url string */,
} from "discord-openapi-client";

All mutation functions are available under prefixes: get, update, delete, etc.

If you just need the URL with proper URL encoding, those are suffixed with Url, which will return the absolute API URL.

Types for responses, params, 200s are available respectively.

Building

  1. Install dependencies with pnpm
  2. Clone discord/discord-api-spec as openapi
  3. Run pnpm build

why?

I was bored