For example all sapi/* endpoints use both X-SAPI-USED-IP-WEIGHT-1M and X-SAPI-USED-UID-WEIGHT-1M headers.
So I’m able to track my weight before any request in order to stay bellow the defined limits if I consider that my weights are all at 0 when instantiating my connector class.
However since I may have several scripts running in parallel, Weight could be consumed by a first script without the second script knowing it. So considering weights are all at 0 is a bad idea in my case.
Is there a way to know what are the current weights on a specific endpoint without making a request which will consume a lot of weight ?
For example, the endpoint /sapi/v1/system/status only returns headers with X-SAPI-USED-IP-WEIGHT-1M but not with X-SAPI-USED-UID-WEIGHT-1M so I have to request an endpoint consuming weight on UID to know how much I have left.
You should track locally the values of X-SAPI-USED-IP-WEIGHT and X-SAPI-USED-UID-WEIGHT from last requests to avoid risking exceeding it with new requests.
There’s a section dedicated to those limits on the API documentation which might help you get the full context better: https://binance-docs.github.io/apidocs/spot/en/#limits
I already read this documentation part, which I used to handle requests weights in my connector.
I do track weight values into my connector but I’m having two issues :
1 - When launching a script, I don’t know what is the current weight at the beginning, so I set them to 0 which could be risky since it could be higher if I’m still within the timeouts for example.
2 - I don’t know when the weight is reset without making a request again, so I need to handle timeouts directly into my connector, it’s not such an issue but it could be nice to know when they are reset.
That’s why it would be easier if I could request my current weights directly from the API, at least at the beginning, in order to avoid a 429 response on my first request if I’m already above the limits.
I don’t know if such an endpoint exists, I didn’t find anything about it. But maybe it could be achieved with a workaround.
X-SAPI-USED-IP-WEIGHT-1M can’t pass 12000 per minute
X-SAPI-USED-UID-WEIGHT-1M can’t pass 180000 per minute
This minute is according to UTC time. If you send at 3:00, those weights will be reset at 3:01.
Therefore, you can log prev request’s weight and timestamp, then by the time you restart your script, you can see the current timestamp and check if the weight has been reset or not.