> 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/credentials-and-cookies.md).

# Credentials and Cookies

This page covers the three things you need before making real requests: Tonapi key, wallet seed, and Fragment cookies.

## Tonapi key

Generate an API key at <https://tonconsole.com>.

## Seed phrase

Use your GRAM (ex TON) wallet mnemonic.

* **Keep it private.**
* **Never log it or commit it to git.**

## Fragment cookies

You must be logged in to Fragment.

### Option 1: automatic extraction

```python
from pyfragment import get_cookies_from_browser

cookie_result = get_cookies_from_browser("chrome")
cookies = cookie_result.cookies
```

`cookie_result` is `CookieResult`:

* `cookies`: `dict[str, str]`
* `expires`: ISO string or `None`

### Option 2: manual export

Export the four required Fragment cookies and pass them directly as dict or JSON string.

Required keys:

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

## Common auth failures

* expired session cookies,
* not logged in on fragment.com,
* missing `stel_*` keys,
* stale cookies from another browser/profile.

When this happens, re-login on fragment.com and refresh cookies first. It solves most auth issues.

## Next step

Proceed to [Quick Start](/pyfragment/setup-guide/quickstart.md).


---

# 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/credentials-and-cookies.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.
