Welcome to the SpecterBot Custom API!
This platform allows developers to integrate seamlessly with our service.
Use your personalized subdomain at guest_user.specterbot.app to
interact with your custom endpoints.
Please note that you need to sign in to verify your
database connection with SpecterBot.
database.php in your PHP files to auto-connect to your database.
<?php
require '/var/www/specterbotapp/database.php';
This provides two connection variables:
$conn — Your main channel database connection (always available).$conn_module — Connection to your custom modules database ({username}_custom_modules), if it exists. This will be null if no custom module database has been created for your channel.Connect to the BotOfTheSpecter WebSocket server to receive real-time events such as channel point redemptions, subscriptions, and more.
WebSocket Connection
Your API code can be found in your BotOfTheSpecter Dashboard. Never paste it directly into your overlay file — store it securely in a separate config file instead.
1. Create a secure config file for your API code:
Use a random filename so it cannot be easily guessed (e.g. x9k2m7p_config.php). This file should never be your main overlay file.
Also choose a unique random string for the guard constant — something hard to guess. Generate one at uuidgenerator.net or just mash your keyboard. Both your config file and overlay file must use the same constant name.
<?php
if (!defined('j4iDSiaiuF3V')) { // replace j4iDSiaiuF3V with your own unique string
header('HTTP/1.0 403 Forbidden');
exit('Access denied');
}
define('BOTOFTHE_SPECTER_CODE', 'YOUR_ACTUAL_API_CODE_HERE');
?>
The guard at the top ensures this file cannot be accessed directly in a browser — it can only be loaded by your own overlay file.
2. Load your config at the top of your overlay file:
<?php
define('j4iDSiaiuF3V', true); // must match the constant name in your config file
require_once __DIR__ . '/x9k2m7p_config.php'; // use your actual random filename here
$apiCode = BOTOFTHE_SPECTER_CODE;
?>
3. Include the Socket.IO client library and pass your code into JavaScript:
<script src="https://cdn.socket.io/4.8.3/socket.io.min.js"></script>
<script>
const code = '<?php echo htmlspecialchars($apiCode, ENT_QUOTES); ?>';
</script>
4. Connect and register your session:
Once connected, emit a REGISTER event with three required fields:
code — Your BotOfTheSpecter API code, securely loaded from your config file as shown above.channel — The channel type. Use 'Custom Overlay' for custom integrations built here.name — A unique, descriptive name for this specific overlay or integration (e.g. 'Loyalty Card', 'My Alert Box'). Each integration you build should use a different name.const socket = io('wss://websocket.botofthespecter.com', {
reconnection: false
});
socket.on('connect', () => {
socket.emit('REGISTER', {
code: code,
channel: 'Custom Overlay',
name: 'My Custom Integration'
});
});
5. Listen for server confirmation and events:
socket.on('WELCOME', (data) => {
console.log('Server welcome:', data);
});
socket.on('SUCCESS', (data) => {
console.log('Registration successful:', data);
});
socket.on('disconnect', () => {
// Implement your own reconnect logic here
setTimeout(() => connectWebSocket(), 5000);
});