Skip to content

flo-finance/flo-quickstart-fastapi

Repository files navigation

flo-quickstart-fastapi

CI License: MIT

Mint a tokenized US equity from a Python FastAPI backend.

Heads up. The Flo sandbox API is in private beta for design partners. With no FLO_SANDBOX_KEY set, this service runs in mock mode and returns canned responses. To call the live sandbox, apply for design-partner access.

A small FastAPI service that exposes POST /tokenize and GET /positions/{wallet}. Both call the Flo sandbox under the hood (POST /v1/mint, GET /v1/positions). Useful as a starting point for any Python backend that wants to ship US equity exposure to its users without the broker-dealer integration.

What it does

POST /tokenize takes { asset, quantity, wallet } and returns the minted token, its contract address, and the settlement tx hash. GET /positions/{wallet} returns every Flo-issued position for that wallet.

Behind the scenes Flo handles the broker-dealer leg, custody under SEC Rule 15c3-3, and the on-chain mint. From this service's perspective, it's two HTTP calls.

Run it

git clone https://github.com/flo-finance/flo-quickstart-fastapi
cd flo-quickstart-fastapi
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload

The service starts in mock mode. To call the live sandbox:

cp .env.example .env
# paste your sandbox key from https://flo.finance/dashboard/developers/keys

Or with Docker

docker build -t flo-quickstart-fastapi .
docker run --rm -p 8000:8000 -e FLO_MOCK=1 flo-quickstart-fastapi
# or pass a real key
docker run --rm -p 8000:8000 -e FLO_SANDBOX_KEY=sk_test_... flo-quickstart-fastapi

Run the tests

pip install pytest
pytest -q

Then in another terminal:

curl -X POST http://localhost:8000/tokenize \
  -H "Content-Type: application/json" \
  -d '{"asset":"AAPL","quantity":10,"wallet":"0x4a8B70fa12cC3d9d3c9b22Ac019bE40a7d11c5bE"}'

You get back a mint ID, a token contract address on Base, and a settlement tx hash.

Going live

Swap FLO_SANDBOX_KEY for FLO_LIVE_KEY in .env and change BASE_URL in main.py from sandbox.flo.finance to api.flo.finance. KYB review takes about two business days.

Useful next steps

License

MIT.

About

Mint a tokenized US equity from a Python FastAPI backend using the Flo API.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors