Is it possible to use a REST api as a datasource in meteor

Can I use a REST api as a datasource in my meteor app?
My goal is to create a connection to a REST api via the app then have meteor update clients with the new data just like meteor does with mongodb data sources.

Is anyone currently doing this? If so can you share some details examples ect… ?

It is possible, your server would need to poll the rest API. Or the api would need to have the concept of pushing changes to your server via some webhook.

Whichever way you get the data, you would use the publication handles added/changed/removed methods to send those changes to the client. On the client side you declareca collection and use as normal

1 Like

That’s how I thought it would work. do know of any meteor packages that already has similar functionality?

No, because it would likely be very dependent on what data you wanted to expose from the API and what data the API provides (single documents, multiple, nested, etc)

1 Like

To do this, you will need DDP.
If you want DDP, why do you want to use REST over websockets?

1 Like

REST or Websockets don’t really matter to me I just wanted to know if anyone was using a datasource other than mongodb and it sounds as if it’s possible which was what I was after. @coagmano do you have an example of using websockets that you can share?
thx

1 Like

In one of my projects I use a REST source on the server and Mongo collections that are not tied to an actual collection in mongodb to transfer the data to the client. Basically, a Method call to the server that performs the REST and returns the result which is put into a collection and can be accessed on the client the same way as if it had subscribed to a publication

1 Like

I’d look at the Apollo library and I also created this SQL example a while ago - https://github.com/dmarkrollins/MeteorMSSQL