Appearance
Quickstart
This takes about five minutes. You will launch an API in the dashboard, add the SDK to a FastAPI app and send a request with a test key.
You need Python 3.10 or newer and a FastAPI app. Using another language? The dashboard steps are the same, and the HTTP API guide replaces steps 3 to 5.
Create your account
Sign up at microauth.com/app/signup with your work email. We send a 6 digit code to confirm it, then you choose your name and a password. That creates your workspace.
Launch your API
The dashboard asks for three things:
- API name, for example
Weather API. It is shown on your portal and in emails. - Portal address, filled in from the name, like
weather-api.microauth.dev. You can add your own domain later. - How do you want to charge? Pick Pay as you go, Free with a quota or Monthly plans. Each one fills in sensible prices and limits that you can change at any time. See Pricing and payments.
Click Create API. Your portal is live right away, and the next screen shows your SDK secret key (mas_...). Your server uses it to talk to MicroAuth. You can reveal it again later from the Connect tab.
Install the SDK
bash
pip install microauth-fastapibash
uv add microauth-fastapibash
poetry add microauth-fastapiPut the secret in a .env file next to your app, or export it in your shell. The SDK reads either one.
bash
# .env
MICROAUTH_SECRET_KEY=mas_...Protect a route
python
from fastapi import FastAPI, Security
from microauth_fastapi import Customer, MicroAuth
app = FastAPI()
auth = MicroAuth(app) # reads MICROAUTH_SECRET_KEY
@app.get("/forecast")
async def forecast(customer: Customer = Security(auth)):
return {"customer": customer.id}That one dependency adds key checks, rate limits, quotas and billing to the route. Routes without it are left alone.
Run the check
bash
python -m microauth_fastapi checkIt confirms the secret works and loads your API's customers. The Connect tab in the dashboard turns green and says Your API is connected. If something is wrong, the check says what to fix. With uv or Poetry, put uv run or poetry run in front of the command. See the check command for every option.
Then start your app as usual, for example fastapi dev main.py.
Make a test request
The Connect tab has a test key that belongs to a built in test customer. It pays with test credit, so no real money moves, and it doesn't count as one of your customers. Copy the request it shows you:
bash
curl "http://127.0.0.1:8000/forecast" -H "X-API-Key: map_..."Within a few seconds the dashboard shows Requests are being counted.
What you have now
- A developer portal where customers sign up, create keys, add credit or pick a plan, and see their usage.
- Key checks, rate limits and quotas enforced inside your own app, with no proxy in front of it.
- Usage counted per customer and charged at your prices, with a ledger entry for every change to a balance.
To see what your customers get, open your portal from the dashboard and sign up as a developer would.
Next steps
- Connect Stripe so customers can pay by card.
- Brand your portal with your logo, colors and links.
- Set your API's base URL on the Portal tab so code samples show your real address.
- Running more than one worker? Add Redis so they share limits.
- Moving off a gateway? Read Coming from Kong.