Hacker News doesn’t send Webmentions when a post is created like Lobste.rs will, and there’s not currently a service on sites like Brid.gy that wi

Use cURL and jq to Send Webmentions from Hacker News

submited by
Style Pass
2024-11-13 21:30:08

Hacker News doesn’t send Webmentions when a post is created like Lobste.rs will, and there’s not currently a service on sites like Brid.gy that will provide them for you. Even the Hacker News API doesn’t provide search or filtering by site. Luckily, there is a service provided by Algolia that provides Hacker News search and it can be used without the need for an API key with just cURL. Here’s an example of querying for items with links to my site:

The results are paged, but rather than dealing with paging to the next results, I was able to experiment and pass &hitsPerPage=1000 which more than accounts for the ~30 results I currently see.

Passing this output to jq lets us extract the array of results stored in the hits key. Not all of the results include a url, and the difference appears to be that if the URL is present the result is a story that’s been posted while other results mean that the result represents a comment that matches the query.

For matching stories, we can also have jq filter those out and return just the data that we’ll need to build a Webmention request: the URL being linked to in the story and the objectID which is needed to build the source URL:

Leave a Comment