Quickstart
Go from nothing to a paid, key-protected API in about five minutes. You will launch an API in the dashboard, add two lines to a FastAPI app, and make a first request as one of your own customers.
You need Python 3.10 or newer and a FastAPI app. Using another language? The dashboard steps are the same, and Any other language replaces steps 2 to 4.
Launch your API
Sign up at app.microauth.com with your work email and the 6-digit code we send you. The launch wizard opens right away and asks two things:
- What's your API called? For example
Weather API. Your portal address, such asweather-api.microauth.dev, is filled in from the name. You can add your own domain later. - How should customers pay? Pick Free, Pay as you go or Monthly plans. Pay as you go starts at $0.001 per request with a $1.00 welcome credit for every new customer.
Click Launch. Your developer portal is live at once, and the next screen walks you through the steps below for your framework, with your SDK secret key (mas_...) ready to paste. It is shown once, so copy it now.
Install the SDK and add your key
pip install microauth-fastapiuv add microauth-fastapipoetry add microauth-fastapiPut the key in a .env file next to your app, or export it in your shell. The SDK reads either one.
# .env
MICROAUTH_SECRET_KEY=mas_...Protect a route
from fastapi import FastAPI, Security
from microauth_fastapi import Customer, MicroAuth
app = FastAPI()
auth = MicroAuth(app) # reads MICROAUTH_SECRET_KEY
@app.get("/hello")
async def hello(customer: Customer = Security(auth)):
return {"hello": customer.id}That one dependency adds API key checks, rate limits, quotas and billing to the route. Routes without it are untouched.
Run the check
python -m microauth_fastapi checkIt confirms the key works, loads your API's settings and connects the SDK to MicroAuth. The dashboard checks off the first steps and shows Your API is connected. If something is off, the check tells you what to fix. With uv or Poetry, put uv run or poetry run in front of the command. See the check command for every flag.
Then start your app as usual, for example fastapi dev main.py. Starting a new app? fastapi dev comes with pip install "fastapi[standard]".
Make a first request
Once the SDK is connected, the dashboard offers Create a test key. The key belongs to a built-in test customer that is never charged, and the dashboard gives you the request to run:
curl "http://127.0.0.1:8000/hello" -H "X-API-Key: map_..."Within a few seconds the dashboard shows Your API is live.
To see what your customers get, open your portal (the dashboard links to it) and sign up as a customer would. The portal creates the first API key automatically and shows a ready-to-run request on its welcome page. On pay as you go, that customer's requests are charged against their welcome credit.
What you have now
- A branded developer portal where customers sign up, create keys, add credit and see their usage.
- Key checks, rate limits and quotas enforced inside your own app, with no proxy in front of it and no network call on the request path.
- Usage counted and billed per customer, with a ledger for every cent.
Next steps
- Brand your portal with your logo, colors and docs link.
- Connect Stripe so customers can pay by card.
- Tune pricing or add monthly plans.
- Set your API's base URL so the portal's sample request points at your real API.
- Running more than one worker? Add Redis to share limits across them.
- Coming from Kong or another gateway? Read Coming from Kong.