Skip to main content
Everything you need to integrate Rankly into your bot or application in one place.

Choose Your Integration Path

I'm a Bot Developer

Want to integrate Rankly features into your Discord bot?Start with: Bot API IntegrationLearn how to:
  • Display server stats in commands
  • Check if users can vote
  • Show latest reviews

I Own a Server

Want to receive real-time vote notifications?Start with: Server WebhooksLearn how to:
  • Configure webhook endpoints
  • Process vote events
  • Build reward systems

I Need the API Reference

Looking for complete API documentation?Start with: API ReferenceLearn about:
  • All available endpoints
  • Authentication methods
  • Response formats

I Handle Premium Features

Need to process premium purchases?Start with: Premium WebhooksLearn how to:
  • Receive purchase events
  • Activate user/server premium
  • Handle subscriptions

Quick Comparisons

API vs Webhooks

FeatureAPIWebhooks
DirectionPull (you request)Push (we notify)
LatencyHigher (polling needed)Lower (instant)
Rate LimitedYes (120/min)No
Best ForOccasional queriesReal-time reactions
SetupJust get API keyNeed public endpoint
Use API when: You need data on-demand (commands, dashboards) Use Webhooks when: You need to react immediately to events

Bot API Integration vs Vote Webhooks

ScenarioUse Bot API IntegrationUse Vote Webhooks
Display vote count in command/stats
Auto-reward votes in bot
Check if user can vote
Track vote trendsBothWebhooks better
Show latest reviews
Instant vote processing

5-Minute Setup Guides

For Bot Developers: Display Server Stats

1

Get API Key

Visit Rankly Dashboard → Edit Server → Advanced Setup → Copy API Key
2

Install Dependencies

npm install axios
3

Create Command Handler

const axios = require('axios');

module.exports = {
  data: new SlashCommandBuilder()
    .setName('stats')
    .setDescription('Show server stats from Rankly'),
  
  async execute(interaction) {
    try {
      const response = await axios.get(
        'https://api.rankly.live/api/v1/server',
        { headers: { 'X-API-Key': process.env.RANKLY_API_KEY } }
      );

      if (response.data.success) {
        const server = response.data.data;
        const embed = {
          title: `📊 ${server.name} Stats`,
          color: 0x16A34A,
          fields: [
            { name: 'Members', value: `${server.memberCount.toLocaleString()}`, inline: true }
          ]
        };
        await interaction.reply({ embeds: [embed] });
      }
    } catch (error) {
      await interaction.reply('Failed to fetch stats.');
    }
  }
};
4

Test It

Run /stats in your Discord server and watch it work!

For Server Owners: Set Up Vote Webhooks

1

Prepare Your Endpoint

You’ll need a publicly accessible HTTPS endpoint. Here’s a minimal example:
const express = require('express');
const app = express();
app.use(express.json());

app.post('/webhook/votes', (req, res) => {
  console.log('Vote received:', req.body);
  res.status(200).json({ received: true });
});

app.listen(3000, () => console.log('Server running'));
2

Deploy Endpoint

Deploy to a service like:
  • Heroku
  • Railway
  • Render
  • Your own VPS
Make sure it’s accessible at a public HTTPS URL
3

Configure Webhook

  1. Go to Rankly Dashboard
  2. Click your server
  3. Find “Vote Webhooks” section
  4. Paste your endpoint URL
  5. Click “Test Webhook”
4

Implement Reward Logic

Add code to process votes and grant rewards:
async function processVote(userId, serverId) {
  // Record in database
  await db.votes.insert({ userId, serverId, date: new Date() });
  
  // Grant reward
  await grantCurrency(userId, 100);
  
  console.log(`Rewarded ${userId} for voting!`);
}

Common Scenarios

”I want to show vote rewards eligibility”

Use the API to check vote status:
// Check if user can vote
const response = await axios.get(
  `https://api.rankly.live/api/v1/votes/${userId}`,
  { headers: { 'X-API-Key': process.env.RANKLY_API_KEY } }
);

if (response.data.data.canVote) {
  // Show "Vote now!" button
} else {
  const hours = Math.ceil(
    response.data.data.secondsUntilVote / 3600
  );
  // Show "Vote again in X hours"
}

“I want to auto-reward votes”

Use webhooks to receive instant notifications:
app.post('/webhook/votes', async (req, res) => {
  const { userId, creditsAwarded } = req.body;
  
  // Immediately grant reward
  if (!creditsAwarded) {
    // User might have ad blocker, but reward anyway
    await grantReward(userId, 100);
  } else {
    await grantReward(userId, 100);
  }
  
  res.status(200).json({ received: true });
});

“I need to track vote trends”

Combine API + Webhooks:With webhooks: Record all votes in real-timeWith API: Periodically fetch reviews to understand sentiment
// Record from webhook
app.post('/webhook/votes', async (req, res) => {
  await db.votes.insert(req.body);
  res.status(200).json({ received: true });
});

// Analyze trends
app.get('/trends', async (req, res) => {
  const last24h = await db.votes.countDocuments({
    timestamp: { $gte: new Date(Date.now() - 86400000) }
  });
  res.json({ votes24h: last24h });
});

Secrets & Configuration

Never hardcode API keys or webhook secrets in your source code!

Environment Variables

Create a .env file:
# API Key for accessing Rankly API
RANKLY_API_KEY=rk_live_...

# Webhook secrets for verification
RANKLY_VOTE_WEBHOOK_SECRET=secret_...
RANKLY_PREMIUM_WEBHOOK_SECRET=secret_...

# Your webhook endpoint
WEBHOOK_URL=https://your-domain.com/webhooks

Loading in Code

require('dotenv').config();

const apiKey = process.env.RANKLY_API_KEY;
const voteSecret = process.env.RANKLY_VOTE_WEBHOOK_SECRET;

Error Handling

API Errors

async function getServerDetails() {
  try {
    const response = await axios.get(
      'https://api.rankly.live/api/v1/server',
      { headers: { 'X-API-Key': process.env.RANKLY_API_KEY } }
    );

    if (!response.data.success) {
      console.error('API Error:', response.data.error);
      return null;
    }

    return response.data.data;
  } catch (error) {
    if (error.response?.status === 401) {
      console.error('Invalid API key');
    } else if (error.response?.status === 429) {
      console.error('Rate limited - wait before retrying');
    } else {
      console.error('Network error:', error.message);
    }
    return null;
  }
}

Webhook Signature Verification

Always verify signatures:
const crypto = require('crypto');

function verifySignature(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(payload))
    .digest('hex');
  
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

app.post('/webhook/votes', (req, res) => {
  const signature = req.headers['x-webhook-signature'];
  
  if (!verifySignature(req.body, signature, process.env.RANKLY_VOTE_WEBHOOK_SECRET)) {
    return res.status(401).json({ error: 'Invalid signature' });
  }

  // Safe to process
  res.status(200).json({ received: true });
});

Testing & Debugging

Test API Calls with cURL

# Test API key
curl -X GET "https://api.rankly.live/api/v1/server" \
  -H "X-API-Key: rk_live_..." \
  -H "Content-Type: application/json"

# Check vote status
curl -X GET "https://api.rankly.live/api/v1/votes/987654321098765432" \
  -H "X-API-Key: rk_live_..."

# Get reviews
curl -X GET "https://api.rankly.live/api/v1/reviews?limit=5&sort=highest" \
  -H "X-API-Key: rk_live_..."

Test Webhooks with Webhook.site

  1. Go to webhook.site
  2. Copy the unique URL
  3. Paste into Rankly dashboard
  4. Click “Test Webhook”
  5. See the payload appear on webhook.site

Local Testing with ngrok

# Start your local server
npm start  # or python app.py

# In another terminal, expose it
ngrok http 3000

# Use the ngrok URL in Rankly dashboard
# ngrok gives you: https://xxxx-xx-xxx-xxx-xxx.ngrok.io

Next Steps

Cheat Sheet

Authentication

Header: X-API-Key: rk_live_...
Query:  ?key=rk_live_...

Base URL

https://api.rankly.live/api/v1

Endpoints

GET /server          - Server details
GET /bot            - Bot details
GET /votes/{id}     - Check if user can vote
GET /reviews        - Get server reviews

Webhook Events

bot_vote            - User voted for bot
premium_purchase    - Premium purchase
server_vote         - Server received a vote

Rate Limits

120 requests per minute per API Key
Still have questions? Join our Discord community! 🎉