通过类别创建更改/移除 API 速率限制

我在通过 API 创建类别时遇到了问题。似乎存在一个限制,但该限制似乎无法自定义,且 nowhere 似乎也没有设置可以禁用它。

我收到的错误是:我们对执行该操作的次数设有每日限制。请等待 17 秒后再试。

秒数似乎总是在 20 秒以下,但从不准确,因为它声称是每日限制,而我在上次尝试后一分钟内就进行了重试。我还尝试将管理仪表板下的所有速率限制调整为 1000+,但它们似乎都没有影响类别创建。

仪表板上可用的速率限制仅有:最大主题数、私信、点赞、书签、标记、编辑、邀请、主题邀请、主题、打印和登录。

我使用的是 https://github.com/discourse/discourse_api,在未遇到未指明的速率限制之前一直工作正常。

我是否遗漏了什么?这也不是来自 nginx,因为该消息来自 Discourse,且 nginx 的速率限制模板已被禁用。

See:

Thanks @sam, not sure how I missed that!

No worries, I have meant to make that post for a while @mpalmer asked for it a few weeks ago ;p

@community FYI ^^^

Ahh, it’s new, didn’t notice that either. Not on top of it today I guess…

I’m only performing one request though to create a category and don’t see any daily limits there. Is there another limit that would be attributing to the 429 error?

Well first thing I would try is another API endpoint to see if this is the global rate limit or some specific rate limit on category creation (or maybe a user rate limit in the app), be sure your api_username is an admin

Using ‘system’ and the key was generated via the admin dashboard. It don’t have an issue grabbing the category list, only creating a category.

Not seeing anything particular in the app, I would try a different admin user to see what happens, maybe the error you are getting is a different limit.

Tried another user and a generic key for all users, but both hit the same 429 error and limit when trying to create a category.

Is there anything in the response body you are receiving?

Just the error message:

 {"errors"=>["We have a daily limit on how many times that action can be taken. Please wait 21 seconds before trying again."], "error_type"=>"rate_limit"} (DiscourseApi::TooManyRequests)

Are you 100% sure nothing is stuck in some sort of a loop hitting the server?

Also are you running latest version of Discourse?

Does it come back with 21 seconds every time?

Running 2.0.0.beta1. Not aware of anything looping, only I have access to these keys and the script that runs them is ran manually by me as I’m developing something to automate creating categories. I have 1 call to get the existing category lists, then one call per category creation (only 1 category right now). It has worked to create most of the categories before the rate limit got hit.

The ‘seconds’ varies; often 12, 17, 21, or other amount around that amount.

What happens if you disable the global admin api rate limit (raise it to say 500 a minute and 500 per ten seconds)? Does this go away?

I would guess that something about your script is pummeling too many requests at the server.

Yup… you appear to have been right! A variable wasn’t being set when it needed to be, so it was bypassing a check I had. Seems to be working fine now, no hammering the API anymore. Still good to know the info you posted though, so I appreciate that.

Hey @sam, could you point me to where I can disable the global admin api limit? I have a script to pull response times that requires getting all the topics in a timeframe and then for each topic, getting all of the posts for the topic, and I keep running into the rate limiting (You’ve performed this action too many times. Please wait 6 seconds before trying again.').

Apologies if this old thread i dug up is now really out of date :smiley:

Are you 100% sure it is not covered in: