2017-04-13 Mastodon API

Testing the API with cURL provides a start.

Get a token for the imaginary app “Oddmuse”:

curl -X POST -d "client_name=Oddmuse&redirect_uris=urn:ietf:wg:oauth:2.0:oob&scopes=read" -Ss https://octodon.social/api/v1/apps

Get back a JSON thing that looks as follows:


Use them, with your username and password:

curl -X POST -d "client_id=CLIENT_ID_HERE&client_secret=CLIENT_SECRET_HERE&grant_type=password&username=YOUR_EMAIL&password=YOUR_PASSWORD" -Ss https://octodon.social/oauth/token

Get back a JSON thing containg the auth token:


Now put that access token in a header and request a URL based on the ID you can see in the URL of a status, e.g. for https://octodon.social/web/statuses/504676, based in info in the API documentation.

curl --header "Authorization: Bearer ACCESS_TOKEN_HERE" -sS https://octodon.social/api/v1/statuses/504676/context

You’ll get a lot of JSON, so let’s save it in a file.

curl --header "Authorization: Bearer ACCESS_TOKEN_HERE" -sS https://octodon.social/api/v1/statuses/504676/context > context.json

Get the status itself and save it in a file:

curl --header "Authorization: Bearer ACCESS_TOKEN_HERE" -sS https://octodon.social/api/v1/statuses/504676 > status.json

Get jq. Test it online.

Let’s extract the HTML from the JSON and build a thread.html file.

jq ".ancestors|map(.content)|.[]" < context.json|sed -e 's/^"//' -e 's/"\r$//' -e 's/\\"/"/g' > thread.html
jq ".content" < status.json|sed -e 's/^"//' -e 's/"\r$//' -e 's/\\"/"/g' >> thread.html
jq ".descendants|map(.content)|.[]" < context.json|sed -e 's/^"//' -e 's/"\r$//' -e 's/\\"/"/g' >> thread.html

Turn it into text using w3m:

w3m -T text/html < thread.html | fmt > thread.txt


@lewisnyman Very much. I'd like to see "channels", on a /defined/ basis,
not / just/ definable by posters. That would let you filter content
by source and/or topic.  That should include a "personal" or "social"
context. And more than on channel might apply to a topic, e.g., "japan"
/and/ "politics", say.

@dredmorbius @lewisnyman ... but how would you handle individual users who
are posting about various topics (e. g. I post about financial economics
as well as other stuff)? Hashtags?

@stefanieschulte @dredmorbius @lewisnyman back on Usenet (for those who
are old enought to remember ;-) you didn&apos;t "follow" individuals,
but topics (aka newsgroups) instead. Which, IMO, was (and is) the better
concept, as I more often are interested in a topic than in all postings
by some individual.

@cynix @lewisnyman @dredmorbius @stefanieschulte Regarding USENET and
groups: remember the discussions regarding new newsgroups? The global
namespace, the kill lists, the trolls? It wasn&apos;t always great. No
need to repeat those mistakes.

@kensanata @stefanieschulte @dredmorbius @lewisnyman of course do I
remember all of Usenet, as I managed one of the largest German sites
during the 90s. And while there where certain problems, I don&apos;t see
where these are solved in todays fragmented infrastructure of social
sites, bulletin boards (yuck) or walled gardens. And I doubt that the
ephemeral "streams of consciousness" here are better either. We need
mix of the best from old and new, not just "new"

@cynix @kensanata @stefanieschulte @lewisnyman I also want to
disintermediate the underlying characteristics and systems of Usenet. Most
especially the technical and social, and not confounding them.

Realising also that Usenet and the early Internet operated within the
walled garden of academia and technology companies. It selected a subset
of a subset of society.

Joseph Wood Krutch, "A bad road is a good filter" is another useful idea.

@lewisnyman @stefanieschulte @kensanata @cynix
https://en.m.wikipedia.org/wiki/ Joseph_Wood_Krutch

@dredmorbius @lewisnyman @stefanieschulte @cynix I guess my main
point is this: an observable bad was trolls on Usenet but also toxic
people in local special interest groups (what Stefanie mentioned). I
see the common thread being namespace competition. There is only one
comp.lang.lisp. There is only one LUG Zürich, and so on. Which is
why federation of servers, name spacing of hashtags, multiplicity of
Communities and Collections on G+.

@kensanata @stefanieschulte @lewisnyman @dredmorbius to make that clear:
I favor the technical infrastructure of Usenet, because here (or even
worse on bulletin boards, which are a rather nasty kind of walled garden)
I have little chance of archiving an interesting thread for later or
offline reading or condensing the information contained.

BTW, I still can connect to e.g. News.Individual.DE for lively and
friendly discussions in various newsgroups.

@cynix @kensanata @stefanieschulte @lewisnyman I suspect you /can/
d/l / archive threads on Mastodon / OSocial, if only by running your
own instance.

There are several console / CLI clients already, a Mastodon / OSocial
front-end based on, say, rtin or mutt, might be feasible, and could
be interesting.

Though that takes technical chops for now. Building that into the Web
clients / chat tools would be a plus.

Especially a "grab thread" feature.

@dredmorbius @cynix @stefanieschulte @lewisnyman A simple bookmarklet
should allow you to download a thread as a document?

@kensanata @cynix @stefanieschulte @lewisnyman Probably. Hrm.

It’s not bad. All it’s missing is the author, I think? With a bit of Perl instead of jq it should be easy to fix this. Here’s how to get the usernames posting the status...

jq ".ancestors|map(.account.username,.content)|.[]" < context.json

Oh well, endless joy! :)




– AlexSchroeder 2017-04-15 21:30 UTC

Trying to compile Don on my laptop:

--> Building server JavaScript bundle
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
make: *** [build/entry-server-bundle.js] Error 125

See Docker via Homebrew.

brew install docker docker-machine webpack
brew cask install virtualbox
docker-machine create main
eval $(docker-machine env main)
npm install --save-dev webpack

That doesn’t work. I also tried to install webpack using Homebrew, but got the same error:

--> Building server JavaScript bundle
yarn run v0.22.0
$ NODE_ENV=production webpack -p --bail --config webpack.config.server.js 
sh: 1: webpack: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
make: *** [build/entry-server-bundle.js] Error 1

And with that, I have decided that the infrastructure required for this project is too complicated for my liking.

– Alex Schroeder 2017-04-17 19:34 UTC

More bookmarks, this time for ActivityPub:

– Alex Schroeder 2018-12-15 10:09 UTC

Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.