API Reference

API Reference

/limit API

The /limit endpoint allows you to consume usage for a single key.

Request

  • Method: POST
  • URL: https://api.limitapi.com/limit
  • Headers:
    • Authorization: Bearer your_api_key_here
    • Content-Type: application/json

Request Body

{
  "tag": Optional<string>,
  "key": string,
  "value": Optional<number>,
 
  // See [Limiter Config] page for the different limiter configurations
  "config": (TokenBucketLimiterConfig | FixedWindowLimiterConfig)
}

Response

{
  "status": "success" | "blocked",
 
  "data": {
    "throughputExceeded": boolean,
    "valueRemaining": number,
  }
} | {
  "status": "error",
  "data": {
    "errorMessage": string,
    "debugMessage": Optional<string>
  }
}

Example

curl -X POST https://api.limitapi.com/limit \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"key": "my-rate-limit-key", "value": 1, "limiter": { "type": "token-bucket", "maxTokens": 100, "refillRate": { "tokens": 10, "seconds": 5 } } }'

/batch-limit API

The /batch-limit endpoint allows you to consume usage for multiple keys in a single request. If any of the limiters in the batch return a ‘blocked’ status, the entire batch will return a ‘blocked’ status and no usage will be consumed.

Request

  • Method: POST
  • URL: https://api.limitapi.com/batch-limit
  • Headers:
    • Authorization: Bearer your_api_key_here
    • Content-Type: application/json

Request Body

{
  "limitRequests": {
    [limiterId: string]: {
      "tag": Optional<string>,
 
      "key": string,
      "value": Optional<number>,
 
      // See [Limiter Config] page for the different limiter configurations
      "config": (TokenBucketLimiterConfig | FixedWindowLimiterConfig)
    }
  }
}

Response

{
  "status": "success" | "blocked",
 
  "data": {
    [limiterId: string]: {
      "throughputExceeded": boolean,
      "valueRemaining": number,
    }
  }
} | {
  "status": "error",
  "data": {
    "errorMessage": string
  }
}