mirror of
https://github.com/LearningCircuit/local-deep-research.git
synced 2026-06-15 19:46:56 +03:00
docs: fix incorrect API endpoint paths in documentation (#1210)
Updates documentation and examples to use the correct API endpoints:
- /api/start_research (was /research/api/start)
- /api/research/{id}/status (was /research/api/research/{id}/status)
- /api/report/{id} (was /research/api/research/{id}/result)
- /api/terminate/{id} (was /research/api/research/{id}/terminate)
Fixes #1205
This commit is contained in:
@@ -41,7 +41,7 @@ with get_user_db_session(username="user", password="pass") as session:
|
||||
|
||||
#### Endpoint Structure
|
||||
- **v0.x**: `/api/v1/quick_summary`
|
||||
- **v1.0**: `/research/api/start`
|
||||
- **v1.0**: `/api/start_research`
|
||||
|
||||
#### Authentication Flow
|
||||
```python
|
||||
@@ -61,7 +61,7 @@ csrf = session.get("http://localhost:5000/auth/csrf-token").json()["csrf_token"]
|
||||
|
||||
# 3. Make API requests with CSRF token
|
||||
response = session.post(
|
||||
"http://localhost:5000/research/api/start",
|
||||
"http://localhost:5000/api/start_research",
|
||||
json={"query": "test"},
|
||||
headers={"X-CSRF-Token": csrf}
|
||||
)
|
||||
@@ -177,7 +177,7 @@ class LDRClient:
|
||||
|
||||
def start_research(self, query, **kwargs):
|
||||
return self.session.post(
|
||||
f"{self.base_url}/research/api/start",
|
||||
f"{self.base_url}/api/start_research",
|
||||
json={"query": query, **kwargs},
|
||||
headers={"X-CSRF-Token": self.csrf_token}
|
||||
)
|
||||
|
||||
@@ -85,7 +85,7 @@ csrf_token = csrf_response.json()["csrf_token"]
|
||||
# 4. Make API requests with CSRF header
|
||||
headers = {"X-CSRF-Token": csrf_token}
|
||||
api_response = session.post(
|
||||
"http://localhost:5000/research/api/start",
|
||||
"http://localhost:5000/api/start_research",
|
||||
json={
|
||||
"query": "What is quantum computing?",
|
||||
"model": "gpt-3.5-turbo",
|
||||
@@ -124,12 +124,12 @@ with get_user_db_session(username="your_username", password="your_password") as
|
||||
|
||||
### Research Endpoints
|
||||
|
||||
All research endpoints are under `/research/api/`:
|
||||
Research endpoints are under `/api/`:
|
||||
|
||||
- `POST /research/api/start` - Start new research
|
||||
- `GET /research/api/research/{id}/status` - Check research status
|
||||
- `GET /research/api/research/{id}/result` - Get research results
|
||||
- `POST /research/api/research/{id}/terminate` - Stop running research
|
||||
- `POST /api/start_research` - Start new research
|
||||
- `GET /api/research/{id}/status` - Check research status
|
||||
- `GET /api/report/{id}` - Get research results
|
||||
- `POST /api/terminate/{id}` - Stop running research
|
||||
|
||||
### Settings Endpoints
|
||||
|
||||
@@ -152,7 +152,7 @@ Settings endpoints are under `/settings/api/`:
|
||||
2. **Settings Snapshot**: Programmatic API calls need settings_snapshot parameter
|
||||
3. **Per-User Databases**: Each user has their own encrypted database
|
||||
4. **CSRF Protection**: State-changing requests require CSRF token
|
||||
5. **New Endpoint Structure**: APIs moved under blueprint prefixes (e.g., `/research/api/`)
|
||||
5. **New Endpoint Structure**: Research APIs are under `/api/` (e.g., `/api/start_research`)
|
||||
|
||||
## Example: Complete Research Flow
|
||||
|
||||
@@ -173,7 +173,7 @@ headers = {"X-CSRF-Token": csrf}
|
||||
|
||||
# Start research
|
||||
research = session.post(
|
||||
"http://localhost:5000/research/api/start",
|
||||
"http://localhost:5000/api/start_research",
|
||||
json={
|
||||
"query": "Latest advances in quantum computing",
|
||||
"model": "gpt-3.5-turbo",
|
||||
@@ -188,7 +188,7 @@ research_id = research["research_id"]
|
||||
# Poll for results
|
||||
while True:
|
||||
status = session.get(
|
||||
f"http://localhost:5000/research/api/research/{research_id}/status"
|
||||
f"http://localhost:5000/api/research/{research_id}/status"
|
||||
).json()
|
||||
|
||||
if status["status"] in ["completed", "failed"]:
|
||||
@@ -199,7 +199,7 @@ while True:
|
||||
|
||||
# Get final results
|
||||
results = session.get(
|
||||
f"http://localhost:5000/research/api/research/{research_id}/result"
|
||||
f"http://localhost:5000/api/report/{research_id}"
|
||||
).json()
|
||||
|
||||
print(f"Summary: {results['summary']}")
|
||||
|
||||
@@ -134,7 +134,7 @@ print(response.json())
|
||||
|
||||
1. **Authentication Required**: All endpoints now require login
|
||||
2. **Settings Snapshot**: Programmatic API needs `settings_snapshot` parameter
|
||||
3. **New Endpoints**: API routes moved (e.g., `/api/v1/quick_summary` → `/research/api/start`)
|
||||
3. **New Endpoints**: API routes moved (e.g., `/api/v1/quick_summary` → `/api/start_research`)
|
||||
4. **CSRF Protection**: POST/PUT/DELETE requests need CSRF token
|
||||
|
||||
### Migration Guide
|
||||
|
||||
@@ -56,7 +56,7 @@ with get_user_db_session(username="user", password="pass") as session:
|
||||
- **"No settings context available"**: Pass `settings_snapshot` to API functions
|
||||
- **"Encrypted database requires password"**: Use `get_user_db_session()` with credentials
|
||||
- **"CSRF token missing"**: Get CSRF token before POST/PUT/DELETE requests
|
||||
- **404 errors**: Check new endpoint paths (e.g., `/research/api/start`)
|
||||
- **404 errors**: Check new endpoint paths (e.g., `/api/start_research`)
|
||||
|
||||
## Need Help?
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ class LDRClient:
|
||||
}
|
||||
|
||||
response = self.session.post(
|
||||
f"{self.base_url}/research/api/start",
|
||||
f"{self.base_url}/api/start_research",
|
||||
json=payload,
|
||||
headers=self._get_headers(),
|
||||
)
|
||||
@@ -152,15 +152,13 @@ class LDRClient:
|
||||
def get_research_status(self, research_id: str) -> Dict[str, Any]:
|
||||
"""Get the status of a research task."""
|
||||
response = self.session.get(
|
||||
f"{self.base_url}/research/api/research/{research_id}/status"
|
||||
f"{self.base_url}/api/research/{research_id}/status"
|
||||
)
|
||||
return response.json()
|
||||
|
||||
def get_research_result(self, research_id: str) -> Dict[str, Any]:
|
||||
"""Get the results of a completed research task."""
|
||||
response = self.session.get(
|
||||
f"{self.base_url}/research/api/research/{research_id}/result"
|
||||
)
|
||||
response = self.session.get(f"{self.base_url}/api/report/{research_id}")
|
||||
return response.json()
|
||||
|
||||
def wait_for_research(
|
||||
|
||||
@@ -234,9 +234,7 @@ def main():
|
||||
)
|
||||
|
||||
# Get results
|
||||
results_response = session.get(
|
||||
f"{API_URL}/research/api/research/{research_id}/result"
|
||||
)
|
||||
results_response = session.get(f"{API_URL}/api/report/{research_id}")
|
||||
|
||||
if results_response.status_code == 200:
|
||||
results = results_response.json()
|
||||
@@ -286,7 +284,7 @@ def main():
|
||||
|
||||
while results_retries < max_results_retries:
|
||||
results_response = session.get(
|
||||
f"{API_URL}/api/research/{research_id}/report"
|
||||
f"{API_URL}/api/report/{research_id}"
|
||||
)
|
||||
|
||||
if results_response.status_code == 200:
|
||||
|
||||
Reference in New Issue
Block a user