Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 88 additions & 6 deletions api-playground/overview.mdx
Original file line number Diff line number Diff line change
@@ -1,15 +1,97 @@
---
title: 'Interactive Playground'
description: 'Enable users to interact with your API'
title: 'Interactive API Playground'
description: 'Enable users to interact with your API endpoints and test requests directly in your documentation'
openapi: 'GET /plants/{id}'
hideApiMarker: true
icon: 'play'
---

The API playground is an interactive environment to make requests and preview an API endpoint.
## Overview

The API playground provides an interactive environment where users can test API endpoints directly within your documentation. It allows users to:
- Make live API requests
- Test different parameters and configurations
- See real responses from your API
- Copy generated code snippets in multiple languages

## Features

### Interactive Request Testing
Users can modify request parameters, headers, and body content to test different API scenarios. The playground provides immediate feedback with actual API responses.

### Code Generation
The playground automatically generates code snippets in multiple programming languages based on the configured request, making it easy for developers to implement API calls in their preferred language.

### Authentication Support
Built-in support for various authentication methods including:
- API Keys
- Bearer Tokens
- Basic Auth
- OAuth 2.0

## Implementation Options

### OpenAPI Integration
<Info>
Autogenerating API pages with OpenAPI will automatically generate API
playground. Read more about using OpenAPI with Mintlify
[here](/api-playground/openapi).
When you use OpenAPI to define your endpoints, Mintlify automatically generates API playgrounds for each endpoint. This ensures consistency between your API specification and interactive documentation. Learn more about OpenAPI integration [here](/api-playground/openapi).
</Info>

### Manual Configuration
For cases where you prefer manual configuration, you can specify endpoint details directly in your MDX files. This gives you full control over the playground's appearance and behavior.

## Example Setup

Here's a basic example of how to set up an API playground for an endpoint:

```markdown
---
title: 'Get User'
api: 'GET /api/users/{id}'
---
```

### Parameters Configuration
Use the ParamField component to define endpoint parameters:

```jsx
<ParamField path="id" type="string" required>
The unique identifier of the user
</ParamField>
```

## Customization

The API playground supports several customization options:

### Response Display
Control how responses are displayed:
- Pretty-printed JSON
- Raw response
- Status code highlighting

### Code Examples
Configure which programming languages are shown in code examples:
- Choose default language
- Customize language order
- Add or remove supported languages

## Best Practices

To create effective API playgrounds:

1. Provide clear parameter descriptions
2. Include example values
3. Document expected responses
4. Add error handling examples
5. Use realistic sample data

## Related Resources

<CardGroup cols={2}>
<Card title="OpenAPI Integration" icon="book" href="/api-playground/openapi">
Learn how to automatically generate API playgrounds from your OpenAPI spec
</Card>
<Card title="Authentication" icon="lock" href="/api-playground/mdx/authentication">
Configure authentication for your API playground
</Card>
</CardGroup>
Loading
Loading