Skip to content

Instantly share code, notes, and snippets.

@andypiper
Last active January 25, 2024 16:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andypiper/c91362a089a3e14856b0d98dabe879a9 to your computer and use it in GitHub Desktop.
Save andypiper/c91362a089a3e14856b0d98dabe879a9 to your computer and use it in GitHub Desktop.
Fedi recipes

Fedi recipes

A scratchpad of quick and dirty CLI calls to noodle against various #Fediverse-related APIs.

Tools used

I use a lot of curl or httpie and jq.

Variables

  • INSTANCE is the service URL
  • FEDIUSER is the user to query (probably shortname)
  • TOKEN is the OAuth token needed for some calls
export TOKEN="longtoken"
export INSTANCE="macaw.social" # in my case
export FEDIUSER="andypiper" # this is usually me
macaw.social
bookrastinating.com
pipesmarks.glitch.me
pixelfed.social
diode.zone
me.dm
social.lol
lemmy.world
andypiper.co.uk
gamesatwork.biz
cerritos.glitch.me
takahe.social
http -A bearer -a $TOKEN https://$INSTANCE/api/v1/followed_tags | jq '.[] | .name'

Mastodon

http https://$INSTANCE/api/v1/accounts/lookup?acct=$FEDIUSER | jq .followers_count

Mastodon

http https://$INSTANCE/api/v1/accounts/lookup\?acct\=$FEDIUSER | jq .note | html2text

This one is intended to be service-independent. Takes a plain list of undecorated URLs in a text file.

for i in `cat urllist.txt`; do 
  echo "-- $i --"; 
  URL=`http https://$i/.well-known/nodeinfo | jq '.links[0].href'`;
  http "${URL//\"/}" | jq '{software, usage}' ;
done
-- lemmy.world --
{
  "software": {
    "name": "lemmy",
    "version": "0.18.5"
  },
  "usage": {
    "users": {
      "total": 148527,
      "activeHalfyear": 29905,
      "activeMonth": 10758
    },
    "localPosts": 226976,
    "localComments": 1818411
  }
}
-- pipesmarks.glitch.me --
{
  "software": {
    "name": "postmarks",
    "version": "0.0.1"
  },
  "usage": {
    "users": {
      "total": 1,
      "activeMonth": 1,
      "activeHalfyear": 1
    },
    "localPosts": 107
  }
}
-- macaw.social --
{
  "software": {
    "name": "mastodon",
    "version": "4.2.4"
  },
  "usage": {
    "users": {
      "total": 1062,
      "activeMonth": 283,
      "activeHalfyear": 465
    },
    "localPosts": 62060
  }
}
-- bookrastinating.com --
{
  "software": {
    "name": "bookwyrm",
    "version": "0.7.1"
  },
  "usage": {
    "users": {
      "total": 3703,
      "activeMonth": 525,
      "activeHalfyear": 2101
    },
    "localPosts": 106055
  }
}
-- pixelfed.social --
{
  "software": {
    "name": "pixelfed",
    "version": "0.11.9"
  },
  "usage": {
    "localPosts": 17041454,
    "localComments": 0,
    "users": {
      "total": 106611,
      "activeHalfyear": 28192,
      "activeMonth": 10263
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment