Skip to content

Latest commit

 

History

History
413 lines (300 loc) · 31.1 KB

README.md

File metadata and controls

413 lines (300 loc) · 31.1 KB

Ratelimit

(ratelimit)

Overview

Available Operations

limit

Example Usage

import { Unkey } from "@unkey/api";

const unkey = new Unkey({
  rootKey: "UNKEY_ROOT_KEY",
});

async function run() {
  const result = await unkey.ratelimit.limit({
    namespace: "sms.sign_up",
    duration: 711276,
    identifier: "<value>",
    limit: 581877,
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { UnkeyCore } from "@unkey/api/core.js";
import { ratelimitLimit } from "@unkey/api/funcs/ratelimitLimit.js";

// Use `UnkeyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const unkey = new UnkeyCore({
  rootKey: "UNKEY_ROOT_KEY",
});

async function run() {
  const res = await ratelimitLimit(unkey, {
    namespace: "sms.sign_up",
    duration: 711276,
    identifier: "<value>",
    limit: 581877,
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request components.V2RatelimitLimitRequestBody ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.V2RatelimitLimitResponseBody>

Errors

Error Type Status Code Content Type
errors.BadRequestErrorResponse 400 application/json
errors.UnauthorizedErrorResponse 401 application/json
errors.ForbiddenErrorResponse 403 application/json
errors.NotFoundErrorResponse 404 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*

setOverride

Example Usage

import { Unkey } from "@unkey/api";

const unkey = new Unkey({
  rootKey: "UNKEY_ROOT_KEY",
});

async function run() {
  const result = await unkey.ratelimit.setOverride({
    duration: 629394,
    identifier: "<value>",
    limit: 925291,
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { UnkeyCore } from "@unkey/api/core.js";
import { ratelimitSetOverride } from "@unkey/api/funcs/ratelimitSetOverride.js";

// Use `UnkeyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const unkey = new UnkeyCore({
  rootKey: "UNKEY_ROOT_KEY",
});

async function run() {
  const res = await ratelimitSetOverride(unkey, {
    duration: 629394,
    identifier: "<value>",
    limit: 925291,
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request components.V2RatelimitSetOverrideRequestBody ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.V2RatelimitSetOverrideResponseBody>

Errors

Error Type Status Code Content Type
errors.BadRequestErrorResponse 400 application/json
errors.UnauthorizedErrorResponse 401 application/json
errors.ForbiddenErrorResponse 403 application/json
errors.NotFoundErrorResponse 404 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*

getOverride

Example Usage

import { Unkey } from "@unkey/api";

const unkey = new Unkey({
  rootKey: "UNKEY_ROOT_KEY",
});

async function run() {
  const result = await unkey.ratelimit.getOverride({
    identifier: "<value>",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { UnkeyCore } from "@unkey/api/core.js";
import { ratelimitGetOverride } from "@unkey/api/funcs/ratelimitGetOverride.js";

// Use `UnkeyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const unkey = new UnkeyCore({
  rootKey: "UNKEY_ROOT_KEY",
});

async function run() {
  const res = await ratelimitGetOverride(unkey, {
    identifier: "<value>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request components.V2RatelimitGetOverrideRequestBody ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.V2RatelimitGetOverrideResponseBody>

Errors

Error Type Status Code Content Type
errors.BadRequestErrorResponse 400 application/json
errors.UnauthorizedErrorResponse 401 application/json
errors.ForbiddenErrorResponse 403 application/json
errors.NotFoundErrorResponse 404 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*

listOverrides

Example Usage

import { Unkey } from "@unkey/api";

const unkey = new Unkey({
  rootKey: "UNKEY_ROOT_KEY",
});

async function run() {
  const result = await unkey.ratelimit.listOverrides({});

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { UnkeyCore } from "@unkey/api/core.js";
import { ratelimitListOverrides } from "@unkey/api/funcs/ratelimitListOverrides.js";

// Use `UnkeyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const unkey = new UnkeyCore({
  rootKey: "UNKEY_ROOT_KEY",
});

async function run() {
  const res = await ratelimitListOverrides(unkey, {});

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request components.V2RatelimitListOverridesRequestBody ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.V2RatelimitListOverridesResponseBody>

Errors

Error Type Status Code Content Type
errors.BadRequestErrorResponse 400 application/json
errors.UnauthorizedErrorResponse 401 application/json
errors.ForbiddenErrorResponse 403 application/json
errors.NotFoundErrorResponse 404 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*

deleteOverride

Example Usage

import { Unkey } from "@unkey/api";

const unkey = new Unkey({
  rootKey: "UNKEY_ROOT_KEY",
});

async function run() {
  const result = await unkey.ratelimit.deleteOverride({
    identifier: "<value>",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { UnkeyCore } from "@unkey/api/core.js";
import { ratelimitDeleteOverride } from "@unkey/api/funcs/ratelimitDeleteOverride.js";

// Use `UnkeyCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const unkey = new UnkeyCore({
  rootKey: "UNKEY_ROOT_KEY",
});

async function run() {
  const res = await ratelimitDeleteOverride(unkey, {
    identifier: "<value>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request components.V2RatelimitDeleteOverrideRequestBody ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.V2RatelimitDeleteOverrideResponseBody>

Errors

Error Type Status Code Content Type
errors.BadRequestErrorResponse 400 application/json
errors.UnauthorizedErrorResponse 401 application/json
errors.ForbiddenErrorResponse 403 application/json
errors.NotFoundErrorResponse 404 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*