# Python

glim is plain HTTPS + JSON — `requests` or `httpx` is the whole integration. Add the x402 client if you want to pay per call from a wallet instead of an API key.

## With an API key

Create a key at `glim.sh/app` and send it as an `x-api-key` header (or `Authorization: Bearer`):

**requests — API key**

```
import os
import requests

res = requests.post(
    "https://glim.sh/api/v1/web/search",
    headers={"x-api-key": os.environ["GLIM_API_KEY"]},
    json={"query": "x402 protocol"},
)
print(res.json())
```

## Pay per call with a wallet

The `x402` package wraps a `requests` session so a `402` response is paid automatically and retried — no account, no key. Fund the wallet with USDC on `Base`:

**install**

```
pip install "x402[requests,evm]"
```

**requests — wallet pays on 402**

```
import os
from eth_account import Account
from x402 import x402ClientSync
from x402.http.clients.requests import x402_requests
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact import register_exact_evm_client

client = x402ClientSync()
register_exact_evm_client(
    client, EthAccountSigner(Account.from_key(os.environ["EVM_PRIVATE_KEY"]))
)

session = x402_requests(client)
res = session.post(
    "https://glim.sh/api/v1/web/search",
    json={"query": "x402 protocol"},
)
print(res.json())
```

To pay on Tempo, see the [MPP request and response headers](https://glim.sh/docs/mpp.md).

## Every tool, same shape

Swap the path and body to reach any tool — `twitter/search`, `reddit/get`, `web/fetch`, `github/search`, and the rest. The [OpenAPI spec](https://glim.sh/openapi.json) carries typed schemas and a copy-pasteable example for each; the [API reference](https://glim.sh/docs/api-reference) renders them in the browser.

---

## All docs pages


**Get started**

- [Introduction](https://glim.sh/docs.md)
- [MCP quickstart](https://glim.sh/docs/quickstart.md)
- [REST API quickstart](https://glim.sh/docs/quickstart-rest.md)
- [JavaScript quickstart](https://glim.sh/docs/quickstart-javascript.md)
- [Python quickstart](https://glim.sh/docs/quickstart-python.md)
- [Payments & auth](https://glim.sh/docs/payments.md)
- [MPP (Tempo)](https://glim.sh/docs/mpp.md)

**Tools**

- [Twitter / X](https://glim.sh/docs/twitter.md)
- [Reddit](https://glim.sh/docs/reddit.md)
- [Web](https://glim.sh/docs/web.md)
- [GitHub](https://glim.sh/docs/github.md)
- [Amazon](https://glim.sh/docs/amazon.md)
- [YouTube](https://glim.sh/docs/youtube.md)
- [Telegram](https://glim.sh/docs/telegram.md)

**Reference**

- [Changelog](https://glim.sh/docs/changelog.md)
- [API reference](https://glim.sh/docs/api-reference)
- [OpenAPI spec](https://glim.sh/openapi.json)
