0CodeKit icon

0CodeKit

A toolbox of no-code utilities

Actions132

Operator → Traffic Light Rate Limiting

AI-generated

Overview

The "Traffic Light Rate Limiting" operation under the "Operator" resource provides a mechanism to enforce rate limits on actions or API calls identified by a unique identifier. This node helps control the number of requests or operations performed within a specified time window, preventing overuse or abuse of resources.

Typical use cases include:

  • Throttling API requests per user or client to avoid hitting service limits.
  • Controlling access frequency to certain features in an application.
  • Implementing custom rate limiting logic in workflows to ensure fair usage.

For example, you can limit an API user identified as "api-user-123" to 50 requests every 60 seconds, ensuring that the system does not get overwhelmed by too many requests from the same user.

Properties

Name Meaning
Rate Limit Identifier Unique string to identify the entity (e.g., user or client) for which rate limiting applies. Example: "api-user-123".
Request Limit Maximum number of allowed requests or operations within the defined time window. Default is 50.
Time Window (Seconds) Duration in seconds during which the request limit applies. Default is 60 seconds.

Output

The node outputs JSON data representing the result of the rate limit check. Typically, this will include information such as whether the current request is allowed or blocked based on the rate limit, and possibly metadata like remaining quota or reset time.

If the node supports binary output, it would relate to any additional data returned by the rate limiting service, but based on the provided code and properties, the primary output is JSON indicating rate limit status.

Dependencies

  • Requires an API key credential to authenticate requests against the external "0CodeKit" service at https://prod.0codekit.com.
  • The node sends a POST request to the /operator/trafficlight endpoint with the parameters identifier, limit, and timeWindow.
  • Proper configuration of the API key credential in n8n is necessary for successful execution.

Troubleshooting

  • Common issues:

    • Invalid or missing API key credential will cause authentication failures.
    • Providing an empty or invalid Rate Limit Identifier may lead to errors or unexpected behavior.
    • Setting a Request Limit less than 1 is invalid and should be avoided.
    • Network connectivity issues to the external API endpoint can cause request failures.
  • Error messages:

    • Authentication errors typically indicate problems with the API key; verify the credential setup.
    • Validation errors may occur if required parameters are missing or out of range; ensure all inputs meet the expected criteria.
    • Rate limit exceeded responses mean the allowed number of requests has been surpassed; wait for the time window to reset or increase the limit if appropriate.

Links and References

Discussion