Code Snippets
Generate ready-to-use code snippets for any endpoint in your project. Right-click an endpoint or use the Copy as Code button to get a working request in your language of choice.
Supported Formats
Section titled “Supported Formats”| Format | Language | Use Case |
|---|---|---|
| cURL | Shell | Command-line testing, documentation |
| fetch | JavaScript | Browser and Node.js applications |
| axios | JavaScript | Popular HTTP client for Node.js/browser |
| Python | Python | Python requests library |
How to Use
Section titled “How to Use”From the Endpoint Tree
Section titled “From the Endpoint Tree”- Right-click an endpoint in the tree view
- Select Copy as Code
- Choose your format
- The snippet is copied to your clipboard
From the Endpoint Editor
Section titled “From the Endpoint Editor”- Open an endpoint for editing
- Click the Copy as Code dropdown in the toolbar
- Select a format
- The snippet is copied to your clipboard
Generated Snippets
Section titled “Generated Snippets”Each snippet includes:
- The correct HTTP method
- The full URL with your server’s base URL and the endpoint path
Content-Type: application/jsonheader for POST/PUT/PATCH requests- A request body template (simplified from your mock response, with template variables stripped)
Example: cURL
Section titled “Example: cURL”curl -X GET http://localhost:3001/api/usersExample: fetch
Section titled “Example: fetch”fetch('http://localhost:3001/api/users') .then(response => response.json()) .then(data => console.log(data));Example: axios
Section titled “Example: axios”axios.get('http://localhost:3001/api/users') .then(response => console.log(response.data));Example: Python
Section titled “Example: Python”import requests
response = requests.get('http://localhost:3001/api/users')print(response.json())- Quick sharing: Copy a cURL snippet to share an endpoint call with a teammate
- Documentation: Paste generated snippets into your API docs as usage examples
- Request bodies: For POST/PUT/PATCH endpoints, the snippet includes a body template based on your mock response schema