> For the complete documentation index, see [llms.txt](https://bohd4nx.gitbook.io/pyfragment/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bohd4nx.gitbook.io/pyfragment/setup-guide/configuration.md).

# Library and Configuration

Main entry point of the library is `FragmentClient`.

```python
FragmentClient(
    seed: str,
    api_key: str,
    cookies: dict[str, Any] | str,
    wallet_version: str = "V5R1",
    api_provider: str = "tonapi",
    timeout: float = 30.0,
)
```

## Parameters

* `seed`: wallet mnemonic (**12 or 24 words**)
* `api_key`: API key — from [tonconsole.com](https://tonconsole.com) (tonapi) or [@toncenter](https://t.me/toncenter)
* `cookies`: Fragment cookies as a dictionary or JSON string
* `wallet_version`: `"V4R2"`, `"V5R1"`, `"HighloadV2"`, or `"HighloadV3R1"`
* `api_provider`: blockchain API provider — `"tonapi"` (default) or `"toncenter"`
* `timeout`: request timeout in seconds

**If `api_key` or cookies are missing, initialization fails immediately.**

## Required cookies

* `stel_ssid`
* `stel_dt`
* `stel_token`
* `stel_ton_token`

## Minimal initialization pattern

```python
from pyfragment import FragmentClient

async with FragmentClient(
    seed="word1 word2 ... word24",
    api_key="YOUR_API_KEY",
    cookies={
        "stel_ssid": "...",
        "stel_dt": "...",
        "stel_token": "...",
        "stel_ton_token": "...",
    },
) as client:
    wallet = await client.get_wallet()
```

## Switching API provider

By default, the library uses [tonconsole.com](https://tonconsole.com) (tonapi). To use [toncenter](https://t.me/toncenter) instead, pass `api_provider="toncenter"`:

```python
async with FragmentClient(
    seed="...",
    api_key="YOUR_TONCENTER_API_KEY",
    cookies={...},
    api_provider="toncenter",
) as client:
    ...
```

Both providers work identically — the correct `tonutils` client is selected automatically based on `api_provider`.

## Validation behavior

At initialization, library validates:

* seed format,
* cookie shape and required keys,
* supported wallet version,
* supported API provider,
* parseability of cookie JSON strings.

Constructor-level issues are raised as `ConfigurationError` or `CookieError`.


---

# 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://bohd4nx.gitbook.io/pyfragment/setup-guide/configuration.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.
