Skip to content

Commit

Permalink
Merge pull request #80 from gm3dmo/sn2b-patch-1
Browse files Browse the repository at this point in the history
Create search-rate-limit-demo.sh
  • Loading branch information
gm3dmo committed Jan 18, 2023
2 parents cc65b6f + 9323410 commit dfc9e4e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions search-rate-limit-demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
. .gh-api-examples.conf

# https://docs.github.com/en/enterprise-cloud@latest/rest/search?apiVersion=2022-11-28#search-repositories
# https://docs.github.com/en/enterprise-cloud@latest/rest/search?apiVersion=2022-11-28#rate-limit
# https://api.github.com/search/repositories?q=Q

# WORKS ON A MAC
default_start_date="$(date -v -7d +'%Y-%m-%d')"

# Pass query as an argument, otherwise list all repos with commits in the last seven days
if [ -z "$1" ]
then
query="pushed:>$default_start_date"
else
query="$1"
fi

# adjusted from search-repositories.sh to hit the 30 requests per minute rate limit
for n in {1..31}
do
echo "position in loop ${n}"
# verbose curl but no output from the curl, since it is not interesting for rate limit demo purposes
curl -v ${curl_custom_flags} \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/search/repositories?q=${query} > /dev/null
done

0 comments on commit dfc9e4e

Please sign in to comment.