X Tutup
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Python API

FastAPI service for fetching and processing market data with Redis-backed storage, JWT authentication, gRPC streaming, and OpenTelemetry observability.

Prerequisites

  • Python 3.11+
  • uv for dependency management
  • Redis (local or Docker)

Quick Start

# Start Redis
make redis-up

# Install dependencies
cd python-api && uv sync

# Copy and configure env
cp .env.example ../config/python-api.env
# Edit python-api.env — set JWT_SECRET_KEY (min 32 chars)

# Run the API server
make py-run

The API is available at http://localhost:8000. Interactive docs at /docs.

Development

# Run tests (requires Redis on localhost:6379)
make py-test

# Lint & format
make py-lint
make py-format

# Type checking
make py-check

Project Structure

src/python_api/
├── api/              # FastAPI routes and dependencies
│   ├── routes/       # auth, health, market, price
│   └── dependencies.py
├── grpc/             # gRPC server and protobuf definitions
├── middleware/        # Rate limiting, request ID
├── models/           # Pydantic request/response schemas
├── services/         # Business logic (auth, Rust API client)
└── utils/            # Config, logging, telemetry, errors

API Endpoints

Method Path Auth Description
GET /health/live No Liveness probe
GET /health/ready No Readiness probe (Redis)
POST /api/v1/auth/signup No Register a new user
POST /api/v1/auth/signin No Sign in and get JWT tokens
POST /api/v1/auth/signout Yes Revoke current token
GET /api/v1/price/{pair} Yes Get price for a pair
GET /api/v1/prices?pairs= Yes Get prices for multiple pairs
GET /api/v1/pairs Yes List available pairs
GET /allmids No Proxy to Rust API

Environment Variables

See .env.example for a full list with defaults.

X Tutup