APIs & Integrations

wnell
Participant

Secondly limit being hit even with rate limiting code

I have implemented some rate limiting code to ensure I do not exceed 10 requests per second (with a safety margin of 1). I tested this and it does work indeed. During any 1 second time window the code will not send more than 9 requests. Please explain to me why I still intermittently get this (not often, say once a week or so):

{"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"8348b8f0-5af3-487e-820c-0272d5dbce66","policyName":"SECONDLY","requestId":"74993fac-61c1-4574-8dee-286274bd465f"}

I have the code to show / send to someone if interested.

0 Upvotes
9 Replies 9
Lele_Mk
Participant

Secondly limit being hit even with rate limiting code

Hi @wnell  I'm experiencing this issue with calls to the CRM Search API. Can you share your rate limit code please. 

0 Upvotes
Blake_West
Member

Secondly limit being hit even with rate limiting code

@dadams Hi, I’m having an identical issue. I had written customer support about this, and they directed me here. I’m reposting below for full context, and it includes an example error.

------------------------------------------- ORIGINAL MESSAGE --------------------------------

Hi, my name is Blake. I’m a developer at Hint Health. We use the Hubspot API internally to keep data in sync between Hubspot and our own database. So we have nightly jobs to make a bunch of updates to Hubspot. We are consistently seeing rate limit errors, despite putting in place code on our side to ensure it does not go over the rate limit.

Specifically, we’re getting the “SECONDLY” error. So of course, we checked the documentation and confirmed there’s a 10 request / second limit.

Our code currently is doing a rate limit of 1 request every 2 seconds. So 20x slower than the posted rate limit. (Also, I have confirmed personally that this rate limiting indeed appears to be happening on our production servers).

While there are potential other technical reasons why our rate might bump up to, say… 2 or 3 requests per second, we should definitely be well below 10 requests per second, and yet we’re still seeing these errors show up a small percentage of the time each night.

I’m looking for clarification on:

1.) How exactly is the rate limit implemented? Is it for the entire length of the connection, just connections started within a time frame? or what?

2.) Is it indeed 10 requests per second for our account? Or do we need to get permission to bump up to 10 per second.

If it’s helpful, here’s an example error message that we’re receiving:

{“status”:“error”,“message”:“You have reached your secondly limit.”,“errorType”:“RATE_LIMIT”,“correlationId”:“c2d6760c-3af5-452c-9c3c-b40f6b12cb51”,“policyName”:“SECONDLY”,“groupName”:“publicapi:oauth-secondly:39016:2562809”,“requestId”:“2b5a0ab1e08959c908ad825d583411b7”}

Also, FYI, we’re using OAuth for these requests.

Thanks! - Blake

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Secondly limit being hit even with rate limiting code

Hi @Blake_West

The rate limit is measured for individual HTTP requests, not necessarily connections, and the limit is measured for individual seconds (you get 10 HTTP requests between 3:01:31 and 3:01:32). The limit is set per token (which is basically per portal), so overall you can exceed 10 requests per second total, just not for any specific portal.

The 10 requests per second limit is set for all apps and individual accounts, so an app wouldn’t need special settings to get up to that 10 requests.

You can see the requests made for your app by looking in the settings for the app, then Monitoring > API call logging in the left sidebar. You’ll need to click on the individual requests to see the seconds part of the time (the table only shows the minute), but you should be able to see cases where the app did exceed 1 request per second, and does exceed 10 requests per second in a few cases. If there are other details you’re looking for, message me directly with what you’re looking for and I can take a deeper look at this.

0 Upvotes
Not applicable

Secondly limit being hit even with rate limiting code

You said …
‘The 10 requests per second limit is set for all apps and individual accounts, so an app wouldn’t need special settings to get up to that 10 requests.’

We are an integration provider with a Hubspot app that is used by hundreds of our customers. We have the app rate limited to 5 records per second, but we are seeing secondly errors for a lot of our customers.

Are we hitting the secondly error because our application is used by many many customers to retrieve data from their individual accounts?

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Secondly limit being hit even with rate limiting code

The limit is per portal, so your integration will be able to hit 10 requests per second for each customer using your integration. We don’t currently have a maximum rate limit for an integration across all portals, so as long as you’re staying below 10 requests per second for each customer you should not be hitting the secondly rate limit.

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Secondly limit being hit even with rate limiting code

@wnell is this something you ran into recently? If you can send me your Hub ID I can take a look at those errors to see if I can give you more details.

0 Upvotes
wnell
Participant

Secondly limit being hit even with rate limiting code

I’d say for the past month or so. How do I share my Hub ID securely with you?

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Secondly limit being hit even with rate limiting code

I message you directly.

0 Upvotes
wnell
Participant

Secondly limit being hit even with rate limiting code

I have sent the details to you.

0 Upvotes