# Source: https://langfuse.com/docs/observability/features/url.md

---
title: Trace URLs
description: Each trace has a unique URL that you can use to share it with others or to access it directly.
sidebarTitle: Trace URLs
---

# Trace URLs

Each trace has a unique URL that you can use to share it with others or to access it directly.

## Get trace url

Sometimes, it is useful to get the trace URL directly in the SDK. E.g. to add it to your logs or interactively look at it when running experiments in notebooks.

<LangTabs items={["Python SDK", "JS/TS SDK", "Langchain (JS/TS)"]}>
<Tab>
When using the `@observe()` decorator:

```python
from langfuse import observe, get_client

@observe()
def process_data():
    langfuse = get_client()

    # Get the URL of the current trace
    trace_url = langfuse.get_trace_url()
    print(f"View trace at: {trace_url}")

    # or pass the trace id
    trace_id = langfuse.get_current_trace_id()
    trace_url = langfuse.get_trace_url(trace_id=trace_id)
```

When using context managers:

```python
from langfuse import get_client

langfuse = get_client()

with langfuse.start_as_current_observation(as_type="span", name="process-request") as span:
    # Get the URL of this trace
    trace_url = langfuse.get_trace_url()
    print(f"View trace at: {trace_url}")

    # or pass the trace id
    trace_id = langfuse.get_current_trace_id()
    trace_url = langfuse.get_trace_url(trace_id=trace_id)
```

</Tab>
<Tab title="JS/TS SDK">

```ts
import { LangfuseClient } from "@langfuse/client";
import { startObservation } from "@langfuse/tracing";

const langfuse = new LangfuseClient();

const rootSpan = startObservation("my-trace");
const traceUrl = await langfuse.getTraceUrl(rootSpan.traceId);

console.log("Trace URL: ", traceUrl);
```

</Tab>
<Tab title="Langchain (JS/TS)">

Use the interoperability of the Langfuse SDK with the Langchain integration to get the URL of a trace ([interop docs](/integrations/frameworks/langchain#interoperability)).

```ts
// Initialize Langfuse Client
import { CallbackHandler, Langfuse } from "langfuse-langchain";
const langfuse = new Langfuse();

// Create a Langfuse trace for an execution of your application
const trace = langfuse.trace();

// Get Langchain handler for this trace
const langfuseHandler = new CallbackHandler({ root: trace });

// Get the trace URL
langfuseHandler.getTraceUrl();
```

**Deprecated:** flaky in cases of concurrent requests as it depends on the state of the handler.

```ts
handler.getTraceUrl();
```

</Tab>
</LangTabs>

## Share trace via url

By default, only members of your Langfuse project can view a trace.

You can make a trace `public` to share it via a public link. This allows others to view the trace without needing to log in or be members of your Langfuse project.

_Example: https://cloud.langfuse.com/project/clkpwwm0m000gmm094odg11gi/traces/2d6b96f2-0a4d-4366-99a5-1ad558c66e99_

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

<Video
  src="https://static.langfuse.com/docs-videos/share-trace.mp4"
  aspectRatio={1652 / 1080}
  gifStyle
/>

</Tab>
<Tab title="Python SDK (v3)">

When using the `@observe()` decorator:

```python
from langfuse import observe, get_client

@observe()
def process_data():
    langfuse = get_client()

    # Make the current trace public
    langfuse.update_current_trace(public=True)
```

When using context managers:

```python
from langfuse import get_client

langfuse = get_client()

with langfuse.start_as_current_observation(as_type="span", name="process-request") as span:
    # Make this trace public
    span.update_trace(public=True)

    # Get the URL to share
    trace_id = langfuse.get_current_trace_id()
    trace_url = langfuse.get_trace_url(trace_id=trace_id)
    print(f"Share this trace at: {trace_url}")
```

</Tab>
<Tab>

```ts /public: true/
import { startObservation, updateTrace } from "@langfuse/tracing";

const rootSpan = startObservation("my-trace");

rootSpan.updateTrace({
  public: true,
});

rootSpan.end();
```

</Tab>
</LangTabs>