A simple and powerful API for generating customizable QR codes from text or URLs, built with FastAPI.
- Built with FastAPI - modern, fast Python web framework
- Interactive API documentation with OpenAPI and Swagger UI
- Generate QR codes from any text or URL
- Customize size (S, M, L)
- Adjust margins/borders
- Multiple error correction levels (L, M, Q, H)
- Returns QR code as PNG image
- Asynchronous request handling
- Python 3.10 or higher
- pip (Python package manager)
git clone https://github.com/heirro/qrcode-generator-api.git
cd qrcode-generator-api# For Windows
python -m venv venv
venv\Scripts\activate
# For macOS/Linux
python3 -m venv venv
source venv/bin/activateFirst, install FastAPI with all standard dependencies and wheel:
pip install "fastapi[standard]"
pip install wheelpip install -r requirements.txtStart the FastAPI server:
fastapi dev main.pyThe API will be available at http://localhost:8000/
GET /api/create
Parameters:
data(required): The text or URL to encode in the QR codesize(optional): QR code size - S (small), M (medium), or L (large)margin(optional): Border width around the QR codeerror_level(optional): Error correction level - L (Low, 7% recovery), M (Medium, 15% recovery), Q (Quartile, 25% recovery), H (High, 30% recovery)
Example Usage:
# Basic QR code for a URL
http://localhost:8000/api/create?data=https://example.com# Customized QR code
http://localhost:8000/api/create?data=https://example.com&size=L&margin=2&error_level=HOne of the best features of FastAPI is the automatic interactive documentation:
- Swagger UI documentation: http://localhost:8000/
- Try out API endpoints directly from your browser
- Explore all available parameters and options
FastAPI applications can be easily deployed:
# Production server
fastapi run main:app --host 0.0.0.0 --port 8000Demo: https://qrcode.heirro.dev
Example Usage:
# Basic QR code for a URL
https://qrcode.heirro.dev/api/create?data=https://example.com# Customized QR code
https://qrcode.heirro.dev/api/create?data=https://example.com&size=L&margin=2&error_level=HMIT