What is the first step to using the REST API in Rails?

I just finished the Hartle book on rails. Following the examples were useful, and I was able to create some very simple functions for my application. However, there is this API that I would like to use, and it was provided with a key for the API. I do not know how to start implementing the API. Other material related to the API was useful, but I was literally fixated on the fact that the implementation of the API should be the first step.

I need the user to be able to register and authenticate, and then provide data that will be tracked through an external API. I have a user who logs in and authenticates, I just need to know what the first step should be to use this API.

The logic of the answer will be equally useful.

+2
source share
1 answer

You can use ActiveResource for your model and point it to an external API. This is useful if your model uses an external data source.

http://api.rubyonrails.org/classes/ActiveResource/Base.html

If the external API that you want to use is well known, there is a good chance that there is already a stone to interact with this API.

If you only need to send some data to an external API, but your model does not use it as a source, you can use an HTTP client such as Faraday https://github.com/technoweenie/faraday

+2
source

Source: https://habr.com/ru/post/946429/


All Articles