[Curl] Calling an http api every X seconds using curl
Command
while true; do curl -X GET \
-H "Content-Type: application/json" \
-H "authorizationHader: $TOKEN" \
$ENDPOINT_URL | python -m json.tool && sleep 60; done
Explication
Variables:
ENDPOINT_URLhttps://api.ecma.com/v1/endpointTOKENs0meAuthenticationTokenJustHereToSetAnExampleHeader
infinite loop
while true;
do
# do stuff.
done
Curl
-X <command>,--request <command>http verb. GET, POST, PUT, PATCH, DELETE, …-H <header>,--header <header>: set custom header
python
-m module-nameSearches sys.path for the named module and runs the corresponding .py file as a scriptjson.toolvalidate and pretty print python
delay
sleep _seconds_suspend execution for seconds
Documentation
- https://docs.python.org/2/library/json.html
- OSX python 2.7.12 man page
- OSX curl 7.43.0 man page
- OSX builtin man page