Templates · Messaging

Discord API collection template

Send and read channel messages and list servers with a Discord bot.

What's inside

Discord bot basics: check the bot, list the servers it is in, read a channel and send a message.

5 requests in 2 folders · Base URL https://discord.com/api/v10 · API key in the Authorization header

Set it up

  1. Open Discord API in Requestarium (or in the app: Import, Start from a template) and import it. You get the collection and a "Discord API" environment.
  2. Create an application at discord.com/developers/applications, add a bot, copy its token and invite it to your server with the Send Messages and Read Message History permissions.
  3. Fill in the environment, pick it in the environment menu and send the first request.

Environment variables

VariableWhat it is
discordBotTokensecretBot token.
channelIdChannel id (Developer Mode, right-click the channel, Copy Channel ID).

Requests

Bot

  • GET
    Get the bot user /users/@me

    The bot account; a quick way to check the token.

  • GET
    List servers /users/@me/guilds

    Servers the bot is in.

Messages

  • GET
    Get a channel /channels/{{channelId}}

    Channel name, type and topic.

  • GET
    Read messages /channels/{{channelId}}/messages

    The latest messages.

  • POST
    Send a message /channels/{{channelId}}/messages

    Posts as the bot.