Writing an API today in 2022 is that easy-medium to medium-Hard thing! because There are many tools out there that can handle it from the oldest one the RestApi to TRPC. Meanwhile, an API must apply the CRUD (Create, Read, Update, Delete)access to models or the Base layer of the Software Architect.
The representational state transfer API is an architecture style to make connections between client-server applications threw the network using HTTP protocols (POST, GET, UPDATE, DELETE, and more) also using the REQUEST and RESPONSE communication. It is designed for Internet-scale usage by coupling the client side with the hosted server where all the logic is happening. RestAPI encapsulates the data in JSON form or style to make it easy to read and write the data on Humans standards. Also, it uses the routing architect, to send data threw a number of URLs. the RestAPI comes to replace the old and scrappy SOAP that uses the XML to communicate between the client-side and the server-side with heavy data load. So RestApi architectural style affects the following architectural properties : Performance, Scalability, Simplicity, Modifiability, Visibility, Portability, and reliability. this is an example that I created a simple POST and GET method with NodeJS and This is what I fetch from a GET.
GraphQl is an open-source data query and manipulation language for API's also a runtime for fulfilling queries with existing data. It allows the client to define the structure of the data required and the same structure of the data is returned from the server This prevents excessively large amounts of data from being returned, but can impede web caching of query results. The flexibility and richness of the query language also add complexity that may not be worthwhile for simple APIs. GraphQL consists of a type system, query language and execution semantics, static validation, and type introspection. It also can serve HTTP protocols like POST and GET and it is widely used in building modern APIs and getting specific types of data without bringing the whole server data to the user side. This open-source doesn't need to be installed in your system but can be configured online. An example with NodeJS
is a cross-platform open-source high-performance Remote Procedure Call (RPC) framework. In general, it was created to handle a single general purpose RPC (REMOTE PROCEDURE CALLS) infrastructure created by google called Stubby, but it was launched for public use in 2015. The gRPC uses HTTP/2 protocols for transferring data using Protocol buffers as the interface description language providing some features such as authentification, bidirectional streaming, and flow control with blocking or nonblocking bindings. It uses scenarios to connect services in a microservices style architecture or connect mobile device clients to backend services. Also, it supports two principles Authentication and encoding using JSON or XML. the gRPC adopted by many programming languages and big tech companies for its liability. An Example of calling gRPC with NodeJs:
Choosing one of these technologies is helping a lot in developing and building a feature killer API but it is a need to know how to build and use your next API with security, and maintainability standards.