Building A Rails API

Neal Oh
1 min readSep 5, 2020

An API stands for Application Programming Interface. This means that it will allow components to communicate with each other. You can also make a request from your Rails app to get information about something to trigger an action, process a payment, etc.

API can perform actions on them such as creating, reading, updating, or deleting (CRUD). Actions are identified using different HTTP request methods.

  • GET: requests the server to return either a collection or a single item of a collection.
  • POST: Allowing the API to create a new resource using the payload you’re submitting.
  • PUT: This is used to update data or to change some or all values.
  • DELETE: Delete a resource or a collection.

API is a great use to connect to the front-end such as React.js. Rails with React is a very popular framework for a modern web application since both of these languages are well recognized in the development community. React is less complicated than any other Javascript framework. When building the frontend, the developers use the structured components and add only those modules that are necessary.

In order to connect React with Ruby, is to create two separate applications for the backend and frontend parts:

  • Frontend: Used to build Javascript libraries without needing any Rails code.
  • Backend: Rails API is communicating with the React using JSON files.

--

--

Neal Oh

Full-Stack Developer & Software Engineering from Flatiron