Skip to main content
GET
/
api
/
datasources
/
alive
Get Available Data Sources
curl --request GET \
  --url https://api.example.com/api/datasources/alive
{
  "id": "<string>",
  "name": "<string>",
  "type": "<string>",
  "url": "<string>",
  "branch": "<string>",
  "repositoryIds": [
    {}
  ],
  "description": "<string>"
}

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

type
string
Optional filter by data source type. Options: Repository, Workspace
searchTerm
string
Optional search term to filter data sources by name

Response

Returns an array of data source objects that are ready for querying.
id
string
required
Unique identifier for the data source
name
string
required
Display name of the repository or workspace
type
string
required
Type of data source: Repository or Workspace
url
string
Repository URL (for Repository type only)
branch
string
Branch name (for Repository type only)
repositoryIds
array
Array of repository IDs (for Workspace type only)
description
string
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
ReturnsOnly “Alive” sourcesAll sources regardless of status
SearchSupports searchTermNo search functionality
Use caseOperational queriesAdministrative access
Ready for queryingYes, alwaysMay 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"
  }
}