Overview
This endpoint returns all data sources (repositories and workspaces) that are in “Alive” state, meaning they are fully processed and ready for chat and search operations. Use this endpoint to get a list of data sources you can query.
For administrative purposes where you need to see all data sources regardless of status, use /api/datasources/all instead.
Request
No request body required. Authentication via Bearer token in Authorization header.
Query Parameters
Optional filter by data source type. Options: Repository, Workspace
Optional search term to filter data sources by name
Response
Returns an array of data source objects that are ready for querying.
Unique identifier for the data source
Display name of the repository or workspace
Type of data source: Repository or Workspace
Repository URL (for Repository type only)
Branch name (for Repository type only)
Array of repository IDs (for Workspace type only)
Optional description of the data source
Code Examples
import requests
url = "https://app.codealive.ai/api/datasources/alive"
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
datasources = response.json()
print(f"Available datasources: {len(datasources)}")
for ds in datasources:
print(f"- {ds['name']} ({ds['type']})")
Example Response
[
{
"id": "60d21b4667d0d63ce0f9a1d1",
"name": "MyApiProject",
"type": "Repository",
"url": "https://github.com/myorg/my-backend-api",
"branch": "main"
},
{
"id": "60d21b4667d0d63ce0f9a1d2",
"name": "Development Workspace",
"type": "Workspace",
"repositoryIds": [
"60d21b4667d0d63ce0f9a1d1",
"60d21b4667d0d63ce0f9a1d3"
]
}
]
Use Cases
Pre-Chat Validation
Check available datasources before initiating chat:
import requests
# Get available datasources
response = requests.get(
"https://app.codealive.ai/api/datasources/alive",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
datasources = response.json()
# Use them in chat by ID
chat_response = requests.post(
"https://app.codealive.ai/api/chat/completions",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"messages": [{"role": "user", "content": "Explain the API structure"}],
"dataSources": [{"id": datasources[0]['id']}]
}
)
Search with Filters
Filter data sources by type or search term:
# Get only repositories with "api" in the name
params = {
"type": "Repository",
"searchTerm": "api"
}
response = requests.get(
"https://app.codealive.ai/api/datasources/alive",
headers={"Authorization": "Bearer YOUR_API_KEY"},
params=params
)
api_repos = response.json()
Differences from /all Endpoint
| Feature | /alive | /all |
|---|
| Returns | Only “Alive” sources | All sources regardless of status |
| Search | Supports searchTerm | No search functionality |
| Use case | Operational queries | Administrative access |
| Ready for querying | Yes, always | May include sources still processing |
Error Responses
401 Unauthorized
{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}
500 Internal Server Error
{
"error": {
"code": "INTERNAL_ERROR",
"message": "Failed to retrieve datasources"
}
}