Shredx Redis Rate Limiter
APIs for Redis Rate Limiter platform built as part of https://github.com/shredx
The platform consists of three parts
- First create the user
- Then create the subscription key
- Then use the api to be limited
- View the usage status using API Usage
- Reset the token useage using Usage Reset
This API will create a test user in the platform. You have to now create a subscription key for that user
curl -X POST "http://127.0.0.1:8081/provision/v1/users/" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Cookie: REVEL_FLASH=" \
--data-raw "email"="[email protected]" \
--data-raw "name"="Tester"
- Content-Type should respect the following schema:
{
"type": "string",
"enum": [
"application/x-www-form-urlencoded"
],
"default": "application/x-www-form-urlencoded"
}
- Cookie should respect the following schema:
{
"type": "string",
"enum": [
"REVEL_FLASH="
],
"default": "REVEL_FLASH="
}
- email should respect the following schema:
{
"type": "string",
"enum": [
"[email protected]"
],
"default": "[email protected]"
}
- name should respect the following schema:
{
"type": "string",
"enum": [
"Tester"
],
"default": "Tester"
}
This API will create a subscription key for a user with given email address. Now you can copy the token key and use it with the requests to the API gateway to hit the required api with header key for the token as token
.
curl -X POST "http://127.0.0.1:8081/provision/v1/users/subscriptions" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Cookie: REVEL_FLASH=" \
--data-raw "email"="[email protected]"
- Content-Type should respect the following schema:
{
"type": "string",
"enum": [
"application/x-www-form-urlencoded"
],
"default": "application/x-www-form-urlencoded"
}
- Cookie should respect the following schema:
{
"type": "string",
"enum": [
"REVEL_FLASH="
],
"default": "REVEL_FLASH="
}
- email should respect the following schema:
{
"type": "string",
"enum": [
"[email protected]"
],
"default": "[email protected]"
}
You can check the usage of your API using the API Usage
api
curl -X GET "http://127.0.0.1:8081/api/" \
-H "token: e3795d31-6423-4f46-8acd-1724888955c5" \
-H "Cookie: REVEL_FLASH="
- token should respect the following schema:
{
"type": "string",
"enum": [
"e3795d31-6423-4f46-8acd-1724888955c5"
],
"default": "e3795d31-6423-4f46-8acd-1724888955c5"
}
- Cookie should respect the following schema:
{
"type": "string",
"enum": [
"REVEL_FLASH="
],
"default": "REVEL_FLASH="
}
This api gives information about the token's api usage.
You can reset the api usage using Usage Reset
api
curl -X POST "http://127.0.0.1:8081/status/usage" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Cookie: REVEL_FLASH=" \
--data-raw "token"="e3795d31-6423-4f46-8acd-1724888955c5"
- Content-Type should respect the following schema:
{
"type": "string",
"enum": [
"application/x-www-form-urlencoded"
],
"default": "application/x-www-form-urlencoded"
}
- Cookie should respect the following schema:
{
"type": "string",
"enum": [
"REVEL_FLASH="
],
"default": "REVEL_FLASH="
}
- token should respect the following schema:
{
"type": "string",
"enum": [
"e3795d31-6423-4f46-8acd-1724888955c5"
],
"default": "e3795d31-6423-4f46-8acd-1724888955c5"
}
This API will reset the usage of the given api token
curl -X POST "http://127.0.0.1:8081/status/reset" \
-H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
-H "Cookie: REVEL_FLASH=" \
--data-raw "token"="e3795d31-6423-4f46-8acd-1724888955c5"
- Content-Type should respect the following schema:
{
"type": "string",
"enum": [
"application/x-www-form-urlencoded; charset=utf-8"
],
"default": "application/x-www-form-urlencoded; charset=utf-8"
}
- Cookie should respect the following schema:
{
"type": "string",
"enum": [
"REVEL_FLASH="
],
"default": "REVEL_FLASH="
}
- token should respect the following schema:
{
"type": "string",
"enum": [
"e3795d31-6423-4f46-8acd-1724888955c5"
],
"default": "e3795d31-6423-4f46-8acd-1724888955c5"
}