leafac / kill-the-newsletter

Convert email newsletters into Atom feeds
https://kill-the-newsletter.com
MIT License
2.31k stars 113 forks source link

Allow usage via API #43

Closed zakius closed 4 weeks ago

zakius commented 2 years ago

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

leafac commented 2 years ago

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.

zakius commented 2 years ago

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

leafac commented 4 weeks ago

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.

zakius commented 4 weeks ago

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

leafac commented 4 weeks ago

Sounds great!