Software Engineering :: Source Control :: VCS :: Git :: Managed Hosting Platform :: GitHub :: Gist :: API :: Scripting
⪼ Made with 💜 by Polyglot.
- Personal Brand :: Social Media :: Medium :: Article :: A modern Hello World
- Personal Brand :: Social Media :: Medium :: Article :: Best Practices for Safeguarding Secrets in Node.js Applications
- Software Engineering :: Operating Systems :: Linux :: Command :: Shell :: Environment :: Variable :: Twelve-Factor App Config
- Software Engineering :: Programming :: Languages :: JavaScript :: Runtimes :: Node.js :: Environment Variables :: --env-file=.env
Request
export $(grep -v '^#' .env | xargs) && curl -I --request GET \
--url 'https://api.github.com/gists?per_page=100&page=1' \
--header 'Accept: application/vnd.github+json' \
--header "Authorization: Bearer ${GIST_API_KEY}" \
--header 'X-GitHub-Api-Version: 2022-11-28'
Response
HTTP/2 200
date: Tue, 03 Sep 2024 22:43:55 GMT
content-type: application/json; charset=utf-8
content-length: 238838
cache-control: private, max-age=60, s-maxage=60
vary: Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With
etag: "f764aa7f51cd5f4889836b77a71a33623e136bf03895e1d5ac6704e661916ded"
x-oauth-scopes: gist
x-accepted-oauth-scopes:
github-authentication-token-expiration: 2024-10-22 21:29:47 UTC
x-github-media-type: github.v3; format=json
link: <https://api.github.com/gists?per_page=100&page=2>; rel="next", <https://api.github.com/gists?per_page=100&page=116>; rel="last"
x-github-api-version-selected: 2022-11-28
x-ratelimit-limit: 5000
x-ratelimit-remaining: 4945
x-ratelimit-reset: 1725405732
x-ratelimit-used: 55
x-ratelimit-resource: core
access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
access-control-allow-origin: *
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'
x-github-request-id: CFBA:29236E:E0186AD:1ADDDFCE:66D79128
server: github.com
Script
total_pages=$(export $(grep -v '^#' .env | xargs) && curl -Is --request GET \
--url 'https://api.github.com/gists?per_page=100&page=1' \
--header 'Accept: application/vnd.github+json' \
--header "Authorization: Bearer ${GIST_API_KEY}" \
--header 'X-GitHub-Api-Version: 2022-11-28' | grep -i "^Link:" | cut -d '=' -f 6 | cut -d '>' -f 1)
echo "Number of pages: $total_pages"
Output
Number of pages: 116
Script
total_pages=$(export $(grep -v '^#' .env | xargs) && curl -Is --request GET \
--url 'https://api.github.com/gists?per_page=100&page=1' \
--header 'Accept: application/vnd.github+json' \
--header "Authorization: Bearer ${GIST_API_KEY}" \
--header 'X-GitHub-Api-Version: 2022-11-28' | grep -i "^Link:" | cut -d '=' -f 6 | cut -d '>' -f 1)
total_gists=$((total_pages * 100))
echo "Approximate number of gists: $total_gists"
Output
Approximate number of gists: 11600