Created
September 28, 2022 15:26
-
-
Save jumanjiman/54cf89d72386df95cf5114d4d156f39b to your computer and use it in GitHub Desktop.
GH ratelimit in both REST and GraphQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eEu | |
set -o pipefail | |
# Use env var to hide corporate namespace. | |
GITHUB_BASE_URL="${GITHUB_BASE_URL:-https://ghe.example.com}" | |
echo 'Get ratelimit with REST API v3' | |
curl \ | |
-H 'Accept: application/vnd.github+json' \ | |
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | |
--write-out 'HTTP response code %{http_code}' \ | |
"${GITHUB_BASE_URL}/api/v3/rate_limit" | |
echo | |
echo | |
echo 'Get ratelimit with GraphQL API' | |
curl \ | |
-H 'Content-Type: application/json' \ | |
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | |
-X POST \ | |
-d '{"query": "query GetRateLimit {rateLimit { used remaining resetAt } }"' \ | |
--write-out 'HTTP response code %{http_code}' \ | |
"${GITHUB_BASE_URL}/api/graphql" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment