Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gutocarvalho/7004f425073981639e4a4da12380720e to your computer and use it in GitHub Desktop.
Save gutocarvalho/7004f425073981639e4a4da12380720e to your computer and use it in GitHub Desktop.
get mastodon stats using shell curl and jq
#!/bin/bash -
INSTANCE_ENDPOINT_V1="bolha.us/api/v1/instance"
INSTANCE_ENDPOINT_V2="bolha.us/api/v2/instance"
INSTANCE_URL="bolha.us"
COUNT_TOTAL_USERS=$(curl -s $INSTANCE_ENDPOINT_V1 | jq '.stats.user_count')
COUNT_ACTIVE_USERS=$(curl -s $INSTANCE_ENDPOINT_V2 | jq '.usage.users.active_month')
COUNT_POOL_LIMIT=$(curl -s $INSTANCE_ENDPOINT_V2 | jq '.configuration.polls.max_options')
COUNT_CHAR_LIMIT=$(curl -s $INSTANCE_ENDPOINT_V2 | jq '.configuration.statuses.max_characters')
INSTANCE_VERSION=$(curl -s $INSTANCE_ENDPOINT_V2 | jq '.version')
echo "Number of total registred users: $COUNT_TOTAL_USERS"
echo "Number of active users (this month): $COUNT_ACTIVE_USERS"
echo "Number of pool options: $COUNT_POOL_LIMIT"
echo "Number of char limit: $COUNT_CHAR_LIMIT"
echo "Mastodon instance version: $INSTANCE_VERSION"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment