Skip to content

Instantly share code, notes, and snippets.

@SpikePy
Created March 8, 2022 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpikePy/6408b8cea510740e18c20510cfe748c1 to your computer and use it in GitHub Desktop.
Save SpikePy/6408b8cea510740e18c20510cfe748c1 to your computer and use it in GitHub Desktop.
twitter_api_bearer_token=xxx
hashtag=spotify
granularity=hour
curl \
-X GET \
-H "Authorization: Bearer ${twitter_api_bearer_token}" \
"https://api.twitter.com/2/tweets/counts/recent?query=%23${hashtag}&granularity=${granularity}&search_count.fields" \
| jq -r '.data[] \
| {"start","end","tweet_count"} \
| join(" ")' \
| sed -e 's/.000Z/Z/g'
# create csv to plat a table via excel/calc
curl \
-X GET \
-H "Authorization: Bearer ${twitter_api_bearer_token}" \
"https://api.twitter.com/2/tweets/counts/recent?query=%23${hashtag}&granularity=${granularity}&search_count.fields" \
| jq -r '.data[] \
| {"start","end","tweet_count"} \
| join(",")' | sed -e 's/.000Z/Z/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment