Question

API Rate Limit Errors (429)

  • 29 January 2024
  • 3 replies
  • 98 views

Badge

I have a script that uses the v2 tickets endpoint to return tickets updated since a specific point in time.  The script loops through each ticket returned and, for each, calls the time_entries endpoint to retrieve its time entries.

Examining the return headers on the very first API call to get the list of tickets reveals a rate limit of 120 and remaining count of 119. However, the first time the script calls for time entries (on the very first ticket) the API returns a 429 error. Presumably, this would be the second call from a rate limit perspective.

We have no other apps using the API key. We are on a Pro plan.

Any help would be greatly appreciated.

 


3 replies

Badge

The problem was in my script. It is working properly again.

Hi @DougAtBHB

 

Not sure what language you are using for the script, but we are a Freshworks partner and created a free, open source Powershell module\library for Freshservice:

 

https://www.flycastpartners.com/freshserviceps

 

There is built-in logic for 429 to wait and also an artificial throttle to ensure the scripts do not consume all API calls that would impact workflows or other integrations using the API.  This is a bit of Verbose output to show the page and where the script is using the minute rate limit:

 

VERBOSE: Invoke-FreshworksRestMethod - Invoking REST GET Method on https://its-fine.freshservice.com/api/v2/agents?page=1&per_page=100...
VERBOSE: Invoke-FreshworksRestMethod - Forcing TLS 1.2 protocol for invoking REST method.
VERBOSE: Requested HTTP/1.1 GET with 0-byte payload
VERBOSE: Received HTTP/1.1 response of content type application/json of unknown size
VERBOSE: Returned status OK with code 200.
VERBOSE: Current FreshService minute rate limit is 140 with 139 calls remaining (0.71% used) .
VERBOSE: Invoke-FreshworksRestMethod - Completed REST GET Method on https://its-fine.freshservice.com/api/v2/agents?page=1&per_page=100 in 00:00:01.5134094.
VERBOSE: Returning agents property with count 12

 

The code is open source if you want or simply use the module, the logic is already built in for any API call so it’s just a simple command to get tickets with automatic paging:

 

$tickets = Get-FSTicket

 

Badge

Hi @DougAtBHB

 

Not sure what language you are using for the script, but we are a Freshworks partner and created a free, open source Powershell module\library for Freshservice:

 

https://www.flycastpartners.com/freshserviceps

 

There is built-in logic for 429 to wait and also an artificial throttle to ensure the scripts do not consume all API calls that would impact workflows or other integrations using the API.  This is a bit of Verbose output to show the page and where the script is using the minute rate limit:

 

VERBOSE: Invoke-FreshworksRestMethod - Invoking REST GET Method on https://its-fine.freshservice.com/api/v2/agents?page=1&per_page=100...
VERBOSE: Invoke-FreshworksRestMethod - Forcing TLS 1.2 protocol for invoking REST method.
VERBOSE: Requested HTTP/1.1 GET with 0-byte payload
VERBOSE: Received HTTP/1.1 response of content type application/json of unknown size
VERBOSE: Returned status OK with code 200.
VERBOSE: Current FreshService minute rate limit is 140 with 139 calls remaining (0.71% used) .
VERBOSE: Invoke-FreshworksRestMethod - Completed REST GET Method on https://its-fine.freshservice.com/api/v2/agents?page=1&per_page=100 in 00:00:01.5134094.
VERBOSE: Returning agents property with count 12

 

The code is open source if you want or simply use the module, the logic is already built in for any API call so it’s just a simple command to get tickets with automatic paging:

 

$tickets = Get-FSTicket

 

Coincidentally, I am using PowerShell too. I thought I was the only one ;)

 

Thanks for sharing. I’ll take a look.

Reply