Skip to contentAPILayer: production APIs with free plansExplore APILayer
Cover illustration: 15 Free APIs for Discord Bots (With a Working discord.js Example)
Favour Onuoha

Posted on · Updated on · 3 min read

15 Free APIs for Discord Bots (With a Working discord.js Example)

On this page · 6 sections

The best free APIs for Discord bots return something fun or useful in one request, with no API key, fast enough to answer within Discord's 3-second window. The bot runs on a server, so CORS doesn't matter, which opens up hundreds of APIs a browser app can't use. Below are 15 that worked in our checks in October 2026, plus a complete discord.js v14 bot you can run in five minutes.

#15 free APIs for bot commands

Command

API

Endpoint

/cat

Cat Facts

https://catfact.ninja/fact

/dog

Dogs

https://dog.ceo/api/breeds/image/random

/fox

RandomFox

https://randomfox.ca/floof/

/joke

JokeAPI

https://v2.jokeapi.dev/joke/Any?safe-mode

/chuck

Chuck Norris Database

https://api.chucknorris.io/jokes/random

/advice

Advice Slip

https://api.adviceslip.com/advice

/trivia

Open Trivia

https://opentdb.com/api.php?amount=1&type=multiple

/pokemon

PokéAPI

https://pokeapi.co/api/v2/pokemon/{name}

/character

Rick and Morty

https://rickandmortyapi.com/api/character/{id}

/card

Deck of Cards

https://deckofcardsapi.com/api/deck/new/draw/?count=1

/weather

Open-Meteo

https://api.open-meteo.com/v1/forecast?...

/price

CoinGecko

https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd

/convert

Frankfurter

https://api.frankfurter.dev/v1/latest?base=USD&symbols=EUR

/book

Open Library

https://openlibrary.org/search.json?q={title}&limit=1

/show

TVMaze

https://api.tvmaze.com/singlesearch/shows?q={name}

For anime commands, Jikan (an unofficial MyAnimeList API) is the usual choice, but it timed out in one of our checks this month. Add a timeout and a friendly error message if you use it.

#A complete discord.js v14 bot

1. Create the bot. In the Discord Developer Portal, create an application, add a bot, copy its token, and invite it to your server with the applications.commands and bot scopes.

2. Install:

Bash
npm init -y
npm install discord.js

3. Register slash commands (deploy-commands.mjs, run once):

JavaScript
import { REST, Routes, SlashCommandBuilder } from "discord.js";

const commands = [
  new SlashCommandBuilder().setName("cat").setDescription("A random cat fact"),
  new SlashCommandBuilder().setName("joke").setDescription("A random (safe) joke"),
  new SlashCommandBuilder()
    .setName("pokemon")
    .setDescription("Look up a Pokémon")
    .addStringOption((o) => o.setName("name").setDescription("e.g. pikachu").setRequired(true)),
].map((c) => c.toJSON());

const rest = new REST().setToken(process.env.DISCORD_TOKEN);
await rest.put(Routes.applicationGuildCommands(process.env.CLIENT_ID, process.env.GUILD_ID), {
  body: commands,
});
console.log("Commands registered");

4. The bot (bot.mjs):

JavaScript
import { Client, EmbedBuilder, Events, GatewayIntentBits, MessageFlags } from "discord.js";

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

async function getJSON(url) {
  const res = await fetch(url, { signal: AbortSignal.timeout(2500) }); // stay inside Discord's 3 s window
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  return res.json();
}

const handlers = {
  async cat() {
    const { fact } = await getJSON("https://catfact.ninja/fact");
    return { content: `🐱 ${fact}` };
  },
  async joke() {
    const j = await getJSON("https://v2.jokeapi.dev/joke/Any?safe-mode");
    return { content: j.type === "single" ? j.joke : `${j.setup}\n||${j.delivery}||` }; // spoiler the punchline
  },
  async pokemon(interaction) {
    const name = interaction.options.getString("name", true).toLowerCase().trim();
    const p = await getJSON(`https://pokeapi.co/api/v2/pokemon/${encodeURIComponent(name)}`);
    const embed = new EmbedBuilder()
      .setTitle(p.name)
      .setThumbnail(p.sprites.front_default)
      .addFields(
        { name: "Types", value: p.types.map((t) => t.type.name).join(", "), inline: true },
        { name: "Weight", value: `${p.weight / 10} kg`, inline: true },
      );
    return { embeds: [embed] };
  },
};

client.on(Events.InteractionCreate, async (interaction) => {
  if (!interaction.isChatInputCommand()) return;
  const handler = handlers[interaction.commandName];
  if (!handler) return;
  try {
    await interaction.reply(await handler(interaction));
  } catch (err) {
    console.error(err);
    const msg = { content: "That API didn't answer. Try again in a moment.", flags: MessageFlags.Ephemeral };
    interaction.replied ? interaction.followUp(msg) : interaction.reply(msg);
  }
});

client.once(Events.ClientReady, (c) => console.log(`Logged in as ${c.user.tag}`));
client.login(process.env.DISCORD_TOKEN);

Run it with DISCORD_TOKEN=... node bot.mjs. Keep the token in an environment variable, never in code: a leaked bot token lets anyone control your bot.

#Handling slow APIs: deferReply

Discord requires a response within 3 seconds. For APIs that can be slower (Jikan, large searches), acknowledge first, then edit the reply:

JavaScript
await interaction.deferReply();                       // shows "Bot is thinking…"
const data = await fetch(slowUrl).then((r) => r.json()); // you now have up to 15 minutes
await interaction.editReply(`Found: ${data.title}`);

#Rate limits: the bot problem

A popular bot can call an API far more often than one person would. Protect yourself, and the free API:

  1. Cache responses. A weather or price lookup for the same city or coin can be reused for 60 seconds or more.
  2. Add per-user cooldowns. A Map of user ID → last-used timestamp is enough to stop /joke spam.
  3. Batch where possible. Open Trivia can return 50 questions in one call. Fetch a pool and serve from it.
  4. Prefer generous APIs. Open-Meteo allows 10,000 calls a day and CoinGecko's free Demo key 10,000 a month; tight free tiers (25 calls a day) won't survive a busy server.

#Keep it safe for your server

  • Use JokeAPI's safe-mode (or its blacklistFlags) in community servers.
  • Open Trivia returns HTML entities ("), so decode them before display.
  • Don't let users pass arbitrary URLs into a command that fetches them; that turns your bot into a proxy.

More fun APIs, ranked daily by uptime, are on our free APIs for Discord bots and fun APIs lists.

#FAQ

#What are the best free APIs for a Discord bot?

PokéAPI, JokeAPI, Open Trivia, Cat Facts, Dogs, Open-Meteo and CoinGecko: all free, keyless and fast, and they cover the most popular bot commands.

#Do Discord bots need CORS-enabled APIs?

No. Bots run on a server, and CORS only applies in browsers, so any API works, including those that don't support CORS.

#How do I stop my bot from hitting API rate limits?

Cache responses, add per-user cooldowns, and fetch in batches where the API allows it. Use deferReply for slow APIs rather than retrying.

#Can a Discord bot use APIs that need a key?

Yes. Store the key in an environment variable on the server running the bot, the same way you store the bot token.