Full-Stack Web Development with Vue.js and Node

(singke) #1

4


Introducing REST APIs


An Application Programming Interface (API), in general, is used to get data from one


application to another. There are different kinds of APIs that are used in different areas,


such as hardware and programming, but we will be talking only about web APIs. Web
APIs are a form of web service that provides an interface to communicate between multiple


applications. Data from one application is sent to another application via an HTTP protocol
using such APIs.


In this chapter, we will talk about:


REST architecture and RESTful APIs
HTTP verbs and status codes
Developing and testing APIs using Postman

Web APIs work in a similar way to how the browser interacts with our application server.


The client requests some data from the server and the server responds with the formatted
data to the client; APIs do something similar. For example, there is a contract set


beforehand between the multiple applications. So, if there are two applications that need to


share data, then one application will submit a request to another application, saying it
needs this data in this format. When another application receives the request, it fetches the


data from its server and responds with the structured and formatted data to the client or
the requester.


Web APIs are classified into Simple Object Access Protocol (SOAP), Remote Procedure


Call (RPC), or Representational State Transfer (REST) categories. The response format for
these APIs can be in various forms, such as XML, JSON, HTML, images, and videos.


APIs also have different models, such as Public APIs and Private APIs:


Private APIs: Private or internal APIs are only used in internal applications
within an organization
Public APIs: Public or external APIs are designed in a way such that they can be
shared with the public parties outside of an organization as well
Free download pdf