A simple Cloudflare Worker that returns random shower thought data from r/showerthoughts.
A fetch request is made once the API is called. The response is parsed and data is returned. The worker uses Cloudflare KV to temporally store the shower thoughts once their generated. Thoughts already stored in the KV are not generated again, and are ignored.
The API is available at https://shower-thoughts.paintbrush.workers.dev/
.
curl https://shower-thoughts.paintbrush.workers.dev/
{
"data": {
"title": "The word \"shower\" is a verb and a noun.",
"url": "<url>",
"author": "<author>",
"subreddit": "Showerthoughts"
}
}
- The API may get rate limited by Reddit (unlikely, but possible).
- The API may get congested and not return data. This is due to how we "cache" posts, as there's unfortunately not unlimited posts in the subreddit.