# Ratelimit Confusion

**URL:** <https://ask.openrouteservice.org/t/ratelimit-confusion/55>\
**Category:** Tokens, ratelimits, quotas & registration\
**Created:** [October 31, 2018, 3:12am UTC](https://ask.openrouteservice.org/t/ratelimit-confusion/55 "2018-10-31T03:12:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sammyhoworth](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/s/c6cbf5/32.png) [@sammyhoworth](https://ask.openrouteservice.org/u/sammyhoworth)\
**Post date:** [October 31, 2018, 3:12am UTC](https://ask.openrouteservice.org/t/ratelimit-confusion/55/1 "2018-10-31T03:12:50Z")

</div>

The ‘Plans’ pages of the website specifies that up to 40 requests are allowed per minute. However, upon submitting 40 requests, then waiting 2 minutes, i receive errors that I believe are due to rate limit violations.

I have also tried running 30 requests, then waiting 2 minutes, and the errors begin to pile up once the 40th request is submitted.

Any information is greatly appreciated.

Thank you and all the best.

---

<div class="post-metadata">

**Author:** ![timothy](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/timothy/32/11_2.png) [@timothy](https://ask.openrouteservice.org/u/timothy)\
**Post date:** [October 31, 2018, 10:04am UTC](https://ask.openrouteservice.org/t/ratelimit-confusion/55/2 "2018-10-31T10:04:39Z")

</div>

Hi @sammyhoworth,

I just double checked with the following python script, it seems to be working as expected

```
import requests
import time
import numpy as np
import math

NUMBER_OF_TESTS = 10  
API_KEY = 'XYZ'
URL = "https://api.openrouteservice.org/directions?api_key=' + API_KEY + '&coordinates=8.34234%2C48.23424%7C8.34423%2C48.26424&profile=driving-car"

rate_limit_lst = []
response_error_lst = []

counter = 0
while(True):
    res = requests.get(URL)
    response = res.status_code
    if(response == 200):
        #print(response)
        counter += 1
        #time.sleep(1.3)
    else:
        rate_limit_lst.append(counter)
        response_error_lst.append(response)
        print("Error response: ", response)
        print("Total number of requests until error: ", counter)
        counter = 0
        if (len(rate_limit_lst) >= NUMBER_OF_TESTS):
            break
        else:
            print("Wait for next measurement...")
        time.sleep(60)

file = open("rate_limit_testing_report", "w")
rate_limit_array = np.array(rate_limit_lst)
mean = np.mean(rate_limit_array)
std = np.std(rate_limit_array)
mean_error = std / math.sqrt(len(rate_limit_array))
file.write("mean: " + str(mean) + "\n")
file.write("mean error: " + str(mean_error) + "\n")
file.write("Order of columns: Number of requests until error, error response" + "\n")
for i in range(len(rate_limit_lst)):
    file.write(str(rate_limit_lst[i]) + " "*4 + str(response_error_lst[i]) + "\n")
file.close()

```

Could you please test it?

---

<div class="post-metadata">

**Author:** ![sammyhoworth](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/s/c6cbf5/32.png) [@sammyhoworth](https://ask.openrouteservice.org/u/sammyhoworth)\
**Post date:** [November 1, 2018, 3:02am UTC](https://ask.openrouteservice.org/t/ratelimit-confusion/55/3 "2018-11-01T03:02:40Z")

</div>

All resolved! Thank you for the example code.
