kill-the-newsletter icon indicating copy to clipboard operation
kill-the-newsletter copied to clipboard

Allow usage via API

Open zakius opened this issue 4 years ago • 2 comments
trafficstars

Thanks for your great tool! It would be great if it was possible to use it in more automated way thanks to some simple API, the most basic idea would be receiving the feed name and returning the generated id, though returning an object containing mail address and feed address may be preferred. I may even implement this if you are willing to accept such a feature

zakius avatar Sep 03 '21 22:09 zakius

Thanks for the idea. I actually like it. I’ll take it on myself as part of some changes I already want to make. I’ll let you know when it’s read.

leafac avatar Sep 13 '21 10:09 leafac

Thank you, I'll be looking forward to it!

zakius avatar Sep 13 '21 14:09 zakius

Hi @zakius,

I implemented this and it’ll be out on the next version of Kill the Newsletter!

The only routes that I found made sense as an API are the create feed and delete feed routes.

The delete feed route already acts like an API, you can just ignore the HTML that it returns.

For the create feed route I added a way for you to send a request header of Accept: application/json and the server responds with JSON instead of the usual HTML, for example:

$ curl --request POST --header "CSRF-Protection: true" --header "Accept: application/json" --data "title=Example of a feed" https://localhost/
{"feedId":"r4n7siivh4iiho0gtv59","email":"r4n7siivh4iiho0gtv59@localhost","feed":"https://localhost/feeds/r4n7siivh4iiho0gtv59.xml"}

I’m curious to know what you end up creating with this.

Best.

leafac avatar Jun 06 '24 14:06 leafac

Thanks! If you don't mind I'd like to use it in a browser extension that simplifies feed detection and subscription, I'm not entirely sure whether I'll submit it to extension repositories as it's meant mainly to integrate with my self hosted aggregating service but it will surely end up on GitHub some day

zakius avatar Jun 06 '24 14:06 zakius

Sounds great!

leafac avatar Jun 06 '24 14:06 leafac