API Playground
The API Playground lets you test CTWise API endpoints directly from your browser without writing any code. It's the fastest way to explore the API and verify your integration logic.
Accessing the Playground​
- Log in to your dashboard
- Select CTWise from the product selector
- Click API Playground in the navigation menu
Playground Features​
| Feature | Description |
|---|---|
| Endpoint Selection | Choose from all available API endpoints |
| Request Builder | Build requests with an intuitive form |
| Live Response | See real responses instantly |
| cURL Export | Copy ready-to-use cURL commands |
| History | View your recent requests |
Making Your First Request​
Step 1: Select an Endpoint​
Choose an endpoint from the dropdown menu:
- Search Rules (
POST /v1/search) - Search regulatory rules - Semantic Search (
POST /v1/semantic-search) - AI-powered semantic search - List Sources (
GET /v1/catalog/sources) - List available content sources
Step 2: Configure Parameters​
Based on the selected endpoint, fill in the required parameters:
For Search Rules:
| Parameter | Required | Description |
|---|---|---|
query | Yes | Your search query |
sources | No | Filter by source (FDA, EMA, ICH) |
limit | No | Max results (default: 10) |
Step 3: Send Request​
Click Send Request to execute the API call.
Step 4: Review Response​
The response panel shows:
- Status Code: HTTP status (200, 400, 401, etc.)
- Response Time: How long the request took
- Headers: Response headers
- Body: JSON response data
Example: Searching Regulatory Rules​
Let's search for FDA clinical trial requirements:
1. Select Endpoint​
Choose POST /v1/search
2. Enter Parameters​
{
"query": "FDA clinical trial phase requirements",
"sources": ["fda"],
"limit": 5
}
3. Send and View Results​
Click Send Request. You'll see results like:
{
"results": [
{
"rule_id": "fda-clin-001",
"title": "Clinical Trial Phases Overview",
"content": "The FDA requires clinical trials to progress through...",
"source": "FDA",
"relevance_score": 0.95
},
...
],
"total": 42,
"query_time_ms": 125
}
Example: Semantic Search​
Semantic search uses AI to understand the meaning of your query:
Parameters​
{
"query": "What are the requirements for drug labeling in Europe?",
"top_k": 10
}
Response​
The semantic search returns results ranked by semantic relevance, even if the exact words don't match.
Copying cURL Commands​
To use the same request outside the Playground:
- Configure your request
- Click Copy as cURL
- Paste into your terminal
Example cURL command:
curl -X POST "https://api.ctwise.ai/v1/search" \
-H "x-api-key: ctw_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "FDA clinical trial requirements",
"sources": ["fda"],
"limit": 5
}'
Understanding Error Responses​
400 Bad Request​
{
"error": "Bad Request",
"message": "Missing required parameter: query",
"code": "MISSING_PARAMETER"
}
Solution: Check that all required parameters are provided.
401 Unauthorized​
{
"error": "Unauthorized",
"message": "Invalid API key",
"code": "INVALID_API_KEY"
}
Solution: Verify your API key is correct.
429 Too Many Requests​
{
"error": "Too Many Requests",
"message": "Rate limit exceeded",
"code": "RATE_LIMIT_EXCEEDED"
}
Solution: Wait and retry, or upgrade your tier for higher limits.
Tips for Using the Playground​
- Start Simple: Begin with basic queries before adding filters
- Use the Examples: Click "Load Example" for pre-configured requests
- Check Response Time: Monitor latency to optimize your queries
- Export for Code: Use the cURL export to build your integration
- Test Edge Cases: Try empty queries, special characters, etc.
Available Endpoints​
| Endpoint | Method | Description |
|---|---|---|
/v1/search | POST | Search regulatory rules by keyword |
/v1/semantic-search | POST | AI-powered semantic search |
/v1/catalog/sources | GET | List available content sources |
/v1/rules/{id} | GET | Get a specific rule by ID |
/v1/patterns | GET | List regulatory patterns |
For detailed endpoint documentation, see the API Reference.
Playground vs Production​
The Playground uses your real API key and counts against your quota. However:
- Requests are made from your browser
- API key is automatically included
- Rate limits apply as normal