Rate_limit_exceeded

I got RATE_LIMIT_EXCEEDED exceptions when I had ask quotes, for this three calls.

“”"
2019-12-15 15:20:05,142 : https://api.smarkets.com/v3/markets/9325843/quotes/
2019-12-15 15:20:05,010 : …marrkets/9325843/quotes/
2019-12-15 13:55:07,013 : https://api.smarkets.com/v3/markets/9325830/quotes/
“”"

I know that there is a limit of 50/min, but I never reach that number in 1 minute.
Can you please, check this out for me?
All the best
miguel

Hi Miguel,

Are you sending the authentication header with your session token in the request? The rate limit for unauthenticated requests is lower.

The code in Python should look as follows:

import requests 

headers = {"Content-Type": "application/json"} 
data = {"username": "<username>", "password": "<password>"}                                       
response = requests.post("https://api.smarkets.com/v3/sessions/", headers=headers, json=data)                                     
session_token = response.json()["token"]
headers = {"Authorization": f"Session-Token {session_token}"}
response = requests.get("https://api.smarkets.com/v3/markets/9325843/quotes/", headers=headers)

Isabel

Hi Isabel,
You are right, I’m going to fix my code and tomorrow is going for production.

But today I had several Rate_limit_exceeded in cancel orders:

“”"
2019-12-19 13:39:25,188 -> delete/orders/202736167938293763/ -> raise RATE_LIMIT_EXCEEDED
2019-12-19 13:39:31,228 -> delete/orders/202736167938293763/ -> raise RATE_LIMIT_EXCEEDED
2019-12-19 13:39:40,207 -> delete/orders/202736167938293763/ -> raise RATE_LIMIT_EXCEEDED
2019-12-19 13:39:43,217 -> delete/orders/202736167938293763/ -> raise RATE_LIMIT_EXCEEDED
2019-12-19 13:39:46,185 -> delete/orders/202736167938293763/ -> raise RATE_LIMIT_EXCEEDED
2019-12-19 13:39:49,285 -> delete/orders/202736167938293763/ -> raise RATE_LIMIT_EXCEEDED
2019-12-19 13:39:52,162 -> delete/orders/202736167938293763/ -> raise RATE_LIMIT_EXCEEDED
2019-12-19 13:39:55,321 -> delete/orders/202736167938293763/ -> raise RATE_LIMIT_EXCEEDED
2019-12-19 13:39:58,160 -> delete/orders/202736167938293763/ -> raise RATE_LIMIT_EXCEEDED
2019-12-19 13:40:01,187 -> delete/orders/202736167938293763/ -> raise RATE_LIMIT_EXCEEDED
2019-12-19 13:40:07,173 -> delete/orders/202736167938293763/ -> Successful
“”"
In cancel orders can’t be session token…
Thank you a lot for all your help.
All the best
miguel

Hi Miguel,

Sorry for the late reply. You were actually reaching the 10 request/s limit in the DELETE v3/orders route.

Isabel

Is there anyway of checking what is causing the rate limit?
At present I am only getting data, but I seem to get 20 requests before I hit the rate limit.
I believe I have my headers etc correct

headers = {“Content-Type”: “application/json”}
data = {“username”: “xxx”, “password”: “xxx”}
response = requests.post(“https://api.smarkets.com/v3/sessions/”, headers=headers, json=data)
if response.status_code != 201:
print(response)
else:
session_token = response.json()[“token”]
headers = {“Authorization”: “Session-Token {session_token}”}
.
.
response=requests.get(“https://api.smarkets.com/v3/markets/"+list2[x]+"/quotes/”,headers=headers)

Hi Michael,

Please, correct me if I’m wrong, but I suspect you are not an API user. The rate limit that applies to non-API users in this particular route is 20 requests per second. If you want to apply for API access you can find more information here.

I hope this helps.
Isabel

Right ok.
I have been told I will be accepted, but as my app is not ready yet I thought it was advisable to wait. Testing is very slow going though.

Didnt realise the rate was 20 for non api users…thought the 50 was no users and api users got a higher rate

Thanks for your help