Code samples in 17 languages
Ready-to-run requests in cURL, JavaScript, Python, Go, Java, C#, PHP, Ruby, PowerShell, HTTPie, Kotlin, Swift, Rust and more, generated from your OpenAPI spec.
Every endpoint shows a ready-to-run request. By default readers get 8 tabs: cURL, JavaScript, Python, Go, Java, C#, PHP and Ruby. Editors can add more tabs, remove tabs and change their order in the macro's Code languages option (under More options in the dialog). Apifolio remembers, in the reader's browser, the language they picked last.
| Tab | What it generates |
|---|---|
| cURL | curl for bash and other POSIX shells |
| JavaScript | fetch |
| Python | requests |
| Go | net/http |
| Java | java.net.http.HttpClient |
| C# | HttpClient |
| PHP | the cURL extension (curl_init) |
| Ruby | Net::HTTP |
| PowerShell | Invoke-RestMethod |
| cURL (cmd) | curl for the Windows command prompt |
| HTTPie | the http command |
| HTTP | the raw HTTP/1.1 request |
| Node (axios) | axios |
| Python (httpx) | httpx |
| Kotlin | OkHttp |
| Swift | URLSession |
| Rust | reqwest |
What goes into a sample
Samples are built from the spec and from what the reader picked on the page:
- the server chosen in the top bar, and the values of its variables (the Variables button in the top bar: a dropdown for listed values, a text field otherwise, URL-encoded in the samples). Servers declared on a path or an operation are used for that endpoint, unless the reader picks a server;
- path, query, header and cookie parameters, serialized as the spec says (
styleandexplode, includingdeepObject,pipeDelimitedandspaceDelimited); - the request body of the selected example, or of the
oneOfvariant picked in the schema, or generated from the schema: JSON, XML, form, multipart and binary bodies; - the credentials of the security scheme, as placeholders such as
YOUR_TOKEN,YOUR_API_KEYorUSERNAME:PASSWORD. When an endpoint accepts several schemes ("Any one of these works"), pick one under Authorization or in the Auth list above the code: every language follows.
Required parameters are always included. Optional ones appear when the spec gives an example or a default, to keep samples short.
For a webhook or a callback, the sample is an example delivery to your endpoint (https://your-endpoint.example), without the API's own credentials.
For OAuth 2.0 and OpenID Connect, the Authorization section of an endpoint and the Overview also show a Get a token cURL request for the flows the API uses, with placeholders for your credentials.
Fill in your own values
Edit request, below the language tabs, lets readers fill in parameters, the body, the server and credentials. Every sample and Copy for AI follow, and nothing is sent. See Edit request.
Your own samples
If an operation has x-codeSamples (or x-code-samples), those samples are shown first, with their labels.
Rovo
The Apifolio API Expert agent in Rovo generates the same code in any of the 17 languages. See AI features.
Why there is no "Try it out" button
Sending live requests from Confluence would send data, and often credentials, to servers outside Atlassian, and Apifolio is built never to do that. Fill in the request with Edit request, copy it, and run it in your terminal or API client. See What Apifolio does not do, and why.