Skip to main content
POST
/
api
/
search
/
artifacts
Fetch Artifacts
curl --request POST \
  --url https://api.example.com/api/search/artifacts \
  --header 'Content-Type: application/json' \
  --data '
{
  "identifiers": [
    {}
  ]
}
'
{
  "artifacts": [
    {
      "identifier": "<string>",
      "content": "<string>",
      "contentByteSize": 123
    }
  ]
}

Overview

The Fetch Artifacts endpoint retrieves the full content for specific artifacts identified by their unique identifiers. This is designed to be used after the Search endpoint to fetch content only for the results you need.

Workflow

1

Search

Use GET /api/search with IncludeContent=false to find relevant artifacts. Each result includes an identifier, description, and contentByteSize.
2

Review

Examine the descriptions and file paths to decide which artifacts you need the full content for.
3

Fetch

Use this endpoint with the identifier values from search results to retrieve the full content.

Request

Body Parameters

identifiers
array
required
Array of artifact identifiers from search results. Maximum 20 identifiers per request.

Response

artifacts
array
Array of artifact objects

Code Examples

import requests

url = "https://app.codealive.ai/api/search/artifacts"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Fetch content for specific artifacts found via search
body = {
    "identifiers": [
        "MyOrg/my-repo::src/services/AuthService.cs::UserAuthService",
        "MyOrg/my-repo::src/controllers/AuthController.cs::Login"
    ]
}

response = requests.post(url, headers=headers, json=body)
data = response.json()

for artifact in data["artifacts"]:
    if artifact.get("content"):
        print(f"--- {artifact['identifier']} ({artifact['contentByteSize']} bytes) ---")
        print(artifact["content"])

Example Response

{
  "artifacts": [
    {
      "identifier": "MyOrg/my-repo::src/services/AuthService.cs::UserAuthService",
      "content": "public class UserAuthService : IAuthService\n{\n    private readonly ITokenGenerator _tokenGenerator;\n    ...\n}",
      "contentByteSize": 4250
    },
    {
      "identifier": "MyOrg/my-repo::src/controllers/AuthController.cs::Login",
      "content": "public async Task<IActionResult> Login(LoginRequest request)\n{\n    ...\n}",
      "contentByteSize": 890
    }
  ]
}

Constraints

ConstraintValue
Max identifiers per request20
Identifier formatowner/repo::path::symbol (from search results)

Error Responses

400 Bad Request

{
  "message": "Identifiers array is required and must contain at most 20 items"
}

401 Unauthorized

{
  "message": "Invalid or missing API key"
}

404 Not Found

{
  "message": "One or more data sources could not be found"
}

Best Practices

  • Group related artifact fetches into a single request (up to 20)
  • Use contentByteSize from search results to estimate response size
  • Only fetch artifacts you actually need — review descriptions first
  1. Call GET /api/search?Query=authentication&DescriptionDetail=Full to find relevant code
  2. Review descriptions to identify the most relevant results
  3. Call POST /api/search/artifacts with selected identifiers to get full content
  4. This is more efficient than using IncludeContent=true on the search endpoint