API Reference

Complete reference for the TryAPI REST API.

Last updated: December 10, 2024

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header:

Authorization: Bearer your_api_key

Getting Your API Key

You can generate API keys from your dashboard settings. Keep your API keys secure and never expose them in client-side code.

Playgrounds API

List Playgrounds

GET /api/playgrounds

Returns a paginated list of your playgrounds.

Query Parameters:

  • page (optional): Page number, defaults to 1
  • limit (optional): Items per page, defaults to 20
  • search (optional): Search playgrounds by name

Get Playground

GET /api/playgrounds/:id

Retrieves a single playground by ID.

Create Playground

POST /api/playgrounds

Creates a new playground.

Request Body:

{
  "name": "My API Playground",
  "curl_command": "curl https://api.example.com/users",
  "is_public": false,
  "theme": "dark",
  "languages": ["python", "javascript", "curl"]
}

Update Playground

PATCH /api/playgrounds/:id

Updates an existing playground.

Delete Playground

DELETE /api/playgrounds/:id

Permanently deletes a playground.

Tests API

Execute Test

POST /api/tests/execute

Executes an API request through our proxy.

Request Body:

{
  "method": "POST",
  "url": "https://api.example.com/users",
  "headers": {
    "Authorization": "Bearer token",
    "Content-Type": "application/json"
  },
  "body": {
    "name": "Test User"
  }
}

List Test History

GET /api/tests?playgroundId=xxx

Returns the test history for a playground.

Get Test Result

GET /api/tests/:id

Retrieves a specific test result.

Code Generation

Generate Code

POST /api/generate-code

Generates code snippets from a parsed cURL command.

Request Body:

{
  "parsed": {
    "method": "GET",
    "url": "https://api.example.com/users",
    "headers": {}
  },
  "language": "python"
}

Supported Languages: python, javascript, curl, go, ruby, php, java, csharp, rust

cURL Parsing

Parse cURL

POST /api/parse-curl

Parses a cURL command into a structured format.

Request Body:

{
  "curl": "curl -X POST https://api.example.com/users -H 'Authorization: Bearer token'"
}

Rate Limits

API rate limits depend on your plan:

  • Starter: 1,000 requests/day
  • Pro: 10,000 requests/day
  • Enterprise: Custom limits

Rate limit headers are included in all responses:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1702252800

Errors

The API uses standard HTTP status codes. Error responses include a JSON body:

{
  "error": {
    "code": "invalid_request",
    "message": "The curl_command field is required"
  }
}

Common Error Codes:

  • 400 - Bad Request (invalid parameters)
  • 401 - Unauthorized (missing or invalid API key)
  • 403 - Forbidden (insufficient permissions)
  • 404 - Not Found (resource doesn't exist)
  • 429 - Too Many Requests (rate limit exceeded)
  • 500 - Internal Server Error

SDKs

Official SDKs are available for popular languages. See our SDK documentation for installation and usage instructions.