This document provides a comprehensive reference for all API endpoints in the ChatGPT Browser application. The application uses Flask's routing system to provide a RESTful interface for managing ChatGPT conversations.
All endpoints are relative to the application root. When running locally:
http://localhost:5000
Currently, the application does not implement authentication. All endpoints are publicly accessible.
- HTML Responses: Most endpoints return HTML pages for browser viewing
- JSON Responses: Toggle endpoints return JSON for AJAX requests
- Redirects: Some endpoints redirect to other pages after processing
- 400 Bad Request: Invalid input data or file uploads
- 404 Not Found: Requested resource doesn't exist
- 500 Internal Server Error: Server-side processing errors
Endpoint: GET /
Description: Displays the main conversation list page.
Response: HTML page showing all conversations in chronological order.
Template: index.html
Query Parameters: None
Example Request:
curl http://localhost:5000/Response: HTML page with conversation list
Endpoint: GET /conversation/<conversation_id>
Description: Displays a conversation in full developer mode with all metadata.
Parameters:
conversation_id(path): The unique identifier of the conversation
Response: HTML page with complete conversation data
Template: conversation.html
Redirects:
- If dev mode is disabled, redirects to nice view
- If conversation not found, returns 404
Example Request:
curl http://localhost:5000/conversation/abc123Response: HTML page with full conversation in dev mode
Endpoint: GET /conversation/<conversation_id>/nice
Description: Displays only the canonical conversation path in a clean interface.
Parameters:
conversation_id(path): The unique identifier of the conversation
Response: HTML page with canonical conversation path
Template: nice_conversation.html
Example Request:
curl http://localhost:5000/conversation/abc123/niceResponse: HTML page with clean conversation view
Endpoint: GET /conversation/<conversation_id>/full
Description: Temporarily enables dev mode for viewing a conversation.
Parameters:
conversation_id(path): The unique identifier of the conversation
Response: Redirects to conversation view with dev mode enabled
Session Variables: Sets override_dev_mode = True
Example Request:
curl http://localhost:5000/conversation/abc123/fullResponse: Redirect to /conversation/abc123 with dev mode enabled
Endpoint: GET /settings
Description: Displays the application settings page.
Response: HTML page with current settings
Template: settings.html
Example Request:
curl http://localhost:5000/settingsResponse: HTML page with settings form
Endpoint: POST /update_names
Description: Updates the display names for user and assistant messages.
Content-Type: application/x-www-form-urlencoded
Form Data:
user_name(string): Display name for user messagesassistant_name(string): Display name for assistant messages
Response: Redirects to index page
Example Request:
curl -X POST http://localhost:5000/update_names \
-d "user_name=John&assistant_name=AI Assistant"Response: Redirect to /
Endpoint: GET /toggle_view_mode
Description: Toggles between nice mode and dev mode.
Response: JSON response with new mode status
Content-Type: application/json
Example Request:
curl http://localhost:5000/toggle_view_modeExample Response:
{
"success": true,
"dev_mode": true
}Endpoint: GET /toggle_dark_mode
Description: Toggles between dark and light themes.
Response: Redirects to previous page or index
Example Request:
curl http://localhost:5000/toggle_dark_modeResponse: Redirect to previous page with theme changed
Endpoint: GET /toggle_verbose_mode
Description: Toggles verbose mode for additional technical details.
Query Parameters:
temp(optional): If "true", creates temporary session override
Response: JSON response with new verbose status
Content-Type: application/json
Example Request:
# Permanent toggle
curl http://localhost:5000/toggle_verbose_mode
# Temporary toggle
curl http://localhost:5000/toggle_verbose_mode?temp=trueExample Response:
{
"success": true,
"verbose_mode": true
}Endpoint: POST /import
Description: Imports ChatGPT conversation data from a JSON file.
Content-Type: multipart/form-data
Form Data:
file(file): JSON file containing ChatGPT export data
Response: Redirects to index page on success, error message on failure
Error Responses:
400 Bad Request: No file uploaded, empty file, or invalid JSON
Example Request:
curl -X POST http://localhost:5000/import \
-F "file=@conversations.json"Response: Redirect to / on success
{
"id": "string",
"create_time": "string",
"update_time": "string",
"title": "string"
}{
"id": "string",
"conversation_id": "string",
"role": "string",
"content": "string",
"create_time": "string",
"update_time": "string",
"parent_id": "string",
"metadata": {
"message_type": "string",
"model_slug": "string",
"citations": "string",
"content_references": "string",
"finish_details": "string",
"is_complete": "boolean",
"request_id": "string",
"timestamp_": "string",
"message_source": "string",
"serialization_metadata": "string"
}
}{
"user_name": "string",
"assistant_name": "string",
"dev_mode": "boolean",
"dark_mode": "boolean",
"verbose_mode": "boolean"
}| Status Code | Description | Common Causes |
|---|---|---|
| 400 | Bad Request | Invalid file upload, malformed JSON |
| 404 | Not Found | Conversation ID doesn't exist |
| 500 | Internal Server Error | Database errors, processing failures |
For JSON endpoints:
{
"error": "Error message description"
}For HTML endpoints:
<div class="error">Error message description</div>The application uses Flask sessions to store temporary state:
override_dev_mode(boolean): Temporarily override dev mode settingoverride_verbose_mode(boolean): Temporarily override verbose mode setting
- Sessions are created automatically on first request
- Session data persists across requests within the same browser session
- Sessions are cleared when the browser is closed or session expires
- Content-Type:
application/json - File Extension:
.json - Size Limit: Determined by Flask configuration (default: 16MB)
- File is validated for JSON format
- Content is parsed and validated against ChatGPT export schema
- Data is processed and stored in database
- User is redirected to conversation list
The import system expects the following JSON structure:
[
{
"id": "conversation_id",
"create_time": "timestamp",
"update_time": "timestamp",
"title": "Conversation Title",
"mapping": {
"message_id": {
"id": "message_id",
"message": {
"id": "message_id",
"author": {"role": "user|assistant"},
"content": {"parts": ["message content"]},
"create_time": "timestamp",
"update_time": "timestamp",
"metadata": {}
},
"parent": "parent_message_id",
"children": ["child_message_ids"]
}
}
}
]Currently, the application does not implement rate limiting. All endpoints are accessible without restrictions.
The application does not implement CORS headers. It is designed for same-origin requests from the web interface.
- All user inputs are validated before processing
- File uploads are checked for valid JSON format
- SQL injection is prevented through parameterized queries
- Only JSON files are accepted
- File content is validated before processing
- Upload size is limited by Flask configuration
- Sessions use cryptographically secure random keys
- Session data is stored server-side
- Sessions expire automatically
- All queries use parameterized statements
- Indexes are created on frequently queried columns
- Connections are properly managed and closed
- Large files are processed in memory
- Import process continues even if individual records fail
- Database transactions ensure data consistency
Test each endpoint with various inputs:
# Test conversation list
curl http://localhost:5000/
# Test conversation view
curl http://localhost:5000/conversation/test-id
# Test settings
curl http://localhost:5000/settings
# Test toggle endpoints
curl http://localhost:5000/toggle_view_mode
curl http://localhost:5000/toggle_dark_mode
curl http://localhost:5000/toggle_verbose_modeTest error conditions:
# Test invalid conversation ID
curl http://localhost:5000/conversation/invalid-id
# Test invalid file upload
curl -X POST http://localhost:5000/import -F "file=@invalid.txt"This API reference covers all endpoints and their usage. For implementation details, see the main code documentation.