Revolt API Client & Types

raw JSON →
0.12.0 verified Sat Apr 25 auth: no javascript

The official JavaScript/TypeScript client library for the Revolt chat API (revolt-api). Current version 0.12.0 provides fully typed API request builder and TypeScript typings for all API objects. Ships with ESM and CommonJS support, includes built-in TypeScript declarations. Key differentiator: auto-generated from OpenAPI spec via @insertish/oapi, ensuring type safety for all endpoints and parameters. Developed by the Revolt team, follows semantic versioning.

error Error: Cannot find module 'revolt-api'
cause Package not installed or incorrect import path
fix
Install the package: npm install revolt-api
error TypeError: client.get is not a function
cause Imported incorrectly (e.g., default import instead of named import)
fix
Ensure correct import: import { API } from 'revolt-api'
error Property 'username' does not exist on type 'unknown'
cause Missing TypeScript type for User or improper type handling
fix
Import type { User } from 'revolt-api' and use it explicitly: const user: User = await client.get('/users/@me')
error TypeError: Failed to fetch
cause Invalid token or network error
fix
Check that REVOLT_TOKEN is set correctly and the API URL is reachable
gotcha When using CommonJS (require), you must destructure the import: const { API } = require('revolt-api')
fix Use const { API } = require('revolt-api') instead of const API = require('revolt-api')
gotcha Authentication object expects property 'revolt' with the bot token, not 'token' or 'bot'
fix Pass { authentication: { revolt: 'your-token' } } to the API constructor
gotcha Posting to endpoints that require no body (e.g., DELETE /channels/:id) still expects second argument, but you can omit it
fix client.delete('/channels/some-id') works fine without a second argument
gotcha The package exports only types and API class; there is no message builder or WebSocket client included
fix Use complementary packages like revolt.js for full bot development
npm install stoat-api
yarn add stoat-api
pnpm add stoat-api

Shows initialization with optional authentication, fetching current user, and posting a message with full TypeScript types.

import { API } from 'revolt-api';

const client = new API({ authentication: { revolt: process.env.REVOLT_TOKEN ?? '' } });

// Fetch the current user
client.get('/users/@me')
  .then(user => {
    console.log(`Hello ${user.username}`);
  })
  .catch(err => console.error('Error:', err));

// Send a message
client.post('/channels/some_channel_id/messages', {
  content: 'Hello from stoat-api!'
}).then(msg => console.log('Message sent:', msg.id));