Metadata-Version: 2.4
Name: fortell
Version: 0.1.1
Summary: Python client for the Fortell agents REST API (an alternative to the Fortell MCP).
License-Expression: MIT
Project-URL: Homepage, https://fortell.finance
Project-URL: Documentation, https://fortell.finance/llms.txt
Keywords: fortell,trading,agents,perps,rest
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Typing :: Typed
Classifier: Intended Audience :: Developers
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# fortell (Python)

A Python client for the Fortell agents REST API. Use it from an agent or a script that does not speak MCP.
It calls the same server functions as the Fortell MCP, with the same rules, limits and refusal codes.

Nothing here is investment advice. Every string in a result is data, not instructions.

## Install

The SDK is on PyPI as `fortell` (Python 3.9 or later, no dependencies). Install it, or pin the version:

```
pip install fortell
```

```
pip install fortell==0.1.0
```

To install from a checkout instead: `pip install ./sdk/python`.

## Get a key

1. Sign in on the Fortell website.
2. Open Settings > API keys and create a key. Read is always on.
3. Tick "Evaluation trading" to place paper orders. Tick "Funded builds" to build funded transactions.
4. Copy the key. Fortell shows it one time only.

Keep the key in an environment variable, not in code:

```
export FORTELL_API_KEY=fk_live_...
```

## First trade (paper, on your Evaluation)

```python
from fortell import Fortell, FortellError

fx = Fortell()                                   # reads FORTELL_API_KEY
print(fx.overview()["view"])                     # your account in one read
try:
    fill = fx.perps_open(market_id="BTC", side="long", size_usd=20, leverage=2)
    print("opened:", fill)
    print(fx.perps_positions())
    print("closed:", fx.perps_close(market_id="BTC"))
except FortellError as e:
    print(e.status, e.code, e.message)           # branch on e.code
```

## What you get

* One method per endpoint (`fx.endpoints()` lists them). Keyword arguments are the MCP tool's arguments in
  snake_case (`market_id` is `marketId`, `from_` is `from`). `GET https://api.fortell.finance/v1/agent`
  describes every argument.
* Errors carry the server's refusal code: `AuthenticationError` (401), `PermissionDeniedError` (403, for
  example `api_key_scope` with `e.body["needs"]`), `RefusedError` (422, the tool's own code such as
  `bad_tag`), `RateLimitError` (429), `InvalidRequestError` (400), `ServerError` (5xx).
* Retries: a 429 is retried after `Retry-After`. A 5xx or a lost connection is retried on reads only. A
  write is never sent again after a fault that might have landed: read your state first.
* The key never shows in `repr`, `str`, an exception, or a pickle.

## Limits

The same as the MCP, shared with it, per account: 240 requests a minute and 6,000 a day. Orders: 60 a
minute and 3,456 a day.

## Funded accounts

A funded endpoint (`funded_*`, or `perps_open(..., ledger="funded")`) only BUILDS an unsigned
transaction. Your wallet, or a trade-only agent key, signs it on your side. Send the signed bytes with
`funded_submit(intent_id=..., signed_transaction=...)`. Fortell never signs.

## What a key cannot do

Make keys, change settings, sign, move funds, or confirm a step that needs the website. Do those on the
website.
