我正在使用their APIs及其python library为Imgur更新/重建一个简单的应用程序。
我正在尽最大努力实施一些速率限制,以确保我保持their rate limits。为此,我偶尔会检查应用程序在任何给定时间的剩余配额,并在配额低于某个限制时减少选项/操作。为了监控我的配额,我有一个简单的命令来打印剩余的配额:
def printQuota():
client = authAsUser()#check you\'re authorized as a user.
timeTillUserReset = client.credits['UserReset']#Grabs the time the user quota will reset in Unix Epoch
timeString = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(float(timeTillUserReset)))#Formats the Unix Epoch to something readable
print ('User Limit: ' + str(client.credits['UserLimit']))#Print the Total credits that can be allocated.
print ('User Remaining: ' + str(client.credits['UserRemaining']))#Print Total credits available.
print ('User Reset: ' + str(timeString)) #Timestamp for when the credits will be reset.
print ('User Client Limit: ' + str(client.credits['ClientLimit'])) #Total credits that can be allocated for the application in a day.
print ('User Client Remaining: ' + str(client.credits['ClientRemaining'])) #Total credits remaining for the application in a day.
尽管我使用该应用程序进行多次调用,但我的配额似乎永远不会下降。非常偶尔,用户配额会下降几个点,但往往会在30秒内重新恢复。
为什么我的剩余配额永远不会改变?我希望它在多次调用过程中稳步下降,但它几乎总是返回以下值:
即使我在直接进行API调用后调用它。