melonly logomelonly logo
melonly logo
Dashboard
Log in

Rate Limits

How many API requests you can make, and what to do when you hit a limit.

What Are the Limits?

Each server can make 60 requests a minute, shared between all of its tokens.

Servers without Melonly Plus also get 100 requests a month. Plus servers have no monthly limit. Requests to the token and verification endpoints don't count towards it.

You can check how many requests you've used this month in your server settings, or with Get Your Rate Limit.

When You Hit a Limit

Requests over a limit get a 429 with the code rate_limited. The Retry-After header says how many seconds to wait:

{
  "error": {
    "code": "rate_limited",
    "message": "too many requests in the current window",
    "details": {
      "currentCount": 60,
      "limit": 60,
      "windowMs": 60000,
      "retryAfter": 60
    }
  }
}

Wait that long, then send the request again:

async function melonly(method, path, body) {
  const response = await fetch(`https://api.melonly.com/api/v1${path}`, {
    method,
    headers: {
      Authorization: `Bearer ${process.env.MELONLY_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: body && JSON.stringify(body),
  });

  if (response.status === 429) {
    const seconds = Number(response.headers.get("Retry-After"));
    await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
    return melonly(method, path, body);
  }
  return response.json();
}

Where to Go Next

Need help?

Still have questions? Join our Discord server for support from the Melonly Team.