A standalone local HTTP server that simulates the X (Twitter) API v2 for testing and development without consuming API credits.
- Complete API compatibility with X API v2 endpoints
- Stateful operations with in-memory state management
- Optional file-based state persistence across server restarts
- Interactive web UI for exploring and testing endpoints
- Request validation against OpenAPI specifications
- Error responses matching real API formats
- Configurable rate limiting simulation
- Server-Sent Events (SSE) streaming support
- CORS support for web applications
- OpenAPI-driven endpoint discovery and handling
- Go 1.21 or later - Download Go
# Clone the repository
git clone https://github.com/xdevplatform/playground.git
cd playground
# Build the binary
go build -o playground ./cmd/playground
# Make it executable (optional)
chmod +x playground
# Move to PATH (optional, for global access)
sudo mv playground /usr/local/bin/go install github.com/xdevplatform/playground/cmd/playground@latestThis will install the playground binary to $GOPATH/bin (or $HOME/go/bin by default).
Make sure $GOPATH/bin is in your PATH:
export PATH=$PATH:$(go env GOPATH)/binCheck the Releases page for pre-built binaries for your platform.
playground --helpYou should see the playground command help output.
-
Start the server:
playground start
-
Access the Web UI: Open http://localhost:8080/playground in your browser
-
Make API requests:
curl -H "Authorization: Bearer test_token" http://localhost:8080/2/users/me
playground start- Start the playground server- Flags:
--port/-p(default: 8080) - Port to run the server on--host(default: localhost) - Host to bind the server to--refresh- Force refresh of OpenAPI spec cache
- Flags:
playground status- Check if a server is runningplayground refresh- Refresh OpenAPI spec cache
Start on custom port:
playground start --port 3000 --host 0.0.0.0Start with OpenAPI cache refresh:
playground start --refreshConfiguration files are stored in ~/.playground/:
config.json- Playground configuration (optional, uses embedded defaults if not present)state.json- Persistent state (if persistence enabled)examples/- Custom example responses (optional).playground-openapi-cache.json- Cached OpenAPI spec
The playground provides several management endpoints (not part of X API):
GET /health- Server health and statisticsGET /rate-limits- Rate limit configuration and statusGET /config- View current configurationPUT /config/update- Update configuration (temporary, lost on restart)POST /config/save- Save configuration to filePOST /state/reset- Reset state to initial seed dataGET /state/export- Export state as JSONPOST /state/import- Import state from JSONPOST /state/save- Manually save state (if persistence enabled)DELETE /state- Delete all stateGET /endpoints- List all available endpoints
For detailed documentation, see DOCUMENTATION.md.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT