# Source: https://langfuse.com/docs/api-and-data-platform/features/public-api.md

---
title: Public API
sidebarTitle: Public API
description: All Langfuse data and features are available via the API. Follow this guide to get started.
---

# Public API

Langfuse is open and meant to be extended via custom workflows and integrations. All Langfuse data and features are available via the API.

<Tabs items={["Path", "Cloud US", "Cloud EU", "HIPAA US"]}>

<Tab>

```
/api/public
```

</Tab>
<Tab>

```
https://us.cloud.langfuse.com/api/public
```

</Tab>
<Tab>

```
https://cloud.langfuse.com/api/public
```

</Tab>
<Tab>

```
https://hipaa.cloud.langfuse.com/api/public
```

</Tab>
</Tabs>

References:

- API Reference: https://api.reference.langfuse.com
- OpenAPI spec: https://cloud.langfuse.com/generated/api/openapi.yml
- Postman collection: https://cloud.langfuse.com/generated/postman/collection.json

<Callout type="info">

There are 3 different groups of APIs:

- This page -> Project-level APIs: CRUD traces/evals/prompts/configuration within a project
- [Organization-level APIs](/docs/administration/scim-and-org-api): provision projects, users (SCIM), and permissions
- [Instance Management API](/self-hosting/administration/instance-management-api): administer organizations on self-hosted installations

</Callout>

## Authentication

Authenticate with the API using [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication).
The API keys are available in the Langfuse project settings.

- Username: Langfuse Public Key
- Password: Langfuse Secret Key

Example:

```bash
curl -u public-key:secret-key https://cloud.langfuse.com/api/public/projects
```

## Access via SDKs

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.

You can use your editor's Intellisense to explore the API methods and their parameters.

<Callout type="info">

When fetching [prompts](/docs/prompts/get-started#use-prompt), please use the `get_prompt` (Python) / `getPrompt` (JS/TS) methods on the Langfuse client to benefit from client-side caching, automatic retries, and fallbacks.

</Callout>

<LangTabs items={["Python SDK", "JS/TS SDK", "Java SDK"]}>
<Tab>

When using the [Python SDK](/docs/sdk/python/sdk-v3):

```python
from langfuse import get_client

langfuse = get_client()
...
# fetch a trace
langfuse.api.trace.get(trace_id)

# async client via asyncio
await langfuse.async_api.trace(trace_id)

# explore more endpoints via Intellisense
langfuse.api.*
await langfuse.async_api.*
```

</Tab>

<Tab>

```ts
import { LangfuseClient } from '@langfuse/client';

const langfuse = new LangfuseClient();
...
// fetch a trace
await langfuse.api.trace.get(traceId);

// explore more endpoints via Intellisense
langfuse.api.*
```

</Tab>

<Tab>

Install Langfuse by adding the following to your `pom.xml`:

```xml
<dependencies>
  <dependency>
    <groupId>com.langfuse</groupId>
    <artifactId>langfuse-java</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </dependency>
</dependencies>

<repositories>
  <repository>
    <id>github</id>
    <name>GitHub Package Registry</name>
    <url>https://maven.pkg.github.com/langfuse/langfuse-java</url>
  </repository>
</repositories>
```

Instantiate and use the Java SDK via:

```java
import com.langfuse.client.LangfuseClient;
import com.langfuse.client.resources.prompts.types.PromptMetaListResponse;
import com.langfuse.client.core.LangfuseClientApiException;

LangfuseClient client = LangfuseClient.builder()
  .url("https://cloud.langfuse.com") // 🇪🇺 EU data region
  // .url("https://us.cloud.langfuse.com") // 🇺🇸 US data region
  // .url("http://localhost:3000") // 🏠 Local deployment
  .credentials("pk-lf-...", "sk-lf-...")
  .build();

try {
  PromptMetaListResponse prompts = client.prompts().list();
} catch (LangfuseClientApiException error) {
  System.out.println(error.getBody());
  System.out.println(error.getStatusCode());
}
```

</Tab>
</LangTabs>

## Ingest Traces via the API

<Callout type="info">
  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.
</Callout>

- [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.
- (Legacy) [Ingestion API](https://api.reference.langfuse.com/#tag/ingestion/POST/api/public/ingestion) allows trace ingestion using an API.

## Retrieve Data via the API

- [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.
- [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.

## Alternatives

You can also export data via:

- [UI](/docs/api-and-data-platform/features/export-from-ui) - Manual batch-exports from the Langfuse UI
- [Blob Storage](/docs/api-and-data-platform/features/export-to-blob-storage) - Scheduled automated exports to cloud storage

## FAQ

import { FaqPreview } from "@/components/faq/FaqPreview";

<FaqPreview tags={["api"]} />

## GitHub Discussions

import { GhDiscussionsPreview } from "@/components/gh-discussions/GhDiscussionsPreview";

<GhDiscussionsPreview labels={["feat-api"]} />