Query Data via SDKs
Langfuse is open-source and data tracked with Langfuse is open. You can query data via: SDKs and API. For export functionality, see Export Data.
Common use cases:
- Train or fine-tune models on the production traces in Langfuse. E.g. to create a small model after having used a large model in production for a specific use case.
- Collect few-shot examples to improve quality of output.
- Programmatically create datasets.
If you are new to Langfuse, we recommend familiarizing yourself with the Langfuse data model.
New data is typically available for querying within 15-30 seconds of ingestion, though processing times may vary at times. Please visit status.langfuse.com if you encounter any issues.
SDKs
Via the SDKs for Python and JS/TS you can easily query the API without having to write the HTTP requests yourself.
pip install langfuse
from langfuse import get_client
langfuse = get_client() # uses environment variables to authenticate
# Fetch list of traces, supports filters and pagination
traces = langfuse.api.trace.list()
# Fetch a single trace by ID
trace = langfuse.api.trace.get("traceId")
# Fetch list of observations, supports filters and pagination
observations = langfuse.api.observations.get_many()
# Fetch a single observation by ID
observation = langfuse.api.observations.get("observationId")
# Fetch list of sessions
sessions = langfuse.api.sessions.list()
# Explore more entities via Intellisense
langfuse.api.*
API
All data in Langfuse is available via the API. Refer to the API reference for more information.
Example routes:
GET /api/public/traces
GET /api/public/traces/:traceId
GET /api/public/observations
GET /api/public/observations/:observationId
GET /api/public/sessions
GET /api/public/scores
GET /api/public/scores/:scoreId
Export Data
For comprehensive export capabilities including UI exports, scheduled blob storage exports, and programmatic access via SDKs and APIs, see the overview page.