Skip to content

Instantly share code, notes, and snippets.

@TaylorJadin
Last active August 30, 2022 18:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save TaylorJadin/2c29cd4c78458102bcccbf990729821b to your computer and use it in GitHub Desktop.
Submit multiple URLS to gtmetrix using their API
#!/bin/bash
# Config
GTMETRIX_API_KEY=
SLEEP_TIME=5
# Functions
function submit_test {
curl -s -u $GTMETRIX_API_KEY: \
-X POST -H Content-Type:application/vnd.api+json \
"https://gtmetrix.com/api/2.0/tests" \
-d '{"data":{"type":"test","attributes":{"url":"'$URL'"}}}'
}
# Loop through URLs and submit tests
for URL in "$@"; do
test=`submit_test`
while [[ $test == *'status":"429"'* ]]; do
sleep $SLEEP_TIME
test=`submit_test`
done
echo "Submitted test for: $URL"
done
echo "Tests submitted, check results by logging in at https://gtmetrix.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment