Skip to content

Commit

Permalink
GITBOOK-51: Rate limiting added
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-Prescott authored and gitbook-bot committed Apr 12, 2024
1 parent 4a18d88 commit 73a907f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [⚠️ Setting Environment Variable](docs/getting-started/setting-environment-variable.md)
* [⬇️ Downloading Library (BETA)](docs/getting-started/downloading-library-beta.md)
* [⚙️ Create API Object](docs/getting-started/create-api-object.md)
* [🛑 Rate Limiting API Calls](docs/getting-started/rate-limiting-api-calls.md)
* [📦 Methods](docs/methods/README.md)
* [📥 Get](docs/methods/get.md)
* [🔢 DNs](docs/methods/get/dns/README.md)
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/create-api-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ The API object is the core object of the library, all functionality is accessed
```python
from odins_spear import api

magic = api.Api(base_url="https://base_url/api/vx", username="john.smith", password="ODIN_INSTANCE_1")
my_api = api.Api(base_url="https://base_url/api/vx", username="john.smith", password="ODIN_INSTANCE_1")
```
{% endcode %}

Once you have built the object the next step is to authenticate it, this authorizes the object to interact with the Odin API it is the equivalent of you logging in through the web portal. To authenticate this call the .authenticate() method on the object. 

<pre class="language-python" data-overflow="wrap" data-line-numbers><code class="lang-python"><strong>from odins_spear import api
</strong><strong>
</strong><strong>magic = api.Api(base_url="https://base_url/api/vx", username="john.smith", password="ODIN_INSTANCE_1")
</strong><strong>my_api = api.Api(base_url="https://base_url/api/vx", username="john.smith", password="ODIN_INSTANCE_1")
</strong>magic.authenticate()
</code></pre>

Expand Down
22 changes: 22 additions & 0 deletions docs/getting-started/rate-limiting-api-calls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 🛑 Rate Limiting API Calls

The API object has a default parameter of 'rate\_limit' set to True which limits the amounts of API calls the library will make to 5 calls per 1 second. If the limit is reach the system will wait for the limit to pass before executing the next 5 calls.&#x20;

This limiting will ease the pressure on the API and hopefully stop any negative impact on systems such as significant resource drainage leading to outages or poor performance.&#x20;

{% hint style="info" %}
It should be noted that Odin does not imply any limitations on the usage of their API and this feature is just a precaution.&#x20;
{% endhint %}

## Disabling Rate Limiting

The limitation is applied by default however this can be removed by passing in the `rate_limit` argument set to `False` when instantiating an API object.

{% hint style="danger" %}
This will remove the limitation of 5 calls per 1 second allowing the library to send as many API as it can.
{% endhint %}

```python
my_api = Api(base_url="https://magic.14ip.net/api/v2", username="Jordan.Prescott",
password="MAGIC_US", rate_limit=False)
```

0 comments on commit 73a907f

Please sign in to comment.