Files
open-web-agent-rs/docs/api.md
geoffsee 7e0b25da59 Add comprehensive documentation and finalize project license
This commit introduces detailed documentation files, including installation, configuration, API, agents, and an index. It also updates the README with new sections and registers the MIT license for the project. These changes aim to improve clarity and ease of use for developers and contributors.
2025-05-23 10:59:17 -04:00

2.6 KiB

API Documentation

Authentication

All API endpoints require authentication using a session token. The token should be included in the Authorization header as a Bearer token:

Authorization: Bearer <session_token>

For more information on authentication and token generation, see the Authentication documentation.

Endpoints

Health Check

GET /health

Returns a simple "ok" response to indicate that the server is running.

Response:

200 OK
ok

Create Stream Resource

POST /api/webhooks

Creates a new stream resource for an agent.

Request Body:

{
  "resource": "web-search",
  "input": "What is the capital of France?"
}
Field Type Description
resource string The type of agent to use (e.g., "web-search", "news-search", "image-generator", "finance-query", "web-scrape")
input string The input query or prompt for the agent

Response:

{
  "stream_id": "abc123"
}
Field Type Description
stream_id string The ID of the created stream resource

Consume Stream Resource

GET /webhooks/:stream_id

Consumes a stream resource, returning the agent's response as a server-sent event stream.

Path Parameters:

  • stream_id: The ID of the stream resource to consume

Response: Server-sent event stream with the agent's response.

Available Agents

The following agent types are available for use with the resource field in the Create Stream Resource endpoint:

Agent Type Description
web-search Performs web searches using SearxNG
news-search Searches for news articles
image-generator Generates images based on text prompts
finance-query Provides financial information
web-scrape Scrapes content from web pages

Error Responses

Status Code Description
400 Bad Request - The request was malformed or missing required fields
401 Unauthorized - Authentication failed or token is invalid
404 Not Found - The requested resource was not found
500 Internal Server Error - An unexpected error occurred

Example Usage

Creating a Stream Resource

curl -X POST https://your-server.com/api/webhooks \
  -H "Authorization: Bearer <session_token>" \
  -H "Content-Type: application/json" \
  -d '{"resource": "web-search", "input": "What is the capital of France?"}'

Consuming a Stream Resource

curl https://your-server.com/webhooks/abc123 \
  -H "Authorization: Bearer <session_token>"