1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[806],{10044:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/tools/api-request-playground",function(){return a(78871)}])},78871:(e,t,a)=>{"use strict";a.r(t),a.d(t,{__N_SSG:()=>c,default:()=>p});var s=a(37876),r=a(14232),n=a(60504),o=a(48230),l=a.n(o),d=a(5132),i=a(17319);JSON.stringify({model:"gpt-3.5-turbo",messages:[{role:"user",content:"Hello, how are you?"}]},null,2);var c=!0;function p(){var e;let{t}=(0,d.s)(),[a,o]=(0,r.useState)([{id:1,name:"New Request",method:"GET",url:"https://jsonplaceholder.typicode.com/posts/1",params:[],headers:[{key:"Content-Type",value:"application/json",enabled:!0}],auth:{type:"none"},body:"",response:null,saved:!1}]),[c,p]=(0,r.useState)(1),[u,x]=(0,r.useState)(2),[h,m]=(0,r.useState)([]),[g,b]=(0,r.useState)(!1),[y,f]=(0,r.useState)(""),[v,j]=(0,r.useState)(null),[N,k]=(0,r.useState)([{id:1,name:"Production",variables:[{key:"BASE_URL",value:"https://api.production.com"},{key:"API_KEY",value:"prod_key_123"}]},{id:2,name:"Development",variables:[{key:"BASE_URL",value:"http://localhost:3000"},{key:"API_KEY",value:"dev_key_123"}]}]),[w,C]=(0,r.useState)(null),[E,S]=(0,r.useState)(!1),[T,P]=(0,r.useState)(!1),[D,A]=(0,r.useState)(!0),[_,O]=(0,r.useState)("params"),[q,R]=(0,r.useState)("body"),[B,I]=(0,r.useState)("javascript"),[U,G]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=localStorage.getItem("apiPlayground_collections");e&&m(JSON.parse(e));let t=localStorage.getItem("apiPlayground_environments");t&&k(JSON.parse(t))},[]),(0,r.useEffect)(()=>{localStorage.setItem("apiPlayground_collections",JSON.stringify(h))},[h]),(0,r.useEffect)(()=>{localStorage.setItem("apiPlayground_environments",JSON.stringify(N))},[N]);let L=a.find(e=>e.id===c),H=e=>{if(1===a.length)return;let t=a.filter(t=>t.id!==e);o(t),c===e&&p(t[t.length-1].id)},J=e=>{o(a.map(t=>t.id===c?{...t,...e}:t))},z=e=>{if(!w||!e)return e;let t=e,a=N.find(e=>e.id===w);
1return a&&a.variables.forEach(e=>{let{key:a,value:s}=e;t=t.replace(RegExp("{{".concat(a,"}}"),"g"),s)}),t},K=(e,t,a)=>{let s=[...L.params];s[e][t]=a,J({params:s})},F=e=>{J({params:L.params.filter((t,a)=>a!==e)})},Y=(e,t,a)=>{let s=[...L.headers];s[e][t]=a,J({headers:s})},X=e=>{J({headers:L.headers.filter((t,a)=>a!==e)})},V=()=>{let e=z(L.url),t=L.params.filter(e=>e.enabled&&e.key);if(t.length>0){let a=t.map(e=>"".concat(encodeURIComponent(e.key),"=").concat(encodeURIComponent(z(e.value)))).join("&");e+=(e.includes("?")?"&":"?")+a}return e},Q=async()=>{P(!0);try{let e,t=Date.now(),a=V(),s={};if(L.headers.forEach(e=>{e.enabled&&e.key&&e.value&&(s[e.key]=z(e.value))}),"bearer"===L.auth.type&&L.auth.token)s.Authorization="Bearer ".concat(z(L.auth.token));else if("apikey"===L.auth.type&&L.auth.key&&L.auth.value)"header"===L.auth.addTo&&(s[L.auth.key]=z(L.auth.value));else if("basic"===L.auth.type&&L.auth.username&&L.auth.password){let e=btoa("".concat(L.auth.username,":").concat(L.auth.password));s.Authorization="Basic ".concat(e)}let r={method:L.method,headers:s};"GET"!==L.method&&"HEAD"!==L.method&&L.body&&(r.body=z(L.body));let n=await fetch(a,r),o=Date.now()-t,l=n.headers.get("content-type");e=l&&l.includes("application/json")?await n.json():await n.text();let d=new Blob([JSON.stringify(e)]).size,i={status:n.status,statusText:n.statusText,headers:Object.fromEntries(n.headers.entries()),data:e,time:o,size:d};J({response:i})}catch(e){J({response:{error:e.message,status:0,statusText:"Error"}})}finally{P(!1)}},M=()=>{b(!0)},W=()=>{y.trim()&&(m([...h,{id:Date.now(),name:y,requests:[]}]),f(""),b(!1))},Z=e=>{let t={id:Date.now(),name:L.name||"".concat(L.method," ").concat(L.url),method:L.method,url:L.url,params:L.params,headers:L.headers,auth:L.auth,body:L.body};m(h.map(a=>a.id===e?{...a,requests:[...a.requests,t]}:a)),b(!1)},$=e=>{o([...a,{id:u,name:e.name,method:e.method,url:e.url,params:e.params||[],headers:e.headers||[],auth:e.auth||{type:"none"},body:e.body||"",response:null,saved:!0}]),p(u),x(u+1)},ee=e=>{confirm("Are you sure you want to delete this collection?")&&m(h.filter(t=>t.id!==e))},et=(e,t)=>{m(h.map(a=>a.id===e?{...a,requests:a.requests.filter(e=>e.id!==t)}:a))},ea=()=>{let e=V(),t={};if(L.headers.forEach(e=>{e.enabled&&e.key&&e.value&&(t[e.key]=z(e.value))}),"bearer"===L.auth.type&&L.auth.token&&(t.Authorization="Bearer ".concat(z(L.auth.token))),"javascript"===B)return"fetch('".concat(e,"', {\n method: '").concat(L.method,"',\n headers: ").concat(JSON.stringify(t,null,4)).concat(L.body&&"GET"!==L.method?",\n body: ".concat(L.body):"","\n})\n .then(response => response.json())\n .then(data => console.log(data))\n .catch(error => console.error('Error:', error));");if("python"===B)return"import requests\n\nurl = '".concat(e,"'\nheaders = ").concat(JSON.stringify(t,null,4).replace(/"/g,"'")).concat(L.body&&"GET"!==L.method?"\ndata = ".concat(L.body):"","\n\nresponse = requests.").concat(L.method.toLowerCase(),"(url, headers=headers").concat(L.body&&"GET"!==L.method?", json=data":"",")\nprint(response.json())");if("curl"===B){let a="curl -X ".concat(L.method," '").concat(e,"'");return Object.entries(t).forEach(e=>{let[t,s]=e;a+=" \\\n -H '".concat(t,": ").concat(s,"'")}),L.body&&"GET"!==L.method&&(a+=" \\\n -d '".concat(L.body,"'")),a}if("nodejs"===B)return"const axios = require('axios');\n\naxios({\n method: '".concat(L.method.toLowerCase(),"',\n url: '").concat(e,"',\n headers: ").concat(JSON.stringify(t,null,4)).concat(L.body&&"GET"!==L.method?",\n data: ".concat(L.body):"","\n})\n .then(response => console.log(response.data))\n .catch(error => console.error('Error:', error));")},es=e=>{let t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),a=URL.createObjectURL(t),s=document.createElement("a");s.href=a,s.download="".concat(e.name,".json"),s.click()};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.A,{seo:{title:"Free API Request Playground 2026 | Postman Alternative for REST Testing",description:"Professional API testing tool with tabs, collections, auth, and environment variables. Test REST APIs like Postman. Generate code for JavaScript, Python, cURL, Node.js. Free online HTTP client!",keywords:"free api testing tool, postman alternative, rest api client, http request playground, api tester online, rest client, curl generator, api authentication test 2026",canonicalUrl:"https://www.nxcode.io
1/tools/api-request-playground"}}),(0,s.jsx)("div",{className:"min-h-screen bg-gray-100",children:(0,s.jsxs)("div",{className:"container mx-auto px-4 pt-20 pb-8 max-w-full",children:[(0,s.jsx)("div",{className:"bg-white border-b border-gray-200 -mx-4 px-4 py-3 mb-0",children:(0,s.jsxs)("div",{className:"flex items-center justify-between max-w-full",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(l(),{href:"/tools",className:"text-pink-600 hover:text-pink-700 text-sm font-medium transition-colors",children:"â Tools"}),(0,s.jsxs)("h1",{className:"text-2xl font-bold text-gray-900",children:["API Playground ",(0,s.jsx)("span",{className:"text-base font-normal text-gray-500",children:"Professional"})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("select",{value:w||"",onChange:e=>C(e.target.value?parseInt(e.target.value):null),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm focus:border-pink-500 focus:ring-2 focus:ring-pink-200",children:[(0,s.jsx)("option",{value:"",children:"No Environment"}),N.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,s.jsx)("button",{onClick:()=>S(!0),className:"px-3 py-2 text-sm border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:"âï¸ Environments"}),(0,s.jsxs)("button",{onClick:()=>A(!D),className:"px-3 py-2 text-sm border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:[D?"âï¸ Hide":"â¶ï¸ Show"," Collections"]})]})]})}),(0,s.jsxs)("div",{className:"flex gap-0 max-w-full -mx-4",children:[D&&(0,s.jsx)("div",{className:"w-64 bg-white border-r border-gray-200 overflow-y-auto",style:{height:"calc(100vh - 140px)"},children:(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsx)("h2",{className:"font-bold text-gray-900",children:"Collections"}),(0,s.jsx)("button",{onClick:M,className:"px-3 py-1 text-xs bg-pink-600 text-white rounded-lg hover:bg-pink-700 transition-colors",children:"+ New"})]}),0===h.length?(0,s.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"No collections yet"}):(0,s.jsx)("div",{className:"space-y-2",children:h.map(e=>(0,s.jsxs)("div",{className:"border border-gray-200 rounded-lg",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-50",children:[(0,s.jsxs)("span",{className:"font-semibold text-sm text-gray-900",children:["\uD83D\uDCC1 ",e.name]}),(0,s.jsxs)("div",{className:"flex gap-1",children:[(0,s.jsx)("button",{onClick:()=>es(e),className:"p-1 text-xs text-gray-600 hover:text-pink-600",title:"Export",children:"\uD83D\uDCBE"}),(0,s.jsx)("button",{onClick:()=>ee(e.id),className:"p-1 text-xs text-gray-600 hover:text-red-600",title:"Delete",children:"\uD83D\uDDD1ï¸"})]})]}),e.requests.map(t=>(0,s.jsx)("div",{className:"px-3 py-2 hover:bg-gray-50 cursor-pointer border-t border-gray-200 group",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("div",{className:"flex-1",onClick:()=>$(t),children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs font-bold px-2 py-0.5 rounded ".concat("GET"===t.method?"bg-green-100 text-green-700":"POST"===t.method?"bg-blue-100 text-blue-700":"PUT"===t.method?"bg-yellow-100 text-yellow-700":"DELETE"===t.method?"bg-red-100 text-red-700":"bg-purple-100 text-purple-700"),children:t.method}),(0,s.jsx)("span",{className:"text-xs text-gray-700 truncate",children:t.name})]})}),(0,s.jsx)("button",{onClick:()=>et(e.id,t.id),className:"opacity-0 group-hover:opacity-100 p-1 text-xs text-gray-600 hover:text-red-600",children:"â"})]})},t.id))]},e.id))})]})}),(0,s.jsxs)("div",{className:"flex-1 bg-gray-100 overflow-y-auto",style:{height:"calc(100vh - 140px)"},children:[(0,s.jsxs)("div",{className:"bg-white border-b border-gray-200 px-4 flex items-center gap-2 overflow-x-auto",children:[a.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b-2 cursor-pointer group ".concat(e.id===c?"border-pink-600 bg-gray-50":"border-transparent hover:bg-gray-50"),onClick:()=>p(e.id),children:[(0,s.jsx)("span",{className:"text-xs font-bold ".concat("GET"===e.method?"text-green-700":"POST"===e.method?"text-blue-700":"PUT"===e.method?"text-yellow-700":"DELETE"===e.method?"text-red-700":"text-purple-700"),
1children:e.method}),(0,s.jsx)("span",{className:"text-sm text-gray-700 max-w-[150px] truncate",children:e.name}),(0,s.jsx)("button",{onClick:t=>{t.stopPropagation(),H(e.id)},className:"opacity-0 group-hover:opacity-100 text-gray-500 hover:text-red-600 ml-2",children:"â"})]},e.id)),(0,s.jsx)("button",{onClick:()=>{o([...a,{id:u,name:"New Request",method:"GET",url:"",params:[],headers:[{key:"Content-Type",value:"application/json",enabled:!0}],auth:{type:"none"},body:"",response:null,saved:!1}]),p(u),x(u+1)},className:"px-3 py-2 text-gray-600 hover:text-pink-600 hover:bg-gray-50",children:"+ New Tab"})]}),(0,s.jsxs)("div",{className:"p-6",children:[(0,s.jsxs)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 mb-6",children:[(0,s.jsx)("div",{className:"p-4 border-b border-gray-200",children:(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsxs)("select",{value:L.method,onChange:e=>J({method:e.target.value}),className:"px-4 py-2 border border-gray-300 rounded-lg font-semibold focus:border-pink-500 focus:ring-2 focus:ring-pink-200",children:[(0,s.jsx)("option",{value:"GET",children:"GET"}),(0,s.jsx)("option",{value:"POST",children:"POST"}),(0,s.jsx)("option",{value:"PUT",children:"PUT"}),(0,s.jsx)("option",{value:"DELETE",children:"DELETE"}),(0,s.jsx)("option",{value:"PATCH",children:"PATCH"}),(0,s.jsx)("option",{value:"HEAD",children:"HEAD"}),(0,s.jsx)("option",{value:"OPTIONS",children:"OPTIONS"})]}),(0,s.jsx)("input",{type:"text",value:L.url,onChange:e=>J({url:e.target.value}),placeholder:"https://api.example.com/endpoint",className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-2 focus:ring-pink-200"}),(0,s.jsx)("button",{onClick:Q,disabled:T,className:"px-6 py-2 bg-gradient-to-r from-pink-600 to-orange-500 text-white rounded-lg font-semibold hover:shadow-lg transition-all disabled:opacity-50",children:T?"â³":"Send"}),(0,s.jsx)("button",{onClick:M,className:"px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",title:"Save to Collection",children:"\uD83D\uDCBE"})]})}),(0,s.jsx)("div",{className:"border-b border-gray-200 px-4 flex gap-1",children:["params","auth","headers","body"].map(e=>(0,s.jsxs)("button",{onClick:()=>O(e),className:"px-4 py-2 font-medium text-sm capitalize ".concat(_===e?"text-pink-600 border-b-2 border-pink-600":"text-gray-600 hover:text-gray-900"),children:[e,"params"===e&&L.params.filter(e=>e.enabled&&e.key).length>0&&(0,s.jsx)("span",{className:"ml-1 px-1.5 py-0.5 bg-pink-100 text-pink-700 rounded-full text-xs",children:L.params.filter(e=>e.enabled&&e.key).length}),"headers"===e&&L.headers.filter(e=>e.enabled&&e.key).length>0&&(0,s.jsx)("span",{className:"ml-1 px-1.5 py-0.5 bg-pink-100 text-pink-700 rounded-full text-xs",children:L.headers.filter(e=>e.enabled&&e.key).length})]},e))}),(0,s.jsxs)("div",{className:"p-4",children:["params"===_&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Query parameters are appended to the URL"}),(0,s.jsx)("button",{onClick:()=>{J({params:[...L.params,{key:"",value:"",enabled:!0}]})},className:"px-3 py-1 text-sm bg-pink-600 text-white rounded-lg hover:bg-pink-700",children:"+ Add"})]}),0===L.params.length?(0,s.jsx)("p",{className:"text-sm text-gray-400 text-center py-8",children:"No query parameters"}):(0,s.jsx)("div",{className:"space-y-2",children:L.params.map((e,t)=>(0,s.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,s.jsx)("input",{type:"checkbox",checked:e.enabled,onChange:e=>K(t,"enabled",e.target.checked),className:"w-4 h-4"}),(0,s.jsx)("input",{type:"text",value:e.key,onChange:e=>K(t,"key",e.target.value),placeholder:"Key",className:"flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-1 focus:ring-pink-200"}),(0,s.jsx)("input",{type:"text",value:e.value,onChange:e=>K(t,"value",e.target.value),placeholder:"Value",className:"flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-1 focus:ring-pink-200"}),(0,s.jsx)("button",{onClick:()=>
1F(t),className:"p-2 text-red-600 hover:bg-red-50 rounded-lg",children:"â"})]},t))})]}),"auth"===_&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("select",{value:L.auth.type,onChange:e=>J({auth:{type:e.target.value}}),className:"w-full px-4 py-2 border border-gray-300 rounded-lg mb-4 focus:border-pink-500 focus:ring-2 focus:ring-pink-200",children:[(0,s.jsx)("option",{value:"none",children:"No Auth"}),(0,s.jsx)("option",{value:"bearer",children:"Bearer Token"}),(0,s.jsx)("option",{value:"apikey",children:"API Key"}),(0,s.jsx)("option",{value:"basic",children:"Basic Auth"})]}),"bearer"===L.auth.type&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Token"}),(0,s.jsx)("input",{type:"text",value:L.auth.token||"",onChange:e=>J({auth:{...L.auth,token:e.target.value}}),placeholder:"your_bearer_token or {{API_KEY}}",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-2 focus:ring-pink-200"}),(0,s.jsx)("p",{className:"mt-2 text-xs text-gray-500",children:"Token will be sent as: Authorization: Bearer YOUR_TOKEN"})]}),"apikey"===L.auth.type&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Key"}),(0,s.jsx)("input",{type:"text",value:L.auth.key||"",onChange:e=>J({auth:{...L.auth,key:e.target.value}}),placeholder:"X-API-Key",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-2 focus:ring-pink-200"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Value"}),(0,s.jsx)("input",{type:"text",value:L.auth.value||"",onChange:e=>J({auth:{...L.auth,value:e.target.value}}),placeholder:"your_api_key",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-2 focus:ring-pink-200"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Add to"}),(0,s.jsxs)("select",{value:L.auth.addTo||"header",onChange:e=>J({auth:{...L.auth,addTo:e.target.value}}),className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-2 focus:ring-pink-200",children:[(0,s.jsx)("option",{value:"header",children:"Header"}),(0,s.jsx)("option",{value:"query",children:"Query Params"})]})]})]}),"basic"===L.auth.type&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Username"}),(0,s.jsx)("input",{type:"text",value:L.auth.username||"",onChange:e=>J({auth:{...L.auth,username:e.target.value}}),placeholder:"username",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-2 focus:ring-pink-200"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Password"}),(0,s.jsx)("input",{type:"password",value:L.auth.password||"",onChange:e=>J({auth:{...L.auth,password:e.target.value}}),placeholder:"password",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-2 focus:ring-pink-200"})]}),(0,s.jsx)("p",{className:"text-xs text-gray-500",children:"Credentials will be sent as: Authorization: Basic BASE64(username:password)"})]})]}),"headers"===_&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Custom headers for your request"}),(0,s.jsx)("button",{onClick:()=>{J({headers:[...L.headers,{key:"",value:"",enabled:!0}]})},className:"px-3 py-1 text-sm bg-pink-600 text-white rounded-lg hover:bg-pink-700",children:"+ Add"})]}),(0,s.jsx)("div",{className:"space-y-2",children:L.headers.map((e,t)=>(0,s.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,s.jsx)("input",{type:"checkbox",checked:e.enabled,onChange:e=>Y(t,"enabled",e.target.checked),className:"w-4 h-4"}),(0,s.jsx)("input",{type:"text",value:e.key,onChange:e=>Y(t,"key",e.target.value),placeholder:"Header name",className:"flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-1 focus:ring-pink-200"}),(0,s.jsx)("input",{type:"text",value:e.value,onChange:e=>Y(t,"value",e.target.value),placeholder:"Header value",className:"flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:border-pink-500 focus:ring-1 focus:ring-pink-200"}),(0,s.jsx)("button",{onClick:()=>X(t),className:"p-2 text-red-600 hover:bg-red-50 rounded-lg",children:"â"})]},t))})]}),"body"===_&&(0,s.jsx)("div",{children:"GET"===L.method||"HEAD"===L.method?(0,s.jsxs)("p",{className:"text-sm text-gray-400 text-center py-8",children:[L.method," requests typically don't have a request body"]}):(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-gray-600 mb-3",children:"Request body (JSON format)"}),(0,s.jsx)("textarea",{value:L.body,onChange:e=>J({body:e.target.value}),placeholder:'{\\n "key": "value"\\n}',className:"w-full h-64 px-4 py-3 border border-gray-300 rounded-lg font-mono text-sm focus:border-pink-500 focus:ring-2 focus:ring-pink-200"})]})})]})]}),L.response&&(0,s.jsxs)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200",children:[(0,s.jsx)("div",{className:"p-4 border-b border-gray-200",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-lg font-bold text-gray-900",children:"Response"}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsxs)("span",{className:"px-3 py-1 rounded-full text-sm font-semibold ".concat(L.response.status>=200&&L.response.status<300?"bg-green-100 text-green-700":L.response.status>=400&&L.response.status<500?"bg-yellow-100 text-yellow-700":"bg-red-100 text-red-700"),children:[L.response.status," ",L.response.statusText]}),L.response.time&&(0,s.jsxs)("span",{className:"text-sm text-gray-600",children:["â±ï¸ ",L.response.time,"ms"]}),L.response.size&&(0,s.jsxs)("span",{className:"text-sm text-gray-600",children:["\uD83D\uDCE6 ",(e=L.response.size)<1024?e+" B":e<1048576?(e/1024).toFixed(2)+" KB":(e/1048576).toFixed(2)+" MB"]})]})]})}),(0,s.jsx)("div",{className:"border-b border-gray-200 px-4 flex gap-1",children:["body","headers","cookies"].map(e=>(0,s.jsx)("button",{onClick:()=>R(e),className:"px-4 py-2 font-medium text-sm capitalize ".concat(q===e?"text-pink-600 border-b-2 border-pink-600":"text-gray-600 hover:text-gray-900"),children:e},e))}),(0,s.jsx)("div",{className:"p-4",children:L.response.error?(0,s.jsx)("div",{className:"bg-red-50 border-l-4 border-red-500 p-4 rounded-lg",children:(0,s.jsx)("p",{className:"text-red-700 font-medium",children:L.response.error})}):(0,s.jsxs)(s.Fragment,{children:["body"===q&&(0,s.jsx)("div",{children:(0,s.jsx)("pre",{className:"bg-gray-900 text-green-400 p-4 rounded-lg overflow-x-auto text-sm max-h-96",children:"string"==typeof L.response.data?L.response.data:JSON.stringify(L.response.data,null,2)})}),"headers"===q&&(0,s.jsx)("div",{className:"space-y-2",children:Object.entries(L.response.headers||{}).map(e=>
1{let[t,a]=e;return(0,s.jsxs)("div",{className:"flex gap-3 p-3 bg-gray-50 rounded-lg",children:[(0,s.jsxs)("span",{className:"font-mono text-sm font-semibold text-gray-700 min-w-[200px]",children:[t,":"]}),(0,s.jsx)("span",{className:"font-mono text-sm text-gray-600",children:a})]},t)})}),"cookies"===q&&(0,s.jsx)("p",{className:"text-sm text-gray-400 text-center py-8",children:"Cookie inspection not available in browser environment"})]})})]}),U&&(0,s.jsxs)("div",{className:"mt-6 bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsx)("h2",{className:"text-lg font-bold text-gray-900",children:"Generated Code"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("select",{value:B,onChange:e=>I(e.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[(0,s.jsx)("option",{value:"javascript",children:"JavaScript (Fetch)"}),(0,s.jsx)("option",{value:"nodejs",children:"Node.js (Axios)"}),(0,s.jsx)("option",{value:"python",children:"Python (Requests)"}),(0,s.jsx)("option",{value:"curl",children:"cURL"})]}),(0,s.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(ea()),alert("Code copied to clipboard!")},className:"px-4 py-2 bg-gradient-to-r from-pink-600 to-orange-500 text-white rounded-lg font-medium hover:shadow-lg transition-all",children:"\uD83D\uDCCB Copy"})]})]}),(0,s.jsx)("pre",{className:"bg-gray-900 text-green-400 p-4 rounded-lg overflow-x-auto text-sm",children:ea()})]}),(0,s.jsx)("button",{onClick:()=>G(!U),className:"mt-4 w-full px-6 py-3 border-2 border-pink-500 text-pink-600 rounded-lg font-semibold hover:bg-pink-50 transition-all",children:U?"\uD83D\uDD3D Hide Code Generator":"\uD83D\uDCBB Generate Code"})]})]})]})]})}),g&&(0,s.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:(0,s.jsxs)("div",{className:"bg-white rounded-xl shadow-2xl max-w-md w-full p-6",children:[(0,s.jsx)("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Save to Collection"}),0===h.length?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:"Create a new collection first"}),(0,s.jsx)("input",{type:"text",value:y,onChange:e=>f(e.target.value),placeholder:"Collection name",className:"w-full px-4 py-2 border border-gray-300 rounded-lg mb-4 focus:border-pink-500 focus:ring-2 focus:ring-pink-200"}),(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("button",{onClick:W,className:"flex-1 px-4 py-2 bg-pink-600 text-white rounded-lg font-semibold hover:bg-pink-700",children:"Create Collection"}),(0,s.jsx)("button",{onClick:()=>b(!1),className:"px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50",children:"Cancel"})]})]}):(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:"Select a collection or create new"}),(0,s.jsx)("div",{className:"space-y-2 mb-4 max-h-48 overflow-y-auto",children:h.map(e=>(0,s.jsxs)("button",{onClick:()=>Z(e.id),className:"w-full text-left px-4 py-3 border border-gray-300 rounded-lg hover:border-pink-500 hover:bg-pink-50 transition-all",children:[(0,s.jsxs)("span",{className:"font-semibold",children:["\uD83D\uDCC1 ",e.name]}),(0,s.jsxs)("span",{className:"text-sm text-gray-500 ml-2",children:["(",e.requests.length," requests)"]})]},e.id))}),(0,s.jsxs)("div",{className:"border-t border-gray-200 pt-4 mt-4",children:[(0,s.jsx)("input",{type:"text",value:y,onChange:e=>f(e.target.value),placeholder:"New collection name",className:"w-full px-4 py-2 border border-gray-300 rounded-lg mb-3 focus:border-pink-500 focus:ring-2 focus:ring-pink-200"}),(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("button",{onClick:W,className:"flex-1 px-4 py-2 bg-pink-600 text-white rounded-lg font-semibold hover:bg-pink-700",children:"Create New"}),(0,s.jsx)("button",{onClick:()=>b(!1),className:"px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50",children:"Cancel"})]})]})]})]})}),E&&(0,s.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:(0,s.jsxs)("div",{className:"bg-white rounded-xl shadow-2xl max-w-3xl w-full p-6 max-h-[90vh] overflow-y-auto",children:[(0,s.jsx)("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Environment Variables"}),(0,s.jsxs)("p",{className:"text-sm text-gray-600 mb-4",children:["Use variables like ",(0,s.jsx)("code",{className:"bg-gray-100 px-2 py-1 rounded",children:"{{BASE_URL}}"})," or ",(0,s.jsx)("code",{className:"bg-gray-100 px-2 py-1 rounded",children:"{{API_KEY}}"})," in URLs, headers, and body"]}),N.map(e=>(0,s.jsxs)("div",{className:"mb-6 border border-gray-200 rounded-lg p-4",children:[(0,s.jsx)("h3",{className:"font-bold text-gray-900 mb-3",children:e.name}),(0,s.jsx)("div",{className:"space-y-2",children:e.variables.map((t,a)=>(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{type:"text",value:t.key,readOnly:!0,className:"flex-1 px-3 py-2 border border-gray-300 rounded-lg bg-gray-50 font-mono text-sm"}),(0,s.jsx)("input",{type:"text",value:t.value,onChange:t=>{k(N.map(t=>
1t.id===e.id?{...t,variables:t.variables.map((e,s)=>s===a?{...e,value:t.target.value}:e)}:t))},className:"flex-1 px-3 py-2 border border-gray-300 rounded-lg font-mono text-sm focus:border-pink-500 focus:ring-1 focus:ring-pink-200"})]},a))})]},e.id)),(0,s.jsx)("button",{onClick:()=>S(!1),className:"w-full px-4 py-2 bg-pink-600 text-white rounded-lg font-semibold hover:bg-pink-700",children:"Close"}),(0,s.jsx)(i.A,{currentSlug:"api-request-playground"})]})})]})}}},e=>{var t=t=>e(e.s=t);e.O(0,[35526,90636,46593,38792],()=>t(10044)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.