> For the complete documentation index, see [llms.txt](https://docs.freighter.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.freighter.app/extension-freighter-api/reading-data.md).

# Reading Data

Retrieve the user's public key and network configuration from Freighter.

{% hint style="info" %}
These methods require that the user has previously authorized your app via [`requestAccess()`](/extension-freighter-api/connecting.md#requesting-access) or [`setAllowed()`](/extension-freighter-api/connecting.md#requesting-authorization).
{% endhint %}

## Getting the User's Address

### `getAddress()`

A lightweight way to retrieve the user's public key. Unlike `requestAccess()`, this will **not** prompt the user — it returns an empty string if the app isn't authorized or Freighter isn't connected.

**Returns:** `Promise<{ address: string } & { error?: FreighterApiError }>`

```typescript
import { getAddress } from "@stellar/freighter-api";

const { address, error } = await getAddress();

if (error) {
  console.error(error.message);
} else {
  console.log("Public key:", address);
}
```

## Getting the Network

### `getNetwork()`

Get the name and passphrase of the network the user has selected in Freighter.

**Returns:** `Promise<{ network: string; networkPassphrase: string } & { error?: FreighterApiError }>`

Possible `network` values: `PUBLIC`, `TESTNET`, `FUTURENET`, or `STANDALONE` (custom networks).

```typescript
import { getNetwork } from "@stellar/freighter-api";

const { network, networkPassphrase, error } = await getNetwork();

if (!error) {
  console.log("Network:", network);           // e.g., "TESTNET"
  console.log("Passphrase:", networkPassphrase);
}
```

### `getNetworkDetails()`

Get comprehensive network configuration including the Horizon URL, passphrase, and Soroban RPC URL.

**Returns:** `Promise<{ network: string; networkUrl: string; networkPassphrase: string; sorobanRpcUrl?: string } & { error?: FreighterApiError }>`

```typescript
import { getNetworkDetails } from "@stellar/freighter-api";

const details = await getNetworkDetails();

if (!details.error) {
  console.log("Network:", details.network);            // e.g., "TESTNET"
  console.log("Horizon:", details.networkUrl);          // e.g., "https://horizon-testnet.stellar.org"
  console.log("Passphrase:", details.networkPassphrase);
  console.log("Soroban RPC:", details.sorobanRpcUrl);   // e.g., "https://soroban-testnet.stellar.org"
}
```

{% hint style="info" %}
Use `getNetworkDetails()` instead of `getNetwork()` when working with Soroban smart contracts or when you need specific network endpoints.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.freighter.app/extension-freighter-api/reading-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
