API endpoint
2 min
api endpoint docid\ jwrgiytgiu8c 7ml3hna8 blocks render interactive api documentation, including request parameters, code examples, and response samples syntax you can add this component using either markdown or mdx syntax \ apimethodv2 (json configuration with name, method, url, request, examples, results) \ \<apimethodv2> (json configuration with name, method, url, request, examples, results) \</apimethodv2> the json configuration supports the following parameter groups pathparameters queryparameters headerparameters bodydataparameters formdataparameters you can also include request examples and response samples in multiple languages when used inside a two column layout, api endpoint blocks are rendered in the right column mdx example the following example creates an endpoint for retrieving a user, including request parameters, multiple code examples, and response samples \<apimethodv2> { "name" "get user", "method" "get", "url" "https //api example com/users/{id}", "description" "retrieve a user by their unique id ", "tab" "examples", "examples" { "languages" \[ { "id" "js example", "language" "javascript", "code" "const res = await fetch('https //api example com/users/usr abc123', {\n headers { 'authorization' 'bearer sk live xxx' }\n})\nconst user = await res json()", "customlabel" "" }, { "id" "curl example", "language" "bash", "code" "curl https //api example com/users/usr abc123 \\\\\n h 'authorization bearer sk live xxx'", "customlabel" "" } ], "selectedlanguageid" "js example" }, "results" { "languages" \[ { "id" "res 200", "language" "200", "code" "{\n \\"id\\" \\"usr abc123\\",\n \\"name\\" \\"jane doe\\",\n \\"email\\" \\"jane\@example com\\",\n \\"role\\" \\"admin\\"\n}", "customlabel" "" }, { "id" "res 404", "language" "404", "code" "{\n \\"error\\" \\"not found\\",\n \\"message\\" \\"user does not exist\\"\n}", "customlabel" "" } ], "selectedlanguageid" "res 200" }, "request" { "pathparameters" \[ { "name" "id", "kind" "required", "type" "string", "description" "user id (e g usr abc123)" } ], "queryparameters" \[ { "name" "include", "kind" "optional", "type" "string", "description" "comma separated relations to include" } ], "headerparameters" \[ { "name" "authorization", "kind" "required", "type" "string", "description" "bearer token" } ], "bodydataparameters" \[], "formdataparameters" \[] }, "currentnewparameter" { "label" "path parameter", "value" "pathparameters" }, "hastryitout" false } \</apimethodv2>
Have a question?
Our super-smart AI, knowledgeable support team and an awesome community will get you an answer in a flash.
To ask a question or participate in discussions, you'll need to authenticate first.