> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-d5730eee.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# API Playground

> Run a local mock server to test X API v2 endpoints during development without consuming API credits, plus example requests and response payloads.

The [API Playground](https://github.com/xdevplatform/playground) is a local mock server that simulates the full X API v2. Test endpoints, build prototypes, and explore the API without consuming real API credits.

<Card title="GitHub repository" icon="github" href="https://github.com/xdevplatform/playground">
  Source code, releases, and full documentation.
</Card>

***

## Features

<CardGroup cols={2}>
  <Card title="Full API v2 compatibility" icon="check">
    All endpoints supported with request validation via OpenAPI specs and realistic error responses.
  </Card>

  <Card title="Interactive web UI" icon="browser">
    Visual endpoint explorer at `http://localhost:8080/playground` for testing in the browser.
  </Card>

  <Card title="No credits needed" icon="coins">
    Everything runs locally with mock data — no API keys or billing required.
  </Card>

  <Card title="Stateful operations" icon="database">
    In-memory state with optional file persistence. Create posts, then look them up.
  </Card>
</CardGroup>

***

## Installation

Requires Go 1.21+. Install from source or download a pre-built binary from [releases](https://github.com/xdevplatform/playground/releases).

<Tabs>
  <Tab title="Go install">
    ```bash theme={null}
    go install github.com/xdevplatform/playground/cmd/playground@latest
    playground start
    ```
  </Tab>

  <Tab title="Build from source">
    ```bash theme={null}
    git clone https://github.com/xdevplatform/playground.git
    cd playground
    go build -o playground ./cmd/playground
    ./playground start
    ```
  </Tab>
</Tabs>

The server starts at `http://localhost:8080` by default.

***

## Quick start

Make requests just like you would to the real API — use `test_token` as your bearer token:

```bash theme={null}
# Look up a user
curl -H "Authorization: Bearer test_token" \
  http://localhost:8080/2/users/me

# Create a post
curl -X POST -H "Authorization: Bearer test_token" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello from the playground!"}' \
  http://localhost:8080/2/tweets

# Search posts
curl -H "Authorization: Bearer test_token" \
  "http://localhost:8080/2/tweets/search/recent?query=hello"
```

Open `http://localhost:8080/playground` in your browser for the interactive UI.

***

## What's included

| Feature                | Description                                     |
| :--------------------- | :---------------------------------------------- |
| **Request validation** | Validates requests against the OpenAPI spec     |
| **Realistic errors**   | Returns proper error codes and messages         |
| **Streaming support**  | Simulated streaming endpoints                   |
| **Rate limiting**      | Configurable rate limit simulation              |
| **CORS support**       | Works with browser-based applications           |
| **Usage tracking**     | Simulated billing and credit tracking endpoints |
| **State persistence**  | Optional file persistence in `~/.playground/`   |

***

## Related

<CardGroup cols={2}>
  <Card title="xurl" icon="terminal" href="/tools/xurl">
    CLI tool for the real X API with built-in authentication.
  </Card>

  <Card title="Make your first request" icon="rocket" href="/make-your-first-request">
    Ready for the real API? Make your first request.
  </Card>
</CardGroup>
