This is an exciting section as we are going to discuss how to work with API calls in Ruby. We'll start out with a basic API example and get into more advanced ways of working with APIs in subsequent sections. Refer to the following screenshot:
Here, I have an API called Resty that I built for this course. Resty, short for RESTful interfaces, is an API for routing; it's a basic API that has posts and makes them available to the API through the JSON data type, as shown.
Let's discuss a basic way of interacting with this API:
- Create a file called apiexample.rb and open it in the Sublime Text editor.
- There are many requirements for interacting with APIs in Ruby, and in this section, we are going to leverage the httparty Ruby gem to handle API communication. If you don't have this gem on your local system, you can install it with...