Skip to content

Add FastAPI REST interface to SMSgate - #3

Draft
chuckleu1976 with Copilot wants to merge 2 commits into
mainfrom
copilot/add-new-fast-api-interface
Draft

Add FastAPI REST interface to SMSgate#3
chuckleu1976 with Copilot wants to merge 2 commits into
mainfrom
copilot/add-new-fast-api-interface

Conversation

Copilot AI commented Apr 1, 2026

Copy link
Copy Markdown

SMSgate only exposed a Twisted XML-RPC API. This adds a parallel FastAPI/uvicorn REST interface that mirrors every XML-RPC operation, with auto-generated OpenAPI docs at /docs.

New: server/fastapi_server.py

Endpoint Operation
GET /ping Liveness check
POST /sms/send Queue outbound SMS
GET /sms/delivery-status/{sms_id} Poll delivery status
POST /sms/received Retrieve buffered inbound SMS
POST /ussd/send Send USSD code
GET /health Combined pool + SMTP health
GET /stats Per-modem statistics
  • Reuses the same bcrypt token validation and [api] config keys as the XML-RPC server
  • Optional TLS via uvicorn ssl_certfile/ssl_keyfile
  • create_app() factory is separately importable for testing

Integration (server/smsgate.py)

FastAPI server starts as a daemon thread alongside the Twisted reactor — opt-in via config:

[fastapi]
enabled = True
host = localhost
port = 8000
# certificate = cert.pem  # optional TLS
# key = key.pem

Dependencies (requirements.txt)

Added: fastapi==0.135.2, uvicorn==0.42.0, pydantic==2.12.5, starlette==1.0.0, h11==0.16.0, click==8.3.1, anyio==4.9.0, annotated-types==0.7.0, pydantic_core==2.41.5

Original prompt

based on the project add new fast api interface

Copilot AI changed the title [WIP] Add new FastAPI interface Add FastAPI REST interface to SMSgate Apr 1, 2026
Copilot AI requested a review from chuckleu1976 April 1, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants