Learning Goals 🎯

  1. Understand the different ways to communicate with other webservices
  2. Know how to interact with API's and Webhooks
  3. Be able to use the Faraday gem to make requests and receive JSON data

So far, we've been working with creating and managing our app's own data. We usually provide forms and views for people to create and see models within our app. But how can we tap into the rest of the web's vast resources? The internet is full of information, and there's no reason that our apps can't tap into it! But how do we access it?

This is a small question in the larger topic of integrating with other websites. The "web" is just computers talking to eachother, and that doesn't have to be restricted to a user's browser sending requests to our webserver! Our rails app can send requests and "talk" to API's (other webservers) that people create. And it can also sign up to recieve requests when some event happens, called a WebHook.

Below, we'll dive into these concepts and learn how we can use them!

What is JSON?

So far, the flow of communication in our Rails projects has been the user's browser sending our server requests and getting back HTML for the browser to render. Traditionally, we think of HTML is the default language that we send back data in, hence all of our *.html.erb files. However, that's not the only "language" we can use! The second most common language you'll see is called JSON

JSON stands for "Javascript Object Notation". It's effectively just one big hash or array put into a file. Let's take a look at an example JSON file