How do I make JSON api calls?

I’m very new to ruby on rails. I need a view that will show the data from a JSON API calls. How do accomplish this? Do I need to create a model for this? I assumed the controller is the place to put my API calls code, correct?

Where is this API? Is it some s/w running on the same machine as
node-red or a web service or what? Tell us a bit more about it. How
would the API be called from another application?

Colin

Oops, ignore me, I forgot which mailing list I was on. I must remember
to engage brain before typing, sorry

Colin

See Net::HTTP.

I would send you a link but ruby-doc.org is down

You do not need a model, in fact you probably shouldn’t have one unless you want to store the data you receive somewhere. (even then you don’t need a model)

You should think outside of the MVC box. Just because DHH put 3 folders named “models”, “views”, and “controllers” doesn’t mean you have to put all of your ruby code there, especially if MVC doesn’t fit your needs.

One specific scalability thing you might consider is that a in-request server-to-server API is generally considered non-scalable, but it depends on the response time on the remote API. If it is very fast maybe it will work. If it is slow, it will slow down your website.

If I’d were to build something really scalable, I’d fetch the external data in a background process and store it — database or otherwise — so that when the user looks at it it comes from cached place (may be a few minute stale). Then a background job runs on an as-needed basis to keep the data fresh. That’s the scalable way to do it.

But if scalability isn’t a concern you can just make the API call, format the data the way you want it, and show it to the user.

Your question was very high level and so was this answer. As a more specific/detailed question if you want a more specific/detailed answer. Your mileage may vary.

-Jason