Posts

Showing posts with the label restful

RESTful API Design

Image
Introduction REST (Representational State Transfer) working with JSON over HTTP/1.1 or HTTP/2 remains the default choice for public APIs and B2B integrations due to its popularity, debuggability and broad ecosystem. API Design & Resource Modeling When adopting REST , the design must maintain consistency, including the following characteristics: Resource-oriented Use plural nouns ( /api/v1/orders, /api/v1/users ). Placing actions in the URL, such as /orders/{id}/cancel , is a bad practice. Instead, use POST /orders/{id}/cancellations or PATCH /orders/{id} with a payload that updates state. Idempotency Ensure GET, PUT, DELETE are always idempotent. For POST (creating resources or processing payments), enforcing an Idempotency-Key in the Header is mandatory to prevent duplicate transactions during network glitches and client retries. Versioning Implement versioning from day one. Prefer URL Versioning (/api/v1/...) because it is explicit, easy to route at the Gateway layer (Nginx...

Creating API Documentation with Swagger on NodeJS

Image
Introduction Swagger is a popular, simple, and user-friendly tool for creating APIs . Most backend developers, regardless of the programming languages they use, are familiar with Swagger . This article will guide you through creating API documentation using Swagger on Node.js (specifically integrated with the Express framework). This is handy when you want to provide API documentation in a professional UI format for stakeholders involved in integration. Restful API REST stands for Representational State Transfer . It is an architectural style that defines a set of constraints for creating web services. RESTful APIs provide a simple and flexible way to access web services without complex processing. Common HTTP Methods in RESTful APIs : - GET : Used to read (retrieve) a representation of a resource. It returns data in XML or JSON format. - POST : Creates new resources or subordinates to existing ones. - PUT : Updates existing resources or creates new ones if the client chooses the...