Introduction to Web APIs with Sinatra

This is it, the last section of Phase 3! We've learned a lot along the way: you now know a whole new programming language, Ruby, as well as how to write object-oriented code. You've also learned a bit of SQL and how relational databases work, as well as how to use Ruby to interact with relational databases by using an ORM like Active Record.

This last section is where it all comes together, and we start building a web API so that we can finally make a full-stack application! By the end of the section, you'll be able to produce a web API server that can receive requests from a frontend application, such as React, and send back a JSON response that takes data from the database using your Active Record models.

In this section, we'll learn about how the web works in general, and what it means to be a back-end developer. You'll learn:

  • How the request-response cycle works on a server
  • How to handle requests from different routes
  • A common file structure for a web server
  • How to both send and receive JSON-formatted data

While you could spend weeks learning Sinatra alone, in this section, we'll cover just enough of the essentials so that you can handle requests from a frontend application; interact with the appropriate Active Record models; and send a response back. In the next phase, we'll introduce another tool, Rails, and we'll go into more depth about building larger web applications.