# View your request count for rate limiting

**URL:** <http://forum.companieshouse.gov.uk/t/view-your-request-count-for-rate-limiting/2880>\
**Category:** Uncategorized\
**Created:** [February 19, 2020, 10:44am UTC](http://forum.companieshouse.gov.uk/t/view-your-request-count-for-rate-limiting/2880 "2020-02-19T10:44:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![annamackenzie2](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/a/aca169/32.png) [@annamackenzie2](http://forum.companieshouse.gov.uk/u/annamackenzie2)\
**Post date:** [February 19, 2020, 10:44am UTC](http://forum.companieshouse.gov.uk/t/view-your-request-count-for-rate-limiting/2880/1 "2020-02-19T10:44:27Z")

</div>

Is there a way to see how many requests the api thinks you have made or when your 5 minute window started? I have written a limiter into my code to prevent it making more than 600 requests in 5 minutes however it looks like my request count is not in line with CH or perhaps the problem is that when I am recording the start of the window is not actually when it began, is there a way to extract this information?

---

<div class="post-metadata">

**Author:** ![voracityemail](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/v/b77776/32.png) [@voracityemail](http://forum.companieshouse.gov.uk/u/voracityemail)\
**Post date:** [February 20, 2020, 12:08am UTC](http://forum.companieshouse.gov.uk/t/view-your-request-count-for-rate-limiting/2880/3 "2020-02-20T00:08:01Z")

</div>

Are you referring to the Streaming API or the main/document REST API?

**Main API**  
Although not listed in the documentation:

[https://developer.companieshouse.gov.uk/api/docs/index/gettingStarted/rateLimiting.html](https://developer.companieshouse.gov.uk/api/docs/index/gettingStarted/rateLimiting.html)

…I thought this was available via the http headers? I thought the `X-Ratelimit-...` fields were what we should use for this purpose - or will things change?

Roughly as in the thread:

[https://forum.aws.chdev.org/t/how-is-rate-limiting-implemented/140](https://forum.aws.chdev.org/t/how-is-rate-limiting-implemented/140)

For what it’s worth I just checked and this still seems functional:

```
curl -uMY_API_KEY: -I "https://api.companieshouse.gov.uk/company/NF004299"

HTTP/1.1 200 OK
Date: Wed, 19 Feb 2020 23:36:41 GMT
Content-Type: application/json
Content-Length: 1302
Connection: keep-alive
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: X-RateLimit-Query, origin, content-type, content-length, user-agent, host, accept, authorization
Access-Control-Expose-Headers: X-RateLimit-Window, X-RateLimit-Limit, X-RateLimit-Remain, X-RateLimit-Reset, Location, www-authenticate, cache-control, pragma, content-type, expires, last-modified
Access-Control-Expose-Headers: Location,www-authenticate,cache-control,pragma,content-type,expires,last-modified
Access-Control-Max-Age: 3600
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Ratelimit-Limit: 600
X-Ratelimit-Remain: 599
X-Ratelimit-Reset: 1582155701
X-Ratelimit-Window: 5m
Server: CompaniesHouse

```

I also checked the documents as if I recall correctly they had separate rate limits some time ago - but I also recall reading something contradicting that more recently.

I believe there are some minor differences between the documents API and main API e.g. per the following thread:

[https://forum.aws.chdev.org/t/rate-limit-header-naming-issue/245](https://forum.aws.chdev.org/t/rate-limit-header-naming-issue/245)

Also see:  
[https://forum.aws.chdev.org/t/not-a-big-issue-format-of-x-ratelimit-window-rate-limit-window-value/1960](https://forum.aws.chdev.org/t/not-a-big-issue-format-of-x-ratelimit-window-rate-limit-window-value/1960)

My test (some info snipped):

```
curl -v -uMY_API_KEY: "https://frontend-doc-api.companieshouse.gov.uk/document/VuqbfmUhDPN8O3uo0FB8EZIQyCi9Fw_9YK3zwdrzWqs"

...

< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json
< Date: Wed, 19 Feb 2020 23:50:35 GMT
< Server: nginx/1.14.1
< X-Ratelimit-Limit: 600
< X-Ratelimit-Remaining: 597
< X-Ratelimit-Reset: 1582156298
< Content-Length: 485
< Connection: keep-alive

```

I believe the Python chwrapper library ([https://github.com/JamesGardiner/chwrapper](https://github.com/JamesGardiner/chwrapper)) uses this also (if anyone uses that).

**Streaming API**  
There doesn’t seem to be any information suggesting that you can check the rate limiting for the _streaming API_ however - if you get a “too many attempts” you just have to back off.

[https://developer-specs.companieshouse.gov.uk/streaming-api/guides/overview](https://developer-specs.companieshouse.gov.uk/streaming-api/guides/overview)

---

<div class="post-metadata">

**Author:** ![voracityemail](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/v/b77776/32.png) [@voracityemail](http://forum.companieshouse.gov.uk/u/voracityemail)\
**Post date:** [February 20, 2020, 4:17pm UTC](http://forum.companieshouse.gov.uk/t/view-your-request-count-for-rate-limiting/2880/4 "2020-02-20T16:17:44Z")

</div>

Found the reference for my comment above:

> [@voracityemail](#):
>
> I also checked the documents as if I recall correctly they had separate rate limits some time ago - but I also recall reading something contradicting that more recently.

Found that post - it was:

> **[New IP Address Rate Limiting Query](https://forum.aws.chdev.org/t/new-ip-address-rate-limiting-query/2518)**
>
> With the introduction of the new IP address rate limiting, I was hoping someone could clarify the following points - Does each IP now get the 600 calls in 300 second limit or have these numbers changed? Is there any impact on how many API keys...

This seemed to say “there is only one limit” (presumably 600 / 5 min per API key - although not per IP address…) but the main and documents API certainly _seem_ to have separate rate limits - or at least the X-Ratelimit http headers report as if they do. Quick test using one API key to access each in turn:

```
curl -uMY_API_KEY: -I "https://api.companieshouse.gov.uk/company/NF004299"
HTTP/1.1 200 OK
Date: Thu, 20 Feb 2020 16:07:55 GMT
...
X-Ratelimit-Limit: 600
X-Ratelimit-Remain: 599
X-Ratelimit-Reset: 1582215175
X-Ratelimit-Window: 5m
Server: CompaniesHouse

curl -v -uMY_API_KEY: "https://frontend-doc-api.companieshouse.gov.uk/document/VuqbfmUhDPN8O3uo0FB8EZIQyCi9Fw_9YK3zwdrzWqs"
...
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json
< Date: Thu, 20 Feb 2020 16:07:56 GMT
< Server: nginx/1.14.1
< X-Ratelimit-Limit: 600
< X-Ratelimit-Remaining: 599
< X-Ratelimit-Reset: 1582215176
...

curl -uMY_API_KEY: -I "https://api.companieshouse.gov.uk/company/NF004299"

HTTP/1.1 200 OK
Date: Thu, 20 Feb 2020 16:07:57 GMT
...
X-Ratelimit-Limit: 600
X-Ratelimit-Remain: 598
X-Ratelimit-Reset: 1582215175
X-Ratelimit-Window: 5m
Server: CompaniesHouse

curl -v -uMY_API_KEY: "https://frontend-doc-api.companieshouse.gov.uk/document/VuqbfmUhDPN8O3uo0FB8EZIQyCi9Fw_9YK3zwdrzWqs"
...
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json
< Date: Thu, 20 Feb 2020 16:07:57 GMT
< Server: nginx/1.14.1
< X-Ratelimit-Limit: 600
< X-Ratelimit-Remaining: 598
< X-Ratelimit-Reset: 1582215176
...

curl -uMY_API_KEY: -I "https://api.companieshouse.gov.uk/company/NF004299"

HTTP/1.1 200 OK
Date: Thu, 20 Feb 2020 16:07:58 GMT
...
X-Ratelimit-Limit: 600
X-Ratelimit-Remain: 597
X-Ratelimit-Reset: 1582215175
X-Ratelimit-Window: 5m
Server: CompaniesHouse

curl -v -uMY_API_KEY: "https://frontend-doc-api.companieshouse.gov.uk/document/VuqbfmUhDPN8O3uo0FB8EZIQyCi9Fw_9YK3zwdrzWqs"

...
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json
< Date: Thu, 20 Feb 2020 16:07:59 GMT
< Server: nginx/1.14.1
< X-Ratelimit-Limit: 600
< X-Ratelimit-Remaining: 597
< X-Ratelimit-Reset: 1582215176
...

```
