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.
How to Get Your API Key
- 1Go to your bot page editor
- 2Click the Settings tab
- 3Scroll to Developer API Access
- 4Click 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' }
| Parameter | Type | Description |
|---|---|---|
| guildId | string | The Discord guild ID |
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); // '!'
| Parameter | Type | Description |
|---|---|---|
| guildId | string | The Discord guild ID |
| field | string | The key of the field to retrieve |
anyβ The field value, or nullupdateGuildData(guildId, updates)
Updates multiple configuration fields for a guild simultaneously.
const updated = await client.updateGuildData('123456789', {prefix: '?',welcomeMessage: 'Welcome!'});
| Parameter | Type | Description |
|---|---|---|
| guildId | string | The Discord guild ID |
| updates | Record<string, any> | Object containing the fields to update |
Record<string, any>β Updated configurationupdateGuildField(guildId, field, value)
Updates a single configuration field for a guild.
const updated = await client.updateGuildField('123456789', 'prefix', '?');
| Parameter | Type | Description |
|---|---|---|
| guildId | string | The Discord guild ID |
| field | string | The key of the field to update |
| value | any | The new value |
Record<string, any>β Updated configurationREST API
You can also interact with BotPage directly via HTTP requests without using the SDK.
https://dyla.nz/api/v1Required Headers
Authorization: Bearer your-api-key-hereContent-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"
{ "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"
{ "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!"}}'
{ "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.
| Header | Description |
|---|---|
| X-RateLimit-Limit | Maximum requests per window |
| X-RateLimit-Remaining | Requests remaining in the current window |
Error Handling
The API returns standard HTTP status codes. Error responses include a message field with details.
| Status Code | Meaning |
|---|
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 BotPageconst settings = await botpage.getGuildData(message.guild.id);// Use the prefix configured in the dashboardconst 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');