Skip to content

Commit dda7bc8

Browse files
committed
update readme
1 parent d0b8101 commit dda7bc8

1 file changed

Lines changed: 50 additions & 6 deletions

File tree

README.md

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,62 @@
11
# stackcoin-python
22

3-
Python client for interacting with the StackCoin HTTP API.
3+
Python library for the StackCoin API. Provides a typed async REST client and a WebSocket gateway for real-time events.
44

5-
https://pypi.org/project/stackcoin/
5+
## Install
66

77
```sh
88
pip install stackcoin
99
```
1010

11+
Requires Python 3.13+. Dependencies: `httpx`, `pydantic>=2`, `websockets`.
12+
13+
## Quick start
14+
15+
```python
16+
import asyncio
17+
import stackcoin
18+
19+
async def main():
20+
async with stackcoin.Client(token="...") as client:
21+
me = await client.get_me()
22+
print(f"{me.username}: {me.balance} STK")
23+
24+
events = await client.get_events()
25+
for event in events:
26+
print(f"[{event.type}] {event.data}")
27+
28+
asyncio.run(main())
29+
```
30+
31+
## Gateway (real-time events)
32+
33+
```python
34+
import stackcoin
35+
36+
gateway = stackcoin.Gateway(token="...")
37+
38+
@gateway.on("transfer.completed")
39+
async def on_transfer(event: stackcoin.TransferCompletedEvent):
40+
print(f"Transfer of {event.data.amount} STK from #{event.data.from_id} to #{event.data.to_id}")
41+
42+
@gateway.on("request.accepted")
43+
async def on_accepted(event: stackcoin.RequestAcceptedEvent):
44+
print(f"Request #{event.data.request_id} accepted")
45+
46+
await gateway.connect()
47+
```
48+
1149
## Examples
1250

13-
- `./examples/basic_usage.py`, bare bones creation of `AuthenticatedClient`, checking balance, making some requests, etc.
14-
- `./examples/simple_cli.py`, thorough usage of the API in a bare-bones command line interface.
51+
- `examples/basic_usage.py` -- REST client basics (balance, requests, transactions)
52+
- `examples/simple_cli.py` -- interactive REPL with live gateway events
1553

16-
---
54+
## Development
55+
56+
Models are generated from the StackCoin OpenAPI spec using `datamodel-codegen`:
57+
58+
```sh
59+
STACKCOIN_ROOT=/path/to/StackCoin just generate
60+
```
1761

18-
This package is generated by running [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) against [StackCoin's OpenAPI specification](https://stackcoin.world/swaggerui), the `./stackcoin` directory in this repository is the package, and is generated by running `just generate` (or running the commands under `generate` in the `Justfile`).
62+
This regenerates `stackcoin/stackcoin/models.py` from `openapi.json`.

0 commit comments

Comments
 (0)