Easy Cloudflare Worker QR code generation API.
Send a GET request to the worker with the following parameters:
text*: The content of the QR code (required).size: Approximate total width in pixels (default: 300).margin: Margin in blocks (default: 4).level: Error correction level:L,M(default),Q,H. Higher levels are more secure but result in larger/denser QR codes.type: Output format:png(default),svg,pdf,eps.
Content:https://github.com
https://your-worker.workers.dev/?text=https%3A%2F%2Fgithub.com&size=300
Note: When passing in the URL, you must convert it to encodeURIComponent, otherwise an error will occur.
Encode URL here: https://www.urlencoder.org/
Deploying to Cloudflare Workers is simpler than you think.
Fork this Repository - Create Worker - Connect to GitHub - Deploy
The task can be completed in roughly four steps.
This is the easiest way to deploy and keep your worker updated.
- Fork this Repository: Click the Fork button at the top right of this page to create a copy of this repository in your own GitHub account.
- Log in to Cloudflare: Go to the Cloudflare Dashboard and log in.
- Navigate to Workers & Pages: In the sidebar, click on Workers & Pages -> Overview.
- Create a Worker: Click the Create application button, then select the Workers tab and click Create Worker.
- Connect to GitHub:
- Instead of using the online editor, go back to the Workers & Pages overview.
- Click Create application -> Pages tab -> Connect to Git.
- Select GitHub and authorize Cloudflare to access your repositories.
- Select your forked
Cloudflare-QRCode-generation-APIrepository.
- Configure and Deploy:
- Project Name: Choose a name for your API.
- Production branch: Usually
mainormaster. - Framework preset: Select None (or it might auto-detect).
- Build command:
npm run build(if applicable) or leave empty if usingwrangler. Actually, for Workers, Cloudflare usually recommends the Git integration directly through the Worker setup or using Wrangler. - Note for Workers: If you prefer the dedicated Workers integration:
- Go to Workers & Pages -> Create application -> Workers -> Deploy from GitHub (if available) or use the Wrangler CLI for better control.
- Clone your fork:
git clone https://github.com/your-username/Cloudflare-QRCode-generation-API.git cd Cloudflare-QRCode-generation-API - Install Dependencies:
npm install
- Login to Cloudflare:
npx wrangler login
- Deploy:
npx wrangler deploy
Your API will be live at https://your-worker-name.your-subdomain.workers.dev.