What is an APIs?
Application Programming Interfaces,
is a set of components that define how a set of functionalities can be accessed by others. APIs allow developers to take advantage of code written by others. If a developer writes a large library of code to perform specific tasks, another developer can easily access that library using the API endpoints that are defined for it.
Similarly, by defining a web API on your server, you'll create a set of high-level options that clients can use to interact with your back-end and access it's data. Instead of each client having to directly query the database for each piece of data it needs, they can simply call an API method on the server and get the desired result. All the client will need to know is what information the API needs, and what data will be returned as a result. The client does not have to worry about what happens on the server in order to prodcue this result.
Defining RESTful Web APIs
REST stands for REpresenational State Transfer. This can be a complex topic. We won't dive too deep into REST concepts, but there are a few important, but simple, ideas to understand as we build a basic RESTful API.
We know that the function of the back-end of a web app is to listen for and handle requests from clients. These requests revolve around data. In a RESTful system, all data is represented in terms of resources. Many systems can be designed in this wa
Web Api format
Our Web API will simply consist of a set of routes that match the types of HTTP requests we expect our clients to make. Each API endpoint is defined by:
1. an HTTP method type (GET, PUT, POST or DELETE)
2. a URI