Variant Systems

Python & FastAPI for B2B SaaS

API-first SaaS backends that your customers actually want to integrate with.

Variant Systems builds industry-specific software with the tools that fit the problem.

Why this combination

  • FastAPI generates OpenAPI docs automatically. Your integration partners get interactive API documentation without you writing a single line of it.
  • Python's async support handles webhook delivery, background tasks, and long-running API calls without blocking your main request loop.
  • Type hints and Pydantic models catch data validation errors before they reach your database. Fewer bugs, less defensive code.
  • Python's ecosystem for data processing, ML, and analytics means your SaaS can add smart features without switching languages.

API-First Architecture

B2B SaaS products don’t exist in isolation. Your customers want to connect your product to their CRM, their billing system, their data warehouse. FastAPI makes this integration-friendly from day one. Define your endpoints with type hints, and you get OpenAPI documentation automatically. Your customers’ developers can explore your API in a browser before writing a single line of integration code.

Pydantic models validate every request body and response. A customer sends malformed JSON? They get a clear error message explaining exactly which field failed and why. This isn’t just developer convenience. It’s fewer support tickets and faster integration cycles. When your sales team says “we have a public API,” they can actually back it up. FastAPI’s dependency injection system also makes it straightforward to layer cross-cutting concerns like tenant resolution, permission checks, and usage metering onto endpoints without cluttering your business logic. Define a dependency that extracts the tenant from the API key, and every downstream handler receives a fully authenticated context object.

Webhook Systems That Don’t Drop Events

Every serious SaaS product needs webhooks. Your customers want to know when a subscription renews, when a user is added, when a report finishes. Building reliable webhook delivery is harder than it looks. Events need to be queued, retried on failure, and signed so customers can verify they came from you.

FastAPI’s background tasks handle simple fire-and-forget delivery. For production workloads, pair it with Celery and Redis. Queue the webhook event, attempt delivery, and if the customer’s endpoint is down, retry with exponential backoff. Store delivery attempts so customers can see what was sent and when. This reliability is what separates a toy API from one that enterprises trust.

Async Processing for Heavy Workloads

SaaS products accumulate background work. Usage metering runs every hour. Subscription renewals process at midnight. Monthly reports generate for every customer on the first of the month. FastAPI’s native async support handles I/O-bound tasks efficiently, and Celery manages CPU-bound and scheduled work.

The pattern is clean. Your API endpoint accepts the request, queues the heavy work, and returns immediately with a job ID. The customer polls for status or gets a webhook when it’s done. No long-running HTTP requests that time out. No users staring at spinners. Your API stays responsive even during peak processing periods because the heavy lifting happens in worker processes. Celery Beat handles the scheduling side — define your periodic tasks in code and they run reliably without cron jobs scattered across servers. For usage-based billing, this means you can aggregate API call counts per tenant every hour, compute overages, and have invoice-ready data without a separate data pipeline.

Type Safety Without the Ceremony

Python gets criticized for being loosely typed. FastAPI flips that argument. Pydantic models define your data shapes with type hints. The framework validates incoming data, serializes outgoing data, and generates documentation from those same models. You define the shape once and it’s enforced everywhere.

This matters for SaaS because your API contract is your product. When a customer integrates with your API, they’re depending on consistent data shapes. Pydantic catches breaking changes at development time, not in production. Your CI pipeline runs type checking with mypy, and you catch the bug before it reaches a customer’s integration. Less firefighting, more shipping. You can also generate client SDKs directly from the OpenAPI spec that FastAPI produces, giving customers typed Python, TypeScript, or Go clients without maintaining separate codebases. When you add a field to a Pydantic response model, the generated SDK picks it up automatically on the next publish.

Compliance considerations

SOC 2 API security is straightforward with FastAPI's dependency injection for authentication and authorization on every endpoint.
GDPR data export endpoints are easy to build when your models are already defined with Pydantic schemas.
Rate limiting and API key management protect your SaaS from abuse while giving customers predictable access patterns.
Request logging middleware captures every API call with timestamps, user context, and response codes for audit trails.

Common patterns we build

  • Webhook delivery systems with retry logic, signature verification, and delivery status tracking for customer integrations.
  • API versioning through URL prefixes and separate router modules, so you can evolve without breaking existing customers.
  • Background task processing with Celery for subscription renewals, usage aggregation, and scheduled report generation.
  • OAuth 2.0 and API key authentication with scoped permissions for third-party integrations and customer API access.

Other technologies

Services

Building in B2B SaaS?

We understand the unique challenges. Let's talk about your project.

Get in touch