OpenHands API 使用指南:构建智能化开发体验

This document provides a detailed description of all the server-side APIs available in the OpenHands project. Each API is categorized by its respective route file and includes information about the endpoint, HTTP method, and functionality.


General Endpoints

EndpointMethodDescriptionResponse
/healthGETA simple health check endpoint.200 OK: Returns the string "OK".

Conversation API

EndpointMethodDescriptionResponse
/api/conversations/{conversation_id}/configGETRetrieves the runtime configuration.200 OK: JSON object with runtime_id and session_id.
/api/conversations/{conversation_id}/vscode-urlGETRetrieves the VSCode URL.200 OK: JSON object with vscode_url.
/api/conversations/{conversation_id}/web-hostsGETRetrieves the runtime hosts.200 OK: JSON object with hosts.

Feedback API

EndpointMethodDescriptionResponse
/api/conversations/{conversation_id}/submit-feedbackPOSTSubmits user feedback.200 OK: JSON object with stored feedback data.

File Management API

EndpointMethodDescriptionResponse
/api/conversations/{conversation_id}/list-filesGETLists files in the runtime.200 OK: JSON array of file names.
/api/conversations/{conversation_id}/select-fileGETRetrieves file content.200 OK: JSON object with file content.
/api/conversations/{conversation_id}/upload-filesPOSTUploads files to the workspace.200 OK: JSON object with upload details.
/api/conversations/{conversation_id}/save-filePOSTSaves a file to the runtime.200 OK: Success message.
/api/conversations/{conversation_id}/zip-directoryGETCompresses the workspace.200 OK: Returns the ZIP file.

GitHub API

EndpointMethodDescriptionResponse
/api/github/repositoriesGETRetrieves GitHub repositories.200 OK: JSON array of repositories.
/api/github/userGETRetrieves GitHub user information.200 OK: JSON object with user details.
/api/github/installationsGETRetrieves GitHub installation IDs.200 OK: JSON array of installation IDs.
/api/github/search/repositoriesGETSearches GitHub repositories.200 OK: JSON array of repositories.

Conversation Management API

EndpointMethodDescriptionResponse
/api/conversationsPOSTInitializes a new conversation.200 OK: JSON object with conversation ID.
/api/conversationsGETSearches for conversations.200 OK: JSON object with conversation details.
/api/conversations/{conversation_id}GETRetrieves conversation details.200 OK: JSON object with conversation details.
/api/conversations/{conversation_id}PATCHUpdates conversation title.200 OK: Success message.
/api/conversations/{conversation_id}DELETEDeletes a conversation.200 OK: Success message.

Public API

EndpointMethodDescriptionResponse
/api/options/modelsGETRetrieves supported models.200 OK: JSON array of model names.
/api/options/agentsGETRetrieves supported agents.200 OK: JSON array of agent names.
/api/options/security-analyzersGETRetrieves security analyzers.200 OK: JSON array of analyzer names.
/api/options/configGETRetrieves server configuration.200 OK: JSON object with configuration details.

Security API

EndpointMethodDescriptionResponse
/api/conversations/{conversation_id}/security/{path:path}ANYSecurity analyzer API requests.200 OK: Response from the security analyzer.

Settings API

EndpointMethodDescriptionResponse
/api/settingsGETLoads current settings.200 OK: JSON object with settings details.
/api/settingsPOSTStores new settings.200 OK: Success message.

Trajectory API

EndpointMethodDescriptionResponse
/api/conversations/{conversation_id}/trajectoryGETRetrieves the current trajectory.200 OK: JSON object with trajectory details.

留言与讨论