2

I have an AWS serverless API configured with a usage plan. I want users to be able to know how many more requests they can make, so they are don't get stuck with:

HTTP/2 429
content-type: application/json
content-length: 28
date: Mon, 16 Apr 2018 03:41:12 GMT
x-amzn-requestid: 02436b06-4128-11e8-aa37-8f617035a300
x-amzn-errortype: LimitExceededException
x-cache: Error from cloudfront
via: 1.1 de2aa82ec56d0a6d749df4bf0a88b28f.cloudfront.net (CloudFront)
x-amz-cf-id: afyULHDbLwJYAJO07zLeFG1Q0tZA-VhB3kezRgE1UBldQdfaGRQaZQ==
{"message":"Limit Exceeded"}

I've been looking over AWS documentation https://docs.aws.amazon.com/cli/latest/reference/apigateway/index.html#cli-aws-apigateway & https://docs.aws.amazon.com/sdk-for-go/api/service/apigateway/

And I can't seem to figure out how to tell how many requests an API key is allowed to make! My goal is to see present user's something like Twitter's:

x-rate-limit-limit: 1500
x-rate-limit-remaining: 1499
x-rate-limit-reset: 1523850782

What am I missing ?

1 Answer 1

1

You can get the usage data of a usage plan in a specified time interval for an "optional" specific API key via usage:get:

GET /usageplans/<usageplanId>/usage{?keyId,startDate,endDate,limit}

The returned usage data represents daily logs of used and remaining quotas, over the specified time interval indexed over the API keys in the usage plan.

(Similar implementations are available in AWS SDKs)

Source: Amazon API Gateway REST API Reference.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.