API Overview
Complete reference for the Browserman REST API.
Base URL
https://api.browserman.runAll API requests should be made to this base URL.
Authentication
Authenticate using API keys in the Authorization header:
Authorization: Bearer YOUR_API_KEYExample:
curl https://api.browserman.run/api/platforms \
-H "Authorization: Bearer sk_live_xxxxxxxxxxxx"Getting API Keys
- Visit app.browserman.run
- Navigate to Settings > API Keys
- Click Generate New Key
- Store the key securely (shown only once)
Request Format
Headers
All POST/PUT requests should include:
Content-Type: application/json
Authorization: Bearer YOUR_API_KEYBody
Request bodies should be valid JSON:
{
"platform": "twitter",
"tool": "createTweet",
"accountName": "my-account",
"parameters": {
"text": "Hello World!"
}
}Response Format
Success Response
{
"success": true,
"data": {
"taskId": "task_abc123",
"state": "pending",
"createdAt": "2024-01-15T10:30:00Z"
}
}Error Response
{
"success": false,
"error": {
"code": "ACCOUNT_NOT_FOUND",
"message": "Account 'my-account' not found for platform 'twitter'",
"details": {}
}
}Core Endpoints
Platforms
Get information about supported platforms and their tools.
# List all platforms
GET /api/platforms
# Get platform schema
GET /api/platforms/schema
# Get specific platform details
GET /api/platforms/:platformIdAccounts
Manage your connected social media accounts.
# List all accounts
GET /api/accounts
# Get account details
GET /api/accounts/:accountId
# Filter by platform
GET /api/accounts?platform=twitter
# Create account (OAuth)
POST /api/accounts/oauth/authorize
# Delete account
DELETE /api/accounts/:accountIdTasks
Create and manage automation tasks.
# Create a task
POST /api/tasks
# Get task status
GET /api/tasks/:taskId
# List tasks
GET /api/tasks
# Cancel task
DELETE /api/tasks/:taskIdRate Limits
API rate limits (per API key):
- Free tier: 100 requests/hour, 1,000 requests/day
- Pro tier: 1,000 requests/hour, 10,000 requests/day
- Enterprise: Custom limits
Rate limit headers in responses:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1642248000Error Codes
Common error codes you might encounter:
| Code | HTTP Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | Invalid or missing API key |
FORBIDDEN | 403 | Insufficient permissions |
NOT_FOUND | 404 | Resource not found |
RATE_LIMITED | 429 | Too many requests |
ACCOUNT_NOT_FOUND | 400 | Account doesn't exist |
INVALID_PARAMETERS | 400 | Invalid request parameters |
PLATFORM_ERROR | 502 | Platform-specific error |
TIMEOUT | 504 | Task execution timeout |
INTERNAL_ERROR | 500 | Server error |
Common Patterns
Creating a Task
Request:
curl -X POST https://api.browserman.run/api/tasks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"platform": "twitter",
"tool": "createTweet",
"accountName": "my-account",
"parameters": {
"text": "Hello from Browserman!"
}
}'Response:
{
"success": true,
"data": {
"taskId": "task_abc123",
"state": "pending",
"createdAt": "2024-01-15T10:30:00Z"
}
}Checking Task Status
Request:
curl https://api.browserman.run/api/tasks/task_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"Response:
{
"success": true,
"data": {
"taskId": "task_abc123",
"state": "completed",
"result": {
"success": true,
"output": "Tweet posted successfully"
},
"createdAt": "2024-01-15T10:30:00Z",
"completedAt": "2024-01-15T10:30:15Z"
}
}Listing Accounts
Request:
curl https://api.browserman.run/api/accounts \
-H "Authorization: Bearer YOUR_API_KEY"Response:
{
"success": true,
"data": {
"accounts": [
{
"id": "acc_123",
"name": "my-twitter",
"platform": "twitter",
"status": "active",
"createdAt": "2024-01-10T08:00:00Z"
},
{
"id": "acc_124",
"name": "my-xueqiu",
"platform": "xueqiu",
"status": "active",
"createdAt": "2024-01-11T09:00:00Z"
}
],
"total": 2
}
}Pagination
List endpoints support pagination:
GET /api/tasks?page=1&limit=20Parameters:
page- Page number (default: 1)limit- Items per page (default: 20, max: 100)
Response:
{
"success": true,
"data": {
"items": [...],
"pagination": {
"page": 1,
"limit": 20,
"total": 150,
"pages": 8
}
}
}Filtering
Many list endpoints support filtering:
# Filter accounts by platform
GET /api/accounts?platform=twitter
# Filter tasks by state
GET /api/tasks?state=completed
# Filter tasks by date
GET /api/tasks?from=2024-01-01&to=2024-01-31Sorting
Control sorting with query parameters:
# Sort by creation date (newest first)
GET /api/tasks?sort=-createdAt
# Sort by name (alphabetical)
GET /api/accounts?sort=namePrefix with - for descending order.
Webhooks
Configure webhooks to receive task completion notifications:
POST /api/webhooksRequest:
{
"url": "https://your-server.com/webhook",
"events": ["task.completed", "task.failed"],
"secret": "your-webhook-secret"
}Webhook Payload:
{
"event": "task.completed",
"taskId": "task_abc123",
"timestamp": "2024-01-15T10:30:15Z",
"data": {
"state": "completed",
"result": {...}
}
}OpenAPI Schema
Get the complete OpenAPI schema:
curl https://api.browserman.run/api/platforms/schemaUse this to:
- Generate API clients
- Validate requests
- Explore available tools
- Build integrations
SDK and Client Libraries
JavaScript/TypeScript
import { BrowsermanClient } from '@browserman/client';
const client = new BrowsermanClient({
apiKey: 'YOUR_API_KEY'
});
// Post a tweet
const task = await client.twitter.createTweet({
accountName: 'my-account',
text: 'Hello World!'
});
// Check status
const status = await client.tasks.get(task.taskId);Python
from browserman import BrowsermanClient
client = BrowsermanClient(api_key='YOUR_API_KEY')
# Post a tweet
task = client.twitter.create_tweet(
account_name='my-account',
text='Hello World!'
)
# Check status
status = client.tasks.get(task.task_id)cURL Examples
See platform-specific API references for cURL examples.
Best Practices
1. Handle Rate Limits
Check rate limit headers and back off when needed:
if (response.headers['x-ratelimit-remaining'] < 10) {
await sleep(60000); // Wait 1 minute
}2. Retry Failed Requests
Implement exponential backoff:
async function retryRequest(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;
await sleep(Math.pow(2, i) * 1000);
}
}
}3. Poll Task Status
Check task status periodically:
async function waitForTask(taskId, timeout = 300000) {
const start = Date.now();
while (Date.now() - start < timeout) {
const status = await getTaskStatus(taskId);
if (status.state === 'completed') {
return status.result;
} else if (status.state === 'failed') {
throw new Error(status.error);
}
await sleep(5000); // Check every 5 seconds
}
throw new Error('Task timeout');
}4. Validate Parameters
Use the OpenAPI schema to validate requests before sending:
import Ajv from 'ajv';
const ajv = new Ajv();
const schema = await fetchSchema();
const validate = ajv.compile(schema);
if (!validate(requestData)) {
console.error(validate.errors);
}5. Secure API Keys
- Use environment variables
- Never commit to version control
- Rotate regularly
- Create separate keys for different environments
API Versioning
The API is currently at version 1. Future versions will be indicated in the URL:
https://api.browserman.run/v2/...Current version (v1) is the default and doesn't require version in URL.
Support
- Documentation: Browse these guides
- API Status: Check dashboard for status updates
- Support: Contact via dashboard
- Community: Access community forum through dashboard
