Official Python SDK for SyncForge — control exactly when data syncs between your database and clients.
Project description
SyncForge Python SDK
Created by Suresh Dullu Polai
SyncForge is the FastAPI of data synchronization. It is a premium, developer-controlled smart data synchronization platform and Web Application Firewall (WAF).
Stop relying on dumb polling or expensive real-time sockets for static data. With SyncForge, you take full control over exactly when and how your applications sync data, saving millions of unnecessary database calls and drastically reducing server costs.
🌟 Best Features (A to Z)
- Zero-Polling Architecture: Clients never hit your database to check for updates. They only get notified when you tell SyncForge that data has changed.
- Built-in Web Application Firewall (WAF): Instantly protect your application from SQL Injection, Cross-Site Scripting (XSS), and Path Traversal attacks with a single line of code.
- Zero-Code Django Auto-Sync: Use our
@sync_modeldecorator to automatically sync data across all your client devices whenever a Django model is created, updated, or deleted. - Precision Logging: The middleware tracks request methods, paths, response statuses, and execution times in milliseconds.
- Framework Agnostic: First-class support for Django, FastAPI, Flask, or pure Python scripts.
- Zero External Dependencies: Built entirely on the Python Standard Library (
urllib,json,threading).
🚀 Installation
pip install syncforge
🛡️ Built-in WAF Security Middleware (Django)
SyncForge SDK includes a professional-grade Web Application Firewall (WAF) and request logger. By adding just one line to your settings.py, your entire application is instantly protected from hackers.
Features of the WAF:
- SQL Injection Protection: Blocks
UNION SELECT,OR 1=1, and other common SQLi payloads. - XSS Protection: Blocks
<script>tags and malicious javascript injections. - Path Traversal Protection: Blocks
../directory traversal attempts. - Security Headers: Automatically injects strict
X-Content-Type-Options: nosniff. - Performance Logging: Logs response times beautifully (e.g.,
[GET] /api/ - 200 (12.4ms)).
How to Install:
Add it to your Django MIDDLEWARE list in settings.py:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
# Add SyncForge Security Firewall right after Django's built-in security
'syncforge.middleware.SyncForgeSecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
# ...
]
No further configuration needed! Your app is now secure.
🔄 The @sync_model Decorator (Django Auto-Sync)
If you use Django, you never have to manually trigger a sync again. Use the @sync_model decorator. It hooks into Django's post_save and post_delete signals to automatically broadcast changes to all connected clients.
# models.py
from django.db import models
from syncforge import sf
from syncforge.django import sync_model
# 1. Zero-code Django auto-sync
@sync_model(sf, sync_mode='event')
class Product(models.Model):
name = models.CharField(max_length=100)
price = models.DecimalField(max_digits=10, decimal_places=2)
Whenever you call Product.objects.create(...) or product.delete(), SyncForge automatically invalidates the cache and pushes the new delta to every single user's device.
⚡ FastAPI & Flask Integration
SyncForge isn't just for Django. You can trigger manual updates from any Python backend.
FastAPI Example:
import os
from fastapi import FastAPI
from syncforge import SyncForge
# Initialize once
sf = SyncForge(api_key=os.environ.get('SYNCFORGE_API_KEY'))
app = FastAPI()
@app.post("/api/products/")
async def create_product(name: str):
# 1. Database operation
db.execute("INSERT INTO products (name) VALUES (?)", (name,))
# 2. Trigger sync — Non-blocking, instant broadcast
sf.refresh('products')
return {"status": "success"}
📚 Core API Reference
SyncForge(api_key, base_url, timeout, silent, async_mode)
| Parameter | Default | Description |
|---|---|---|
api_key |
required | Your API key from the developer dashboard |
base_url |
https://syncforge.dev/api |
Override for local dev / self-hosted |
timeout |
10 |
HTTP timeout in seconds |
silent |
False |
Suppress errors — logs warnings instead of crashing |
async_mode |
False |
Fire-and-forget — refresh runs in a background thread |
sf.refresh(*tables) → SyncResult | list[SyncResult]
Broadcasts a refresh signal for the specified tables.
sf.refresh('products') # single table
sf.refresh('products', 'categories', 'orders') # multiple at once
result = sf.refresh('products')
print(result.ok) # True
print(result.calls_saved) # 1854211 (Analytics data from SyncForge servers)
print(result.sync_mode) # 'Event — On INSERT / UPDATE / DELETE'
Advanced Usage
# Silent mode — SyncForge errors never crash your app
sf = SyncForge(api_key='sf_live_...', silent=True)
# Async mode — fire-and-forget, returns immediately
sf = SyncForge(api_key='sf_live_...', async_mode=True)
sf.refresh('products') # returns None, syncs in background
👨💻 About the Author
SyncForge is passionately built and maintained by Suresh Dullu Polai. Designed to bring Enterprise-Grade data synchronization and security to developers worldwide, entirely out of the box.
📄 License
MIT — see LICENSE
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syncforge-1.0.4.tar.gz.
File metadata
- Download URL: syncforge-1.0.4.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ff29471949dffe29e72a98120baca893cbf2d26aed48c78ac9fbbb6fd150f52
|
|
| MD5 |
4f2de3ea143cbceb11ed7edb005494d6
|
|
| BLAKE2b-256 |
1ab2862eea5ea38b6072b773a210a31f84f87e4f578404f92bc0789220d4a231
|
File details
Details for the file syncforge-1.0.4-py3-none-any.whl.
File metadata
- Download URL: syncforge-1.0.4-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96bfb6fe73ad00598a4b82d2c79926b531d804bed9c7a9cf3b1fb6455f0d0f25
|
|
| MD5 |
ce858a3a1bca1a2823cdd97112b8e410
|
|
| BLAKE2b-256 |
e48978650bbb324bc2780e469a848fc5892d45aa66d2722874f50ad1901b5e59
|