Created
November 23, 2023 18:44
-
-
Save olithissen/11d20dd61826694a7543f256c8aa0049 to your computer and use it in GitHub Desktop.
A bash script to retrieve all account statuses using the Mastodon API
This file contains 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 | |
instance="your.instance.org" | |
access_token="your_access-token" | |
account_id="your-account-id" | |
api_endpoint="https://${instance}/api/v1/accounts/${account_id}/statuses" | |
min_id="1" | |
while true; do | |
response=$(curl -s -X GET -H "Authorization: Bearer ${access_token}" "${api_endpoint}?min_id=${min_id}&limit=40") | |
if [[ "$response" == "[]" ]]; then | |
break; | |
fi | |
statuses=$(jq -r '.[] | {id: .id, content: .content, replies_count: .replies_count, reblogs_count: .reblogs_count, favourites_count: .favourites_count, created_at: .created_at}' <<< "$response") | |
echo "$statuses" | |
min_id=$(jq -r '[.[] | .id] | max' <<< "$response") | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment