Glad it worked. I didn’t know the endpoint before reading your post.
Japanese Speaker. I can read/write some English but not well, so corrections are always appreciated.
プログラミングや音楽に興味があります。最近はEmacsでよく遊んでます。
Glad it worked. I didn’t know the endpoint before reading your post.
As you said, GET /resolove_object
(https://join-lemmy.org/api/interfaces/ResolveObject.html) may work:
$ post_id=9589178
$ curl 'https://lemm.ee/api/v3/resolve_object?q=https%3A%2F%2Fprogramming.dev%2Fpost%2F${post_id}' | jq .post.post.id
22873872
$ curl 'https://lemm.ee/api/v3/post?id=22873872' | jq '.post_view.post | [.id, .name]'
[
22873872,
"How do you get the url or id of the same post on a different instance?"
]
I’m not sure what “lemmy_server api_tests context” does mean, but
curl 'https://<instance>/api/v3/community?name=lemmydev' | jq .moderators
seems to work for me.
No problem! Thanks for moderating this community.
listCommunities
with sort=Hot
and type_=Local
would work. See:
I’d call getPersonDetails, getPost or getCommunity then check moderators
attribute.
Can you share the reproducible requests/URLs?
it doesn’t appear that comments returned are sorted or grouped together in any way by default
Have you tried sort
parameter?
Yes. See here.
I’d call GET /api/v3/comment/list?post_id=<post_id>&type_=All
to get comments,
then sort the comments with path
attribute.
Hi! The first curl example doesn’t seem to work - it fetches comments but they are not relevant to https://lemmy.world/post/290602 :
> curl -H 'Accept: application/activity+json' "https://lemmy.world/api/v3/comment/list?limit=10&postId=290602" | jq -c '.comments[] | [.post.id, .comment.id, community.name]'
[484044,486431,"nostupidquestions"]
[455772,486976,"giftofgaming"]
...
[485477,486428,"outoftheloop"]
[484044,485717,"nostupidquestions"]
It seems that we need to set type_
parameter like this:
> curl -H 'Accept: application/activity+json' "https://lemmy.world/api/v3/comment/list?limit=10&post_id=290602&type_=All" | jq -c '.comments[] | [.post.id, .comment.id, community.
name]'
[290602,484328,"programmer_humor"]
[290602,374758,"programmer_humor"]
...
[290602,355277,"programmer_humor"]
[290602,345799,"programmer_humor"]
It seems OAuth2 hasn’t implemented yet. At this time,
to get auth
value, username and password are required:
# Python
url = 'https://<instance_name>/user/login'
data = {'username_or_email': username_or_email,
'password': password}
response = requests.post(url, json=data)
json = response.json()
auth = json['jwt']
Since the endpoint recieves JSON then returns JSON, you may need to send following HTTP headers explicitly:
Content-Type: application/json
Accept: application/json
Since it’s a MediaWiki page you can get Markdown source of the page with appending
action=raw
query to the URL.