# 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())
```

## 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-openapi) renders them in the browser.

---

## All docs pages


**Get started**

- [Introduction](https://glim.sh/docs.md?page=introduction)
- [MCP quickstart](https://glim.sh/docs.md?page=quickstart)
- [REST API quickstart](https://glim.sh/docs.md?page=quickstart-rest)
- [JavaScript quickstart](https://glim.sh/docs.md?page=quickstart-js)
- [Python quickstart](https://glim.sh/docs.md?page=quickstart-python)
- [Payments & auth](https://glim.sh/docs.md?page=payments)

**Tools**

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

**Reference**

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