Python Classroom notes 25/Dec/2024

REST API

REST API URI Patterns

URI Pattern HTTP Method Description
/products GET Retrieve a list of all products.
/products/{productId} GET Retrieve details of a specific product by its ID.
/products POST Create a new product.
/products/{productId} PUT Update an existing product by its ID.
/products/{productId} DELETE Delete a specific product by its ID.
/users/{userId}/products GET Retrieve products associated with a specific user.
/users/{userId}/products/{productId} GET Retrieve details of a specific product associated with a user.
/products/{productId}/related GET Retrieve related products for a specific product.

This table outlines common URI patterns for managing products in a REST API, along with the corresponding HTTP methods that define the actions that can be performed on those URIs. Each URI is designed to clearly represent the resource it interacts with, following best practices for RESTful API design.

Citations:
[1] https://stackoverflow.com/questions/44415000/rest-api-url-pattern-design
[2] https://learn.microsoft.com/en-us/azure/architecture/best-practices/api-design
[3] https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API
[4] https://restfulapi.net/resource-naming/
[5] https://www.ibm.com/docs/en/was/8.5.5?topic=applications-defining-uri-patterns-resources-in-restful

  • URI also support query string for filtering and paging
    Preview
  • To make it easier to understand API’s we need to document them, There are two open standards
    • OpenAPI
    • Swagger
  • To test API’s, two popular options are
    • PostMan
    • Thunderclient

How to build REST APIs

  • APIs run on Web or APP servers accepting http(s) connections
  • Depending on which language we are using there are different frameworks

    • Java => Spring boot
    • dotnet => asp.net core web api
    • node => express
    • Python => dJango-restful, flask, Fastapi
  • Findout what asynchronous is ?
  • Findout the difference between parallel vs concurent

Fast API

  • Fast API support asynchronous api’s and it automatically generates API documentation.
  • fast api documentation
    Preview

Lets build a simple Math Calculator REST API

  • Resource (Noun) => Calculator
  • Actions (Verbs) => Add, sub, mul, div,mod
  • versioning: tbd
  • Steps:
  • Refer Here for changes

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube