Загрузка страницы

REST API tutorial: How to Call a JSON API in the Ruby Programming Language

This is an exciting section as we are going to learn how to work with API calls in this Ruby programming tutorial. We'll start out with a basic API example and get into more advanced ways to work with APIs in subsequent guides.

This is an exciting section as we are going to learn how to work with API calls in Ruby. We'll start out with a basic API example and get into more advanced ways to work with APIs in subsequent guides.

Here, I have an API called Resty that I built for this course. Resty is a short for RESTful interfaces for Routing, and it's a basic API that has posts and makes them available to the API through the json data type.

There are many requirements for interacting with APIs in Ruby, and in this guide we are going to leverage the httparty RubyGem to handle API communication. If you don't have this gem on your local system, you can install it with the command gem install httparty.

In this code, we are creating a class called EdutechionalResty. We start by including the httparty call, and then use a variable that this gem provides called base_uri. As the name suggests, this is the base URI we are going to be using for this application.

Next, we create a method called posts and call an instance of this method. It takes a parameter, which is the endpoint of our API's URL. So, this is all we have to do inside this class.

View code and written guide:
https://www.edutechional.com/2018/08/18/example-of-how-to-work-with-an-api-in-ruby/

Follow me:

Twitter: https://twitter.com/jordanhudgens
Instagram: https://www.instagram.com/jordanhudgens/
GitHub: http://github.com/jordanhudgens

Видео REST API tutorial: How to Call a JSON API in the Ruby Programming Language канала edutechional
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
30 января 2016 г. 23:58:15
00:05:42
Яндекс.Метрика