Getting Started

The BotPage SDK and API allow you to read and update your users' dashboard settings directly from your Discord bot's code. This is the bridge between your bot page's web dashboard and your bot's server-side logic.

Prerequisites

  • A BotPage account with at least one bot page created
  • An active Premium subscription on the bot page
  • An API key (generated from the Settings tab)
  • Node.js 16+ (for the SDK)

Authentication

All API requests require authentication via an API key. Your API key is tied to a specific bot page.

Keep your API key secret. Never commit it to version control or share it publicly.

How to Get Your API Key

  1. 1
    Go to your bot page editor
  2. 2
    Click the Settings tab
  3. 3
    Scroll to Developer API Access
  4. 4
    Click Generate Key to create your API key

To regenerate your API key, click Regenerate Key. This will invalidate your previous key immediately.

Installing the SDK

The official BotPage SDK is available as an npm package.

npm install botpage-sdk

Initialization

const { BotpageClient } = require('botpage-sdk');
const client = new BotpageClient('your-api-key-here');

SDK Reference

The BotpageClient class provides methods to interact with your bot page's dashboard data.

getGuildData(guildId)

Fetches all dashboard values configured for a specific guild.

const data = await client.getGuildData('123456789');
console.log(data);
// { prefix: '!', welcomeMessage: 'Hello!', logsChannel: '987654321' }
ParameterTypeDescription
guildIdstringThe Discord guild ID
Returns: Record<string, any>

getGuildField(guildId, field)

Fetches a single specific field value from a guild's configuration.

const prefix = await client.getGuildField('123456789', 'prefix');
console.log(prefix); // '!'
ParameterTypeDescription
guildIdstringThe Discord guild ID
fieldstringThe key of the field to retrieve
Returns: anyβ€” The field value, or null

updateGuildData(guildId, updates)

Updates multiple configuration fields for a guild simultaneously.

const updated = await client.updateGuildData('123456789', {
prefix: '?',
welcomeMessage: 'Welcome!'
});
ParameterTypeDescription
guildIdstringThe Discord guild ID
updatesRecord<string, any>Object containing the fields to update
Returns: Record<string, any>β€” Updated configuration

updateGuildField(guildId, field, value)

Updates a single configuration field for a guild.

const updated = await client.updateGuildField('123456789', 'prefix', '?');
ParameterTypeDescription
guildIdstringThe Discord guild ID
fieldstringThe key of the field to update
valueanyThe new value
Returns: Record<string, any>β€” Updated configuration

REST API

You can also interact with BotPage directly via HTTP requests without using the SDK.

Base URL
https://dyla.nz/api/v1

Required Headers

Authorization: Bearer your-api-key-here
Content-Type: application/json

GET/data?guildId={id}

Get all configured data for a specific guild.

"text-purple-400">curl "text-purple-400">-X GET "https://dyla.nz/api/v1/data?guildId=123456789" \
"text-purple-400">-H "Authorization: Bearer your-api-key-here"
Response: { "data": { "prefix": "!", ... } }

GET/data?guildId={id}&field={field}

Get a single specific field value.

"text-purple-400">curl "text-purple-400">-X GET "https://dyla.nz/api/v1/data?guildId=123456789&field=prefix" \
"text-purple-400">-H "Authorization: Bearer your-api-key-here"
Response: { "value": "!" }

PATCH/data

Update multiple fields simultaneously.

"text-purple-400">curl "text-purple-400">-X PATCH "https://dyla.nz/api/v1/data" \
"text-purple-400">-H "Authorization: Bearer your-api-key-here" \
"text-purple-400">-H "Content-Type: application/json" \
"text-purple-400">-d '{"guildId": "123456789", "updates": {"prefix": "?", "welcomeMessage": "Welcome!"}}'
Response: { "message": "Updated successfully", "data": { ... } }

Or update a single field:

"text-purple-400">curl "text-purple-400">-X PATCH "https://dyla.nz/api/v1/data" \
"text-purple-400">-H "Authorization: Bearer your-api-key-here" \
"text-purple-400">-H "Content-Type: application/json" \
"text-purple-400">-d '{"guildId": "123456789", "field": "prefix", "value": "?"}'

Rate Limiting

The API is rate limited to 100 requests per minute per API key. Rate limit information is included in response headers.

HeaderDescription
X-RateLimit-LimitMaximum requests per window
X-RateLimit-RemainingRequests remaining in the current window

Error Handling

The API returns standard HTTP status codes. Error responses include a message field with details.

Status CodeMeaning

Example Error Response

{
"message": "Missing or invalid guildId"
}

Full Example

Here's a complete example of a Discord.js bot that uses the BotPage SDK to fetch and apply server settings.

Discord.js Bot Integration

const { Client, GatewayIntentBits } = require('discord.js');
const { BotpageClient } = require('botpage-sdk');
const discord = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
const botpage = new BotpageClient('your-api-key-here');
discord.on('messageCreate', async (message) => {
if (message.author.bot) return;
// Fetch this server's settings from BotPage
const settings = await botpage.getGuildData(message.guild.id);
// Use the prefix configured in the dashboard
const prefix = settings.prefix || '!';
if (!message.content.startsWith(prefix)) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'ping') {
message.reply('Pong!');
}
if (command === 'welcome') {
const welcomeMsg = settings.welcomeMessage || 'Welcome to the server!';
message.reply(welcomeMsg);
}
});
discord.login('your-discord-bot-token');