• Experimental

    Get span annotations for a list of span IDs.

    This method allows you to retrieve annotations for specific spans within a project. You can filter annotations by name and support cursor-based pagination.

    this function is experimental and may change in the future

    Parameters

    • params: GetSpanAnnotationsParams

      The parameters to get span annotations

    Returns Promise<GetSpanAnnotationsResult>

    A paginated response containing annotations and optional next cursor

    // Get annotations for specific spans
    const result = await getSpanAnnotations({
    client,
    project: { projectName: "my-project" },
    spanIds: ["span1", "span2", "span3"],
    limit: 50
    });

    // Get specific annotation types
    const result = await getSpanAnnotations({
    client,
    project: { projectName: "my-project" },
    spanIds: ["span1"],
    includeAnnotationNames: ["quality_score", "sentiment"],
    limit: 100
    });

    // Paginate through results
    let cursor: string | undefined;
    do {
    const result = await getSpanAnnotations({
    client,
    project: { projectName: "my-project" },
    spanIds: ["span1"],
    cursor,
    limit: 100
    });

    // Process annotations
    result.annotations.forEach(annotation => {
    console.log(`Annotation: ${annotation.name}, Label: ${annotation.result.label}`);
    });

    cursor = result.nextCursor || undefined;
    } while (cursor);