Skip to main content

fastsyftbox

Logo

PyPI - Version PyPI - Python Version PyPI - Downloads Tests License MadeWith


Build offline-first Python apps with FastAPI and SyftBox — FAST.

🚀 Features

  • Build local admin UIs with FastAPI.
  • Build delay-tolerant UIs/APIs using SyftEvents.
  • Keep private data offline with SyftBox HTTP over RPC.
  • Builtin JS SDK with fetch compatible syntax
  • Debug APIs with a built-in Postman-style interface.

🔧 Purpose

How can you build a web app that runs on your own device, without uploading data to the cloud?

With SyftBox, you can:

  • Run a webserver anywhere that can go offline and keep functioning when it comes back online.
  • Access your data even when offline or when your laptop lid is closed.

⚡ Quick Start

Install with uv and create your app:

uvx fastsyftbox version
uvx fastsyftbox create app test

To start in hot-reloading more:

cd test
./run.sh

This generates a sample FastAPI app in app.py:

app = FastSyftBox(
    app_name=app_name,
    syftbox_endpoint_tags=[
        "syftbox"
    ],  # endpoints with this tag are also available via Syft RPC
    include_syft_openapi=True,  # Create OpenAPI endpoints for syft-rpc routes
)


# normal fastapi
@app.get("/", response_class=HTMLResponse)
def root():
    return HTMLResponse("<html><body><h1>Welcome to {app_name}</h1>")


# build a model with pydantic
class MessageModel(BaseModel):
    message: str
    name: str | None = None

# make syftbox rpc endpoints easily
# syft://{datasite}/app_data/{app_name}/rpc/hello
@app.post("/hello", tags=["syftbox"])
def hello_handler(request: MessageModel):
    print("got request", request)
    response = MessageModel(message=f"Hi {request.name}", name="Bob")
    return response.model_dump_json()

# Debug your RPC endpoints in the browser
app.enable_debug_tool(
    endpoint="/hello",
    example_request=str(MessageModel(message="Hello!", name="Alice").model_dump_json()),
    publish=True,
)

HTTP / JS

Vanilla JS fetch:

const url = "http://somewebsite.com/api"
const request = await fetch(url, {
    method: 'POST',
    headers,
    body
});

Becomes syftFetch:

const syftUrl = "syft://madhava@openmined.org/app_data/fastsyftbox/rpc/hello"
const request = await syftFetch(syftUrl, {
    method: 'POST',
    headers,
    body
});

Under the hood:

  • Translates to the correct HTTP request
  • Adds syft-x headers
  • Waits for queued response
  • Polls future until completed

What is SyftBox?

SyftBox is a new platform for building privacy-preserving applications and experiences that work over the internet without uploading your data. Instead of sending your data to a server, SyftBox lets you run powerful AI and analytics locally or in trusted environments, so your personal information stays private and secure.

Read more about SyftBox here

🧱 Your Dependencies

Add any Python dependencies to requirements.txt and run.sh will install them fresh every run.

🧪 RPC Debug Tool

Its like Postman but for SyftBox RPC.

A built-in HTML/JS tool helps you debug your HTTP over RPC endpoints. To enable:

app.enable_debug_tool(
    endpoint="/hello",
    example_request=str(MessageModel(message="Hello!", name="Alice").model_dump_json()),
    publish=True,
)

🧭 Construct syft:// RPC URLs

Debug Tool Screenshot

🎯 Configure custom headers

Debug Tool Screenshot

🔍 View real-time responses

Debug Tool Screenshot

Then visit either: http://localhost:${SYFTBOX_ASSIGNED_PORT}/rpc-debug or if you have publish=True https://syftbox.net/datasites/{{ email }}/public/{{ app_name }}/rpc-debug.html

📥 SyftBox App Install via GitHub

syftbox app install GITHUB_URL

This executes run.sh and binds your app to a random port: http://localhost:${SYFTBOX_ASSIGNED_PORT}

📚 Example fastsyftbox Apps

Metadata

Release files for fastsyftbox 0.1.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastsyftbox 0.1.21
File Size Uploaded Provenance
fastsyftbox-0.1.21.tar.gz 30.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fastsyftbox 0.1.21
File Interpreter ABI Platform
fastsyftbox-0.1.21-py3-none-any.whl Python 3 none any Details

Total release size: 65.3 kB

Release files / fastsyftbox-0.1.21.tar.gz

Download URL fastsyftbox-0.1.21.tar.gz
Size 30.4 kB
Tags Source
SHA-256 checksum
How to use checksums
77d6744e91afa03565ef7482235c0de3311465991205123afeec0adabd4038dd
BLAKE2b-256 checksum
How to use checksums
afb45a8453fc4526412aa1d153b3086e4bfdf47bb5e58ecda6fe73f14c62a61c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Release files / fastsyftbox-0.1.21-py3-none-any.whl

Download URL fastsyftbox-0.1.21-py3-none-any.whl
Size 34.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a6e4a2ef0e93d192eb9e6b9ec7e870e8a61e15c9be74c622929caeb2e139350
BLAKE2b-256 checksum
How to use checksums
c7b9bba6693b66b376d3603f911db659017f81c23a2e00b6e318a4142fb798b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Security for fastsyftbox 0.1.21

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page