Skip to content

Quickstart

Add rate limiting capabilities to your API.

How does it work?

Redis is used as the backing storage for the rate limit configurations, and using Lua scripts, the Ratelimit Service can make a determination to allow or deny a request within milliseconds.

Install the Ratelimit CLI

Install the RateLimit CLI https://pypi.org/project/ratelimitcli/. It is a python package that also comes with:

  1. An HTTP client that can be used to manually test your limits.
  2. A python decorator for your HTTP endpoint functions.
pip install ratelimitcli

Set up your config

You won't have an API key yet so just press [ENTER] when asked for a value. You can rerun ratelimitcli configure at any time.

$ ratelimitcli configure
Client ID  [None]:
API key    [None]:
First name [None]: Jasmin
Last name  [None]: Smith
Email name [None]: jasmin.smith@gmail.com
Updated config file (~/.ratelimit/config).

Request an API key

You'll need a credit card to request an API key. See the example below but make sure to add in your own values.

$ ratelimitcli billing configure
Enter a credit card number: 1234567890123456
Enter the expiration date for that credit card: 10/12
Enter the CCV for that credit card: 333
New values have been written to the config file.

Disclaimer

I have not yet implemented payments and as such, you won't be charged for anything. That said, this service is currently in a closed alpha. There is only a single credit card that will allow you to get an API key and you'd have to get that from me.

If this service or the concept is interesting enough for you and you don't mind sending an email, feel free to contact me and we can discuss your usecase.

Oh and the fake card I show above won't work - just FYI.

Test setup

Make sure everything is set up and working by trying to create a rate limit with ratelimitcli limits upsert. This will attempt to connect to the RateLimit API and create a rate limit that can be referenced later.

ratelimitcli limits upsert \
  --throttling-burst-limit 2 \
  --throttling-rate-limit 0

You'll know everything is set up when you get an API response with a limit ID that identifies the rate limit you just created.

Ok: API response ({"limit_id": "a9f9f31b-2c0b-321b-b398-f9d36kd30820"}).