The Hacker News Firebase API is publicly available, with multiple endpoints allowing you to query for any news item and user. Also, as their Github readme states:
Up to 500 top and new stories are at /v0/topstories (also contains jobs) and /v0/newstories. Best stories are at /v0/beststories.
E.g., hitting https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty returns the ID's of the top 500 stories on HN at that point in time.
My question is, how are these endpoints created and updated on the Firebase end? Firebase Database allows for some rules such as indexOn
that optimises queries sorted by ID or upvotes etc..., but the user still needs to make a query requesting the sorted data, using orderBy()
for example. I can see nowhere in the Firebase console or docs for creating these endpoints and keeping them updated in the cloud so the endpoint is always returning up-to-date data. How does this work?
It doesn't appear that there is a way to have endpoints like that with content generated on-the-fly by Firebase. It appears that those endpoints are just normal data endpoints, with their data continuously updated by the Hacker News backend to be correct. Firebase isn't the source of truth for HN data anyways: all of the data in the API is updated by a script whenever the underlying data changes in the real database.