2
submitted 1 year ago* (last edited 1 year ago) by freamon@feddit.nl to c/linuxscripts@lemmy.zip

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.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here
this post was submitted on 08 Jul 2023
2 points (100.0% liked)

Linux Troubleshooting and scripts

430 readers
1 users here now

this is a community for sharing your scripts that help when working with Linux as well a general troubleshooting.

Rules

Feel free to ask any kind of support questions, as we grow more succinct answers will be available. Let's make this community grow.

We are important to one another, not only in the linux world but also in the fediverse as a whole. Feel free to reach out to me with questions or concerns, as we grow bigger I will look into adding mods. (This section will be updated as needed.)

founded 1 year ago
MODERATORS