Impeccable API Design: What you MUST CONSIDER before deploying APIs to production

Поделиться
HTML-код
  • Опубликовано: 12 июн 2024
  • In this video, we talk about what APIs are, how they help software engineers expose data for query and updates, and what are some best practices when exposing APIs on the server side.
    We touch upon various topics including:
    00:00 What is an API?
    00:27 Indian Government Aadhaar APIs
    00:40 How do APIs work?
    01:16 REST vs. GraphQL
    01:31 Webhooks
    02:04 Writing Good APIs
    02:10 What is Atomicity?
    02:53 What is Idempotency?
    03:35 Error Codes for HTTP APIs
    05:28 OpenAPI Specs with Swagger
    05:54 War Story - Aadhaar API Integration
    We end with a war story of API design gone wrong. Let's make our software clients live in a better place :p
    Are you looking to master system design?
    InterviewReady: interviewready.io/
    You can follow me on:
    Github: github.com/InterviewReady/sys...
    LinkedIn: / interview-ready
    Twitter: / gkcs_
    #SystemDesign #InterviewReady #Coding

Комментарии • 35

  • @S3Kglitches
    @S3Kglitches 10 месяцев назад +46

    Errors should not be just plain message sent in response. There is a whole standard for errors and it's called Problem Details (RFC 7807). That's the right way of building a good web API.

    • @gkcs
      @gkcs  10 месяцев назад +7

      Excellent points, thank you!

  • @S3Kglitches
    @S3Kglitches 10 месяцев назад +24

    Idempotency does not apply to all API requests. The HTTP protocol explicitly defines which HTTP verbs should be idempotent. For example POST is not idempotent. It will simply insert another entity when repeated.

    • @arunraju9705
      @arunraju9705 10 месяцев назад

      Keep going man. good stuff!

    • @AamirKhan-gv8oh
      @AamirKhan-gv8oh 10 месяцев назад

      @S3K what do you suggest to follow for REST best practices

    • @S3Kglitches
      @S3Kglitches 10 месяцев назад +5

      @AamirKhan-gv8oh Read the REST definition paper or its brief summary and read the relevant HTTP standards (RFC) in latest version for each used part of the protocol.
      Do not aim for REST API maturity level 3 but try reaching REST API maturity level 2.

  • @prabhussingh
    @prabhussingh 10 месяцев назад

    Really insightful 💡

  • @S3Kglitches
    @S3Kglitches 10 месяцев назад +14

    "You can access APIs using REST or GraphQL" = wrong. You access *web* APIs using HTTP protocol. REST is only about structuring API and adding semantics to the endpoints.

    • @olafthebadlynamed2373
      @olafthebadlynamed2373 9 месяцев назад

      Where are you quoting this from? He said expose, not access.

    • @Maruth
      @Maruth 15 дней назад

      In way than also wrong, you reach api server with TCP/IP Portcol

  • @dalbeersingh1788
    @dalbeersingh1788 6 месяцев назад

    This is a great video!

  • @S3Kglitches
    @S3Kglitches 10 месяцев назад +9

    APIs are not just web APIs of which you are talking but for example Win32 API to communicate with the operating system. API is not Web API.

  • @thePradiptalks
    @thePradiptalks 9 месяцев назад

    Hey Gaurav,
    You mentioned about the aadhar data being transferred over wire. Can you explain more about good that works and how it should actually be transferred?

  • @sarankumar_n
    @sarankumar_n 10 месяцев назад +2

    6:42 I also faced that status code problem 😅. I receive status code as 200 but in response they have field called status which value is failed 😒.

  • @forbiddensouls
    @forbiddensouls 9 месяцев назад +1

    are there any tools or libraries we can refer to, in order to handle atomicity well?
    For instance, If during an API execution I am performing a couple of operations and one tends to break, then at times its kinda hard to revert the other partially committed operations.
    function myFullOperation(){
    // first partial operation - Writes something in DB or updates
    const myminorOperation = new Promise()
    // same as previous one
    const mysecondMinorOperation = new Promise()
    // this one fails
    const thisOperationFails = new Promise()
    }
    We can definitely manually write the logic to handle these operations, but that would be a nightmare when writing complex logics and your app tends to scale. So is there any tidier way to handle this?

  • @smrutiranjansahoo1308
    @smrutiranjansahoo1308 10 месяцев назад

    @gkcs when you're saying add api should be idempotency, what if clients wants to add multiple times on the given id ?? In that case it won't be. Right??

  • @atharva1237
    @atharva1237 10 месяцев назад +1

    This has been usch a big problem when I was using Third Party GST apis they are just shit! They give response 200 with error message very frustrating. Very good video.

  • @user-kq5om9bi3i
    @user-kq5om9bi3i 9 месяцев назад

    There are two response codes generally. 1 API response code, 2. Operation response. They both might be HTTP Status Codes

  • @user-hk6jp8ol9l
    @user-hk6jp8ol9l 6 месяцев назад

    nice
    ❤❤❤❤

  • @pankaj_9998
    @pankaj_9998 9 месяцев назад

    Idempotent - How do server knows that the request add (10rs, id- 50) is already done? If the client is making the request for the second time ??

  • @sandipbhaumik
    @sandipbhaumik 8 месяцев назад

    I have a query about api atomicity. Let's say I have a bulk operation In database and the process gets failed in between. Is it okay to skip that erroneous data and continue till end? If we maintain the atomicity, then I have to rollback all transaction due single or few data which are faulty. What's your opinion on this?

  • @afsanVlog1100
    @afsanVlog1100 9 месяцев назад

    please increase video quality it can be more than 1080 p and I am pretty sure you will consider , watching on big screen need good quality of video Thanks

  • @mrrishiraj88
    @mrrishiraj88 10 месяцев назад

    👍💯🙏

  • @mohammedsameermohiuddin1121
    @mohammedsameermohiuddin1121 9 месяцев назад

    User not found is not an error. And status code indicate the api is successfully completed. I think 200 sc is correct we always check if error exists in the response

    • @gkcs
      @gkcs  9 месяцев назад

      When designing APIs, think of the client (people calling the API) instead of the server (engineers handling the requests).
      It is likely that the sender expected to read or write data in the system. They won't consider a "UserNotFound" response as part of their normal/happy flow.
      Hence it is more intuitive to return an error code in the response along with the description/prescription.
      Does this make sense? Let me know if you have further doubts on this.

  • @RajaSekharaReddyKaluri
    @RajaSekharaReddyKaluri 10 месяцев назад

    @gkcs can you share a intermediate level python API (flask or fastapi) which has all the best practices followed?
    I want to use it as a template for any new development around apis

  • @Chesstreamer
    @Chesstreamer 10 месяцев назад +5

    Bro made an entire video to teach those Adhaar engineers how to send right api response code🤣

    • @gkcs
      @gkcs  10 месяцев назад

      It wasn't the Aadhaar folks, it was a third party😅
      But yes, I made a video out of it :p

  • @cristinareese8444
    @cristinareese8444 9 месяцев назад

    😝 Promo sm

  • @KheraShanu
    @KheraShanu 10 месяцев назад +1

    Came here to comment, but apparently S3Kglitches took away all my comments and more ... kudos to You @S3Kglitches

    • @gkcs
      @gkcs  10 месяцев назад +2

      It's folks like @S3Kglitches who make this an awesome place.

  • @dalbeersingh1788
    @dalbeersingh1788 6 месяцев назад

    This is a great video!

  • @dalbeersingh1788
    @dalbeersingh1788 6 месяцев назад

    This is a great video!

  • @dalbeersingh1788
    @dalbeersingh1788 6 месяцев назад

    This is a great video!

  • @dalbeersingh1788
    @dalbeersingh1788 6 месяцев назад

    This is a great video!