Run the “Basic Lemmy API login script” (see here) first to get value for ‘jwt’
#!/bin/bash
# Basic get unread replies script for Lemmy API
# CHANGE THESE VALUES
my_instance="" # e.g. https://feddit.nl
my_username="" # e.g. freamon
my_password="" # e.g. hunter2
jwt="" # run basic login script to get this
########################################################
# Lemmy API version
API="api/v3"
########################################################
# Turn off history substitution (avoid errors with ! usage)
set +H
########################################################
# Get inbox messages
get_unread_replies() {
end_point="user/replies"
www_data="auth=$jwt&unread_only=true"
url="$my_instance/$API/$end_point?$www_data"
curl "$url"
}
get_unread_replies
Personally, I’d use the ‘jq’ program to de-serialize the reply, e.g.
get_unread_replies.sh | jq ‘.replies[].comment.content’
My next plan is to use a script like this with a notification service like PUSHOVER, so it can ding my phone if I’ve an unread message
For each API method, whether it’s GET or POST and end_point can be found here, and then each method has a click-through to see what parameters it can take.
You must log in or register to comment.