"use strict";(self.webpackChunknewoaks_help=self.webpackChunknewoaks_help||[]).push([[8567],{3173:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>h,frontMatter:()=>c,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"integration-backend","title":"Integrating with Backend APIs","description":"This guide provides a standardized approach for integrating with backend APIs, covering request methods, data structures, and error-handling best practices. Follow these steps to ensure seamless API interactions","source":"@site/Integration/014.integration-backend.md","sourceDirName":".","slug":"/integration-backend","permalink":"/guides/integration/integration-backend","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":14,"frontMatter":{"sidebar_position":14},"sidebar":"sidebar","previous":{"title":"Clerk Integration","permalink":"/guides/integration/integration-clerk"},"next":{"title":"Chatbot Integration","permalink":"/guides/integration/chatbot"}}');var r=s(4848),i=s(8453);s(8175);const c={sidebar_position:14},d="Integrating with Backend APIs",o={},l=[{value:"<strong>1. General API Structure</strong>",id:"1-general-api-structure",level:3},{value:"<strong>Request Details</strong>",id:"request-details",level:3},{value:"<strong>Response Structure</strong>",id:"response-structure",level:3},{value:"<strong>Handling Responses</strong>",id:"handling-responses",level:3},{value:"<strong>2. Example Integration: Product Details API</strong>",id:"2-example-integration-product-details-api",level:3},{value:"<strong>3. Best Practices</strong>",id:"3-best-practices",level:3}];function a(e){const n={code:"code",h1:"h1",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"integrating-with-backend-apis",children:"Integrating with Backend APIs"})}),"\n",(0,r.jsx)(n.p,{children:"This guide provides a standardized approach for integrating with backend APIs, covering request methods, data structures, and error-handling best practices. Follow these steps to ensure seamless API interactions"}),"\n",(0,r.jsx)(n.h3,{id:"1-general-api-structure",children:(0,r.jsx)(n.strong,{children:"1. General API Structure"})}),"\n",(0,r.jsx)(n.p,{children:"All API requests should adhere to the following structure:"}),"\n",(0,r.jsx)(n.h3,{id:"request-details",children:(0,r.jsx)(n.strong,{children:"Request Details"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"Request Type"}),": Use ",(0,r.jsx)(n.code,{children:"POST"})," as specified by the endpoint."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"Request URL"}),": Include the full endpoint URL (e.g., ",(0,r.jsx)(n.code,{children:"https://api.example.com/resource"}),")."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"Request Body"}),": Submit data in JSON format."]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"Example Request Body"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:'{\n  "OrderID": 123456  // Replace with a valid identifier\n}\n'})}),"\n",(0,r.jsx)(n.h3,{id:"response-structure",children:(0,r.jsx)(n.strong,{children:"Response Structure"})}),"\n",(0,r.jsx)(n.p,{children:"The API returns responses in the following JSON format:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:'{\n  "Success": true/false,\n  "Data": {},     // Included when Success = true\n  "Msg": "..."    // Included when Success = false\n}\n'})}),"\n",(0,r.jsx)(n.h3,{id:"handling-responses",children:(0,r.jsx)(n.strong,{children:"Handling Responses"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"Success Handling"}),":","\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["If ",(0,r.jsx)(n.code,{children:"Success"})," is ",(0,r.jsx)(n.code,{children:"true"}),", extract data from the ",(0,r.jsx)(n.code,{children:"Data"})," object."]}),"\n",(0,r.jsx)(n.li,{children:"Process the payload according to your application\u2019s requirements."}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"Error Handling"}),":","\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["If ",(0,r.jsx)(n.code,{children:"Success"})," is ",(0,r.jsx)(n.code,{children:"false"}),", display the ",(0,r.jsx)(n.code,{children:"Msg"})," to the user or log it for debugging."]}),"\n",(0,r.jsx)(n.li,{children:"Implement fallback logic (e.g., retries, alerts) based on the error message."}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"2-example-integration-product-details-api",children:(0,r.jsx)(n.strong,{children:"2. Example Integration: Product Details API"})}),"\n",(0,r.jsxs)(n.p,{children:["To retrieve product data, use the ",(0,r.jsx)(n.strong,{children:"Product Details API"})," as follows:"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"API Endpoint"})}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:"POST <https://usapi.hottask.com/autodev/products>\n\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"Request Structure"})}),"\n",(0,r.jsxs)(n.p,{children:["Include a valid ",(0,r.jsx)(n.code,{children:"ProductID"})," in the JSON body:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:'{\n  "ProductID": 123456  // Replace with the target product\u2019s ID\n}\n\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"Response Example"})}),"\n",(0,r.jsxs)(n.p,{children:["A successful response returns product details in the ",(0,r.jsx)(n.code,{children:"Data"})," field:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:'{\n  "Success": true,\n\xa0 "Data": {\n\xa0 \xa0 "ID": 123456,\n\xa0 \xa0 "Name": "Sample Product",\n\xa0 \xa0 "Price": 29.99,\n\xa0 \xa0 "ImageUrls": [\n\xa0 \xa0 \xa0 "<https://example.com/image1.jpg>",\n\xa0 \xa0 \xa0 "<https://example.com/image2.jpg>"\n\xa0 \xa0 ]\n\xa0 },\n\xa0 "Msg": ""\n}\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"Handling for Product Details API"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"Success"}),": Parse the details  in ",(0,r.jsx)(n.code,{children:"Data"})," to display product information."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"Error"}),": If ",(0,r.jsx)(n.code,{children:"Success"})," is ",(0,r.jsx)(n.code,{children:"false"}),", notify users with the ",(0,r.jsx)(n.code,{children:"Msg"}),' (e.g., "Product not found").']}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"3-best-practices",children:(0,r.jsx)(n.strong,{children:"3. Best Practices"})}),"\n",(0,r.jsxs)(n.p,{children:["Prompt for  Calling ",(0,r.jsx)(n.strong,{children:"Product Details API"}),":"]}),"\n",(0,r.jsx)(n.p,{children:"//Sample Prompt"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:'The data for the **Product Details** needs to be retrieved through the following API. \n\nThe API is defined as follows:\n\xa0 \xa0 \xa0 \xa0 API Endpoint:\n\xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 POST https://usapi.hottask.com/autodev/products\xa0 \xa0 \xa0\n        Request Structure: \n        json\n\xa0 \xa0 \xa0 \xa0 \xa0 \xa0 {\n\n             "ProductID": 123456 // Sample Product ID Value\n\n            }\n\n        Response Example:\n\xa0       json\n\xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 {\n\xa0                "Success": true,\n\xa0                "Data": {\n\xa0 \xa0                 "ID": 123456,\n\xa0 \xa0                  "Name": "Sample Product",\n\xa0 \xa0                  "Price": 29.99,\n\xa0 \xa0                   "ImageUrls": [\n\xa0 \xa0 \xa0                    "https://example.com/image1.jpg",\n\xa0 \xa0 \xa0                    "https://example.com/image2.jpg"\n\xa0 \xa0                  ]\n\xa0                 },\n\xa0                 "Msg": ""\n\n\xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 }\n\xa0 \xa0 \xa0 \xa0 \xa0 \xa0 Success Handling:\n\xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 If Success = true, extract data from the Data object.\n\xa0 \xa0 \xa0 \xa0 \xa0 \xa0 Error Handling:\n\xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 If Success = false, display the Msg to the user or log it for debugging.\n'})})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},8175:(e,n,s)=>{s.d(n,{A:()=>r});s(6540);var t=s(4848);function r(){return(0,t.jsx)("code",{children:"EZsite"})}},8453:(e,n,s)=>{s.d(n,{R:()=>c,x:()=>d});var t=s(6540);const r={},i=t.createContext(r);function c(e){const n=t.useContext(i);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),t.createElement(i.Provider,{value:n},e.children)}}}]);