CodingTrain / Intro-to-Data-APIs-JS

Working with Data and APIs in JavaScript
MIT License
754 stars 610 forks source link

Convert REST to Stream #8

Closed Californ1a closed 5 years ago

Californ1a commented 5 years ago

Oftentimes, an api will be available in REST format without a Stream option, so you have to query the REST api every so often to get updates from it. It would be nice to see this included - working around rate limits and such in order to convert a REST api into your own Stream to use.

shiffman commented 5 years ago

Interesting! I like this idea! Could you give me a specific example of an API that would make sense for me to show this with? The less authentication required the better 😄

Californ1a commented 5 years ago

Any RSS feed would probably work well as a simple demo without having to deal with an actual REST api and auth, although RSS feeds are typically xml instead of json, so you'd probably have to do xml parsing, and you'd have to find one you could easily insert new entries into for testing/demo. Alternatively, and maybe a better option, you could reference your playlist on creating a REST api, and fetch from something similar to that, though altered a little in order to give new entries on future calls instead of being a predefined word and count (so you have a reason to want to use a Stream). Third option even simpler than those two would be to just use express to serve a text or json file, and then building a Stream to get changes/new entries from the file since the last fetch (and emitting an event when changes are detected).

shiffman commented 5 years ago

Labeling this as "Part 2" for now. I like the idea of doing this, but at the moment it's a little out of scope for the current examples described in #12. Although who knows maybe I'll need to simulate 'streaming' in one of these, we'll see!

shiffman commented 5 years ago

closing the for next time issues but hope to come back to these!