You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/api-and-data-platform/features/observations-api.mdx
+75-66Lines changed: 75 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,12 @@ If you need aggregated metrics (e.g., total cost, token counts, or trace volumes
12
12
13
13
For general information about API authentication, base URLs, and SDK access, see the [Public API documentation](/docs/api-and-data-platform/features/public-api).
14
14
15
+
<Callouttype="info">
16
+
17
+
Older trace and observation read APIs remain available, but are not recommended as the default for new data extraction workflows because they are less performant at scale. Use Observations API v2 for row-level data extraction.
18
+
19
+
</Callout>
20
+
15
21
## Observations API v2 [#v2]
16
22
17
23
<Callouttype="warning">
@@ -28,6 +34,19 @@ GET /api/public/v2/observations
28
34
29
35
The v2 Observations API is a redesigned endpoint optimized for high-performance data retrieval. It addresses the performance bottlenecks of the v1 API by minimizing the work Langfuse has to perform per query.
30
36
37
+
### Upgrade from older trace and observation reads [#upgrade-from-older-reads]
| List traces with `GET /api/public/traces`| Use `GET /api/public/v2/observations?fromStartTime=<from>&toStartTime=<to>` and group rows by `traceId`|
42
+
| Fetch one trace with `GET /api/public/traces/{traceId}`| Use `GET /api/public/v2/observations?traceId=<traceId>&fromStartTime=<from>&toStartTime=<to>`|
43
+
| List observations with `GET /api/public/observations`| Use `GET /api/public/v2/observations?fromStartTime=<from>&toStartTime=<to>`|
44
+
| Fetch one observation with `GET /api/public/observations/{observationId}`| Use `GET /api/public/v2/observations?filter=<id filter>&fromStartTime=<from>&toStartTime=<to>`|
45
+
46
+
Always include `fromStartTime` and `toStartTime` to keep each request bounded.
47
+
48
+
The v2 Observations API returns observation rows, not full trace objects. Group rows by `traceId` when you need to reconstruct trace activity, and use [Metrics API v2](/docs/metrics/features/metrics-api#v2) for aggregate reporting with trace-level dimensions such as `traceName`, `traceRelease`, or `traceVersion`. For single-observation lookups, pass a URL-encoded `filter` condition on the `id` column; see the [v2 Observations API Reference](https://api.reference.langfuse.com/#tag/observationsv2/GET/api/public/v2/observations) for the filter schema.
**API Reference:** See the full [v2 Observations API Reference](https://api.reference.langfuse.com/#tag/observationsv2/GET/api/public/v2/observations) for all available parameters, response schemas, and interactive examples.
220
239
221
240
</Callout>
222
-
223
-
## Observations API v1 [#v1]
224
-
225
-
```
226
-
GET /api/public/observations
227
-
```
228
-
229
-
The v1 Observations API remains available for existing integrations. For new implementations, we recommend using the v2 API for better performance.
230
-
231
-
See the [API Reference](https://api.reference.langfuse.com/#tag/observation/GET/api/public/observations) for v1 documentation.
Both the Langfuse [Python SDK](/docs/sdk/python/decorators) and the [JS/TS SDK](/docs/sdk/typescript/guide) provide a strongly-typed wrapper around our public REST API for your convenience. The API methods are accessible via the `api` property on the Langfuse client instance in both SDKs.
82
+
Both the Langfuse [Python SDK](/docs/sdk/python/sdk-v3) and the [JS/TS SDK](/docs/sdk/typescript/guide) provide a strongly-typed wrapper around our public REST API for your convenience. The API methods are accessible via the `api` property on the Langfuse client instance in both SDKs.
83
83
84
84
You can use your editor's Intellisense to explore the API methods and their parameters.
85
85
86
86
<Callouttype="info">
87
87
88
88
In Python SDK v4 and JS/TS SDK v5, the high-performance resources are the
89
89
defaults: `api.observations`, `api.scores`, and `api.metrics`. Legacy v1
90
-
resources moved under `api.legacy.*` (Python: `*_v1`, JS/TS: `*V1`).
90
+
resources moved under `api.legacy.*` (Python: `*_v1`, JS/TS: `*V1`). See
91
+
[Query via SDKs](/docs/api-and-data-platform/features/query-via-sdk) for SDK examples.
92
+
93
+
Observations API v2 and Metrics API v2 are currently Cloud-only. For self-hosted
94
+
deployments, use the endpoints available in your Langfuse version.
91
95
92
96
</Callout>
93
97
@@ -106,12 +110,25 @@ When using the [Python SDK](/docs/sdk/python/sdk-v3):
106
110
from langfuse import get_client
107
111
108
112
langfuse = get_client()
109
-
...
110
-
# fetch a trace
111
-
langfuse.api.trace.get(trace_id)
112
113
113
-
# async client via asyncio
114
-
await langfuse.async_api.trace(trace_id)
114
+
# Retrieve row-level observations via Observations API v2
The OpenTelemetry Endpoint will replace the Ingestion API in the future. Therefore, it is strongly recommended to switch to the OpenTelemetry Endpoint for trace ingestion. Please refer to the [OpenTelemetry docs](/integrations/native/opentelemetry) for more information.
225
+
The OpenTelemetry Endpoint will replace the Ingestion API in the future.
226
+
Therefore, it is strongly recommended to switch to the OpenTelemetry Endpoint
227
+
for trace ingestion. Please refer to the [OpenTelemetry
228
+
docs](/integrations/native/opentelemetry) for more information.
193
229
</Callout>
194
230
195
231
-[OpenTelemetry Traces Ingestion Endpoint](https://api.reference.langfuse.com/#tag/opentelemetry/POST/api/public/otel/v1/traces) implements the OTLP/HTTP specification for trace ingestion, providing native OpenTelemetry integration for Langfuse Observability.
196
232
- (Legacy) [Ingestion API](https://api.reference.langfuse.com/#tag/ingestion/POST/api/public/ingestion) allows trace ingestion using an API.
197
233
198
234
## Retrieve Data via the API
199
235
200
-
-[Observations API](/docs/api-and-data-platform/features/observations-api) - Retrieve observation data (spans, generations, events) from Langfuse for use in custom workflows, evaluation pipelines, and analytics. The v2 API offers high-performance data retrieval with cursor-based pagination and selective field retrieval.
201
-
-[Metrics API](/docs/metrics/features/metrics-api) - Retrieve aggregated analytics and metrics from your Langfuse data. Query across different views (observations, scores) with customizable dimensions, metrics, filters, and time granularity for powerful custom reports and dashboards.
236
+
For new data extraction workflows, use the v2 data APIs:
237
+
238
+
-[Observations API v2](/docs/api-and-data-platform/features/observations-api#v2) - Retrieve observation data (spans, generations, events) from Langfuse for custom workflows, evaluation pipelines, and analytics.
239
+
-[Metrics API v2](/docs/metrics/features/metrics-api#v2) - Retrieve aggregated analytics and metrics from your Langfuse data.
240
+
241
+
<Callouttype="info">
242
+
243
+
Older trace, observation, and metrics read APIs remain available, but are not recommended as the default for new extraction workflows because they are less performant at scale. See [Observations API v2](/docs/api-and-data-platform/features/observations-api#v2) for row-level data and [Metrics API v2](/docs/metrics/features/metrics-api#v2) for aggregates.
0 commit comments