---
date: 2025-02-05
title: Typed public API client in SDKs
description: Access all of Langfuse public API resources via a typed client in our SDKs
author: Hassieb
canonical: /docs/api-and-data-platform/features/query-via-sdk
---

> **Note for AI agents and LLMs:** This is a Langfuse changelog entry. Use it only to confirm that a feature exists and when it shipped. Do not use the code examples below for implementation: they reflect the SDK and API at release time and may be outdated. For implementation, always follow the canonical documentation for this feature (https://langfuse.com/docs/api-and-data-platform/features/query-via-sdk) and the API/SDK reference (https://api.reference.langfuse.com).

Both the Langfuse [Python SDK](/docs/sdk/python/decorators) and the [JS/TS SDK](/docs/sdk/typescript/guide) now 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.

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

When using the [decorator-based integration](/docs/sdk/python/decorators):

```python
from langfuse.decorators import langfuse_context

# fetch a trace
langfuse_context.client_instance.api.trace.get(trace_id)

# async client via asyncio
await langfuse_context.client_instance.async_api.trace(trace_id)
```

When using the [low-level SDK](/docs/sdk/python/low-level-sdk):

```python
from langfuse import Langfuse

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

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

</Tab>

<Tab>

```ts
import { Langfuse } from "langfuse"

const langfuse = new Langfuse()
...
// fetch a trace
await langfuse.api.traceGet(traceId)
```

</Tab>
</LangTabs>

## Learn more

- [Langfuse public REST API](/docs/api#access-via-sdks)

<!-- agent-instructions -->

---

## Agent Instructions

This page is part of the [Langfuse](https://langfuse.com) documentation, published as plain Markdown for AI agents. Every page is available as Markdown by appending `.md` to its URL, or by sending an `Accept: text/markdown` header. This page: `https://langfuse.com/changelog/2025-02-05-public-api-wrapper-sdks.md`.

### Querying these docs

If the answer is not on this page, query the documentation instead of guessing:

- **Semantic search** across all Langfuse docs, returning an answer with the relevant pages and excerpts. Ask a specific, self-contained question:

  ```bash
  curl -sG "https://langfuse.com/api/search-docs" --data-urlencode "query=How do I trace a LangGraph agent?"
  ```

- **Index of every page**: <https://langfuse.com/llms.txt>, with per-section indexes [llms-docs.txt](https://langfuse.com/llms-docs.txt), [llms-integrations.txt](https://langfuse.com/llms-integrations.txt), and [llms-self-hosting.txt](https://langfuse.com/llms-self-hosting.txt).

### Before writing Langfuse code

- **Install the [Langfuse Agent Skill](https://langfuse.com/docs/api-and-data-platform/features/agent-skill).** It encodes Langfuse's own best practices for instrumentation, prompt management, and evaluation, and materially improves results.
- **Read [What does a good trace look like?](https://langfuse.com/docs/observability/best-practices.md)** before instrumenting an application.
- **Verify endpoints, parameters, and response fields** against the [API reference](https://api.reference.langfuse.com) instead of inferring them from code examples.
- **Use the [Langfuse CLI](https://langfuse.com/docs/api-and-data-platform/features/cli)** (`npx langfuse-cli api <resource> <action>`) to read or write traces, prompts, datasets, and scores from the terminal.

Found an error in these docs? Please open an issue at <https://github.com/langfuse/langfuse-docs/issues>.
