Skip to main content

Introduction to REST API

In the 'Mocking data' chapter, we went over how to mock data and arrived at a mockTimeEntries data set. So far, we had this data set defined within our code. But in real life, an application would 'fetch' this kind of data from a back-end/database. This chapter will prepare you to understand how we can set up our own server/back-end that will hold the mockData - from now on called, data - and we will see how we can interact with our server using the REST API.

A REST API (also known as RESTful API) is an application programming interface (API or web API). It is a set of rules that allows programs to talk to each other. The developer creates the API on the server and allows the client to talk to it.

"REST" stands for “Representational State Transfer”. It is a set of rules that developers follow when they create their API. One of these rules states that you should be able to get a piece of data (called a resource) when you link to a specific URL. Each URL is called a request while the data sent back to you is called a response.