Open-source • No SDK • REST
Generate QR codes with a single API call
PNG, SVG, ASCII, or JSON. Free, simple, and deployable to Vercel in minutes.
Formats
PNG • SVG • ASCII • JSON
Endpoint
POST /api/generate
Hosted
Vercel-ready
Overview
QRCodeAPI is a simple, open-source QR Code Generator API built from scratch. It supports generating QR codes in PNG, SVG, ASCII, and JSON formats.
- Generate QR codes via a REST API
- Output formats: PNG, SVG, ASCII (terminal), JSON (matrix)
- Public rate limiting
- Easy to deploy on Vercel
Note: PNG width/height are supported; colors apply to PNG and SVG.
Quickstart
bash
curl -X POST https://<your-app-url>/api/generate \
-H "Content-Type: application/json" \
-d '{"text":"Hello World","type":"png"}' --output qrcode.png
powershell
Invoke-RestMethod -Uri "https://<your-app-url>/api/generate" -Method POST -ContentType "application/json" -Body '{"text":"Hello World","type":"svg"}' > qrcode.svg
API
| Method | Endpoint | Description |
|---|---|---|
POST | /api/generate | Create a QR code |
Request Body
JSON
{
"text": "Hello World",
"type": "png" // "svg" | "ascii" | "json"
}
Optional (PNG/SVG):
colorForeground (default#000)bgColorBackground (default#fff)width,height(PNG only)
Examples
bash
curl -X POST https://<api-url>/api/generate \
-H "Content-Type: application/json" \
-d '{"text":"Hello","type":"png"}' \
--output qrcode.png
powershell
Invoke-RestMethod `
-Uri "https://<api-url>/api/generate" `
-Method POST `
-ContentType "application/json" `
-Body '{"text":"Hello","type":"svg"}'
If calling from the browser on a different origin, ensure CORS is enabled on your deployment.
Example QR Codes
1) Website URL
Encodes https://example.com
powershell
Invoke-RestMethod `
-Uri "https://<api-url>/api/generate" `
-Method POST `
-ContentType "application/json" `
-Body '{"text":"https://example.com","type":"png"}' `
-OutFile "example_com.png"
bash
curl -X POST https://<api-url>/api/generate \
-H "Content-Type: application/json" \
-d '{"text":"https://example.com","type":"png"}' \
--output example_com.png
2) WiFi QR Code
Format your text as: WIFI:T:WPA;S:MyNetwork;P:MyPassword;;
powershell
Invoke-RestMethod `
-Uri "https://<api-url>/api/generate" `
-Method POST `
-ContentType "application/json" `
-Body '{"text":"WIFI:T:WPA;S:MyNet;P:MyPass;;","type":"svg"}' `
> wifi_qr.svg
bash
curl -X POST https://<api-url>/api/generate \
-H "Content-Type: application/json" \
-d '{"text":"WIFI:T:WPA;S:MyNet;P:MyPass;;","type":"png"}' \
--output wifi_qr.png
Playground
Test the API directly from your browser.
Result
Fill the form and hit Generate.
Equivalent request
bash
curl -X POST <base-url>/api/generate \
-H "Content-Type: application/json" \
-d '{"text":"Hello World","type":"png"}' \
--output qrcode.png
powershell
Invoke-RestMethod `
-Uri "<base-url>/api/generate" `
-Method POST `
-ContentType "application/json" `
-Body '{"text":"Hello World","type":"png"}' `
-OutFile "qrcode.png"
Rate limiting may apply on public deployments.
Deployment
- Clone the repo:
git clone https://github.com/raigon-pawa/QRCodeAPI.git - Install dependencies:
npm install - Deploy to Vercel:
- Import the repo in Vercel
- Vercel will auto-detect the
/api/generateendpoint
Local dev: npm start then call http://localhost:3000/api/generate
License
MIT — Use it freely in commercial or personal projects. Attribution appreciated.