Skip to content

Latest commit

 

History

History
280 lines (224 loc) · 5.14 KB

Usage.md

File metadata and controls

280 lines (224 loc) · 5.14 KB

Shredx Redis Rate Limiter

APIs for Redis Rate Limiter platform built as part of https://github.com/shredx

The platform consists of three parts

Usage

  • 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

Requests

POST - /provision/v1/users/

Description

This API will create a test user in the platform. You have to now create a subscription key for that user

CURL

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"="test@test.com" \
    --data-raw "name"="Tester"

Header Parameters

  • 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="
}

Body Parameters

  • email should respect the following schema:
{
  "type": "string",
  "enum": [
    "test@test.com"
  ],
  "default": "test@test.com"
}
  • name should respect the following schema:
{
  "type": "string",
  "enum": [
    "Tester"
  ],
  "default": "Tester"
}

POST - /provision/v1/users/subscriptions

Description

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

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"="test@test.com"

Header Parameters

  • 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="
}

Body Parameters

  • email should respect the following schema:
{
  "type": "string",
  "enum": [
    "test@test.com"
  ],
  "default": "test@test.com"
}

GET - /api/

Description

You can check the usage of your API using the API Usage api

CURL

curl -X GET "http://127.0.0.1:8081/api/" \
    -H "token: e3795d31-6423-4f46-8acd-1724888955c5" \
    -H "Cookie: REVEL_FLASH="

Header Parameters

  • 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="
}

POST - /status/usage

Description

This api gives information about the token's api usage. You can reset the api usage using Usage Reset api

CURL

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"

Header Parameters

  • 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="
}

Body Parameters

  • token should respect the following schema:
{
  "type": "string",
  "enum": [
    "e3795d31-6423-4f46-8acd-1724888955c5"
  ],
  "default": "e3795d31-6423-4f46-8acd-1724888955c5"
}

POST - /status/reset

Description

This API will reset the usage of the given api token

CURL

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"

Header Parameters

  • 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="
}

Body Parameters

  • token should respect the following schema:
{
  "type": "string",
  "enum": [
    "e3795d31-6423-4f46-8acd-1724888955c5"
  ],
  "default": "e3795d31-6423-4f46-8acd-1724888955c5"
}