In a discussion about API rate limits on Discourse, lstuartfry asks whether these limits are configurable via the Admin panel and how to monitor API activity. blake clarifies that rate limits are set in the app.yml file for self-hosted instances, but for Discourse-hosted sites, users must contact support. For enterprise customers, limits can be adjusted and API usage optimized. blake advises handling 429 errors and using the Retry-After header to manage throttling. When asked for the default rate limits, blake directs to the Discourse defaults config for pro/business plans. lstuartfry also inquires about future support for serializer customizations at the theme/component level to reduce per-topic API calls. blake notes no timeline for that feature but recommends using the Data Explorer plugin to create custom SQL queries and retrieve data via a single API call, reducing overall load.
Hey all,
I’ve come across several (somewhat-old) articles on this forum that outline API rate limits (ex: Available settings for global rate limits and throttling). I’m interested in this because, during the customization of our site, we’re making several API calls related to users and topics, and I’d like to ensure we keep the calls to a minimum.
Are these settings still configurable via the Admin panel? I haven’t come across anything thus far that relates to the Discourse API rate limits.
If not, is there a way to monitor the request activity somewhere?
These API rate limit settings are not configured via the admin panel, but you will add them to the app.yml file on the server where your discourse site is hosted. So you will have to ssh into your server to make the change if you are self hosted.
@blake thank you for the response! My team is actually going to lean on Discourse for hosting, so we don’t have any of our own config files. Are there any avenues for viewing or tweaking the API limits if this is the route we go down?
If you are on enterprise we can tweak some of these limits for you as well as provide some api guidance so that we can reduce your api usage load.
What we recommend is to have your app that is making the API calls handle 429 errors and then check the Retry-After header that is received and this will let you know when you can start making requests again.
@blake thanks again for the info! I think my team is most likely fine with the current standard rate limits as defined by Discourse. Can you share what these limits are? I’ve been unable to track down a definitive list thus far.
@blake once again, thank you for the information! This is somewhat related, but do you know if there is a timeline to add serializer customizations to at the themes/component level? I’ve seen that feature mentioned on this forum here and there over the past year, but I know it hasn’t been implemented yet.
I ask because we’re currently fetching user data on a per-topic basis in the topic list, which can add up once our platform has more and more users. Adding certain pieces of data of the user model to certain serializers could help cut down the API calls we’re currently having to make.
There is not a timeline for that that I’m aware of.
However, I recommend using the data-explorer plugin for custom data requests like this. What you can do is create your own custom sql query and save it so that it gets an id. Then you can make an API call to that saved query and it will execute then and return the json you are after in a single request.