The Dyad HTTP REST API allows you to access and control Dyad's functionality through standard HTTP requests. This means you can:
- Build web applications that use Dyad
- Create command-line tools
- Integrate Dyad with other software
- Access Dyad from any programming language
-
Dyad Desktop must be running
- Download from: https://dyad.sh
- The HTTP API starts automatically when Dyad launches
-
API is accessible at:
http://localhost:3000
Check if the API is working:
curl http://localhost:3000/api/healthOpen in your web browser:
http://localhost:3000/api/health
{
"success": true,
"data": {
"status": "ok",
"version": "0.22.0-beta.1",
"timestamp": "2025-01-12T10:30:00.000Z",
"uptime": 300
}
}If you see this, the API is working! π
Request:
curl http://localhost:3000/api/appsResponse:
{
"success": true,
"data": {
"apps": [
{
"id": 1,
"name": "My App",
"path": "my-app",
"description": "My first app",
"createdAt": "2025-01-12T10:00:00.000Z"
}
],
"total": 1
}
}Request:
curl http://localhost:3000/api/apps/1Request:
curl -X POST http://localhost:3000/api/apps/1/chatsResponse:
{
"success": true,
"data": {
"id": 5,
"title": "",
"messages": [],
"initialCommitHash": null
}
}Request:
curl -X POST http://localhost:3000/api/chats/5/messages \
-H "Content-Type: application/json" \
-d '{
"content": "Create a todo list component",
"role": "user"
}'Request:
curl http://localhost:3000/api/chats/5/messagesWe've included a fully functional web interface!
cd examples/web-app
python3 -m http.server 8080Then open: http://localhost:8080
npm install -g http-server
cd examples/web-app
http-server -p 8080Then open: http://localhost:8080
- β Lists all your applications
- β Shows chats for each app
- β Creates new chats
- β Deletes chats
- β Shows connection status
- β Auto-refreshes every 10 seconds
The web app has a beautiful gradient interface with:
- Purple gradient header
- Application cards in a grid layout
- Chat list with management buttons
- Real-time status indicator
- Responsive design
We've included a test script that exercises all endpoints:
node examples/test-api.jsThis will:
- Check API health
- List all applications
- Create a test chat
- Add a message
- Delete the test chat
- Test error handling
const BASE_URL = "http://localhost:3000";
// Fetch all apps
async function getApps() {
const response = await fetch(`${BASE_URL}/api/apps`);
const data = await response.json();
return data.data.apps;
}
// Create a chat
async function createChat(appId) {
const response = await fetch(`${BASE_URL}/api/apps/${appId}/chats`, {
method: "POST",
headers: { "Content-Type": "application/json" },
});
const data = await response.json();
return data.data;
}
// Usage
const apps = await getApps();
console.log("Apps:", apps);
const chat = await createChat(1);
console.log("Created chat:", chat);import requests
import json
BASE_URL = 'http://localhost:3000'
# Fetch all apps
def get_apps():
response = requests.get(f'{BASE_URL}/api/apps')
data = response.json()
return data['data']['apps']
# Create a chat
def create_chat(app_id):
response = requests.post(f'{BASE_URL}/api/apps/{app_id}/chats')
data = response.json()
return data['data']
# Usage
apps = get_apps()
print('Apps:', apps)
chat = create_chat(1)
print('Created chat:', chat)# Get all apps
curl http://localhost:3000/api/apps
# Create a chat
curl -X POST http://localhost:3000/api/apps/1/chats
# Send a message
curl -X POST http://localhost:3000/api/chats/1/messages \
-H "Content-Type: application/json" \
-d '{"content": "Hello!", "role": "user"}'
# Get chat messages
curl http://localhost:3000/api/chats/1/messages
# Delete a chat
curl -X DELETE http://localhost:3000/api/chats/1For the complete list of all endpoints, request/response formats, and error handling, see:
π docs/HTTP_API.md
This includes:
- All 15 API endpoints
- Request/response examples
- Error codes and handling
- Authentication options
- CORS configuration
- Troubleshooting guide
Problem: Can't reach the API at http://localhost:3000
Solution:
- Make sure Dyad Desktop is running
- Check if another application is using port 3000
- Look at Dyad logs for errors
Problem: API returns empty app list
Solution:
- Create at least one app in Dyad Desktop first
- The API accesses the same data as the desktop app
Problem: Web interface can't connect to API
Solution:
- Check if Dyad Desktop is running
- Try accessing http://localhost:3000/api/health directly
- Make sure you're running the web app through a local server (not opening HTML directly)
Problem: Browser blocks API requests
Solution:
- Run the web app through a local server (python or http-server)
- Don't open the HTML file directly in the browser
By default:
- API only accepts connections from
localhost - No authentication required for localhost
- CORS enabled for localhost origins only
For production deployments:
- Enable JWT authentication
- Configure allowed origins
- Use HTTPS
- Add rate limiting
See docs/HTTP_API.md for security configuration.
-
Read the full documentation:
- docs/HTTP_API.md - Complete API reference
-
Try the examples:
examples/web-app/- Web interfaceexamples/test-api.js- Test script
-
Build something!
- Create a CLI tool
- Build a web dashboard
- Integrate with your workflow
- Documentation:
docs/HTTP_API.md - GitHub Issues: https://github.com/dyad-sh/dyad/issues
- Website: https://dyad.sh
β
API runs automatically on http://localhost:3000
β
15 endpoints for apps, chats, and messages
β
RESTful design with JSON responses
β
Works with any programming language
β
Example web app included
β
Comprehensive documentation
Start building with Dyad today! π