Last active
January 15, 2020 15:40
-
-
Save neilmillard/ab737f09197d4198ed8220caa7309060 to your computer and use it in GitHub Desktop.
get github api limit status
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
#!/bin/bash | |
# Set $GITHUB_API_USER and $GITHUB_API_TOKEN | |
# | |
set +x | |
GITHUB_API_HEADER_ACCEPT="Accept: application/vnd.github.v3+json" | |
temp=`basename $0` | |
TMPFILE=`mktemp /tmp/${temp}.XXXXXX` || exit 1 | |
curl --user "$GITHUB_API_USER:$GITHUB_API_TOKEN" -s "https://api.github.com/rate_limit" -H "${GITHUB_API_HEADER_ACCEPT}" >> $TMPFILE | |
remaining=`jq ".resources.core.remaining" $TMPFILE` | |
limit=`jq ".resources.core.limit" $TMPFILE` | |
reset=`jq ".resources.core.reset" $TMPFILE` | |
date | |
echo "$remaining / $limit: resets at " | |
date -d "@$reset" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment