Fetching my IndieWeb mentions with HTTPie and Requests
So I hosed a local copy of my mentions feed the other month. What’s my
“mentions feed,” I hear you wondering?
Whenever somebody shares a reaction to something here — like, reshare, reply,
mention — that reaction gets sent to Webmention.io. There are
more moving parts than that, of course. Bridgy aggregates reactions
to my announcement toots and tweets and sends those to Webmention. It shows in
my mentions feed as a reaction to site content when someone reacts to a
Sometimes folks even post mentions, replies, and reactions directly to the
Webmention endpoint. Mostly it’s just social media reactions, though.
The Webmention.io API lets me gather all of these reactions.
Let’s acquaint ourselves with the important parts of this API. You’ll need
your API token, which can be found in the Webmention settings once you sign
Reading the feed with HTTPie
I’ll use HTTPie for my little exploration. I like the way it works.
Getting recent reactions
We mainly care about the mentions endpoint. Hand it your domain and API token,
and it will send you the 20 most recent responses for your site.
HTTPie’s double-equals == syntax means “make a query string,” so I end up
with something like this::
When http fetches that URL, I get back a JF2 feed that looks something
What’s JF2? It’s obviously JSON. Maybe something to do with JSON
Feed? Similar, but no. JF2 is a JSON format for IndieWeb’s
microformats2. The mnemonic I’ve been trying to drill into my
head is “JSON (micro)Formats 2.”
It’s not a very good mnemonic.
Each entry summarizes the reaction, including which of my posts they were
reacting to. That’s kind of important. Most recently, Twitter user
@junkw retweeted my announcement about adding a note from Org
Checking for new reactions
Maybe I’m checking again later and only want to see the new reactions. I
request mentions received since the value of the wm-received field in the
last entry I have.
Well, yeah. That makes sense. I don’t get the kind of traffic where you’d
expect fresh reactions every time you check.
Fetching the oldest reactions first
As I mentioned at the start, my site is a little broken. I need to rebuild the
full list of reactions so my Hugo site can work with a complete record.
To do that, I should probably start from the oldest mentions and work my way
Rather than the default sort-dir of down, I specify up.