Skip to content

stayforge/Cloudflare-QRCode-generation-API

 
 

Repository files navigation

Cloudflare-QRCode-generation-API

Easy Cloudflare Worker QR code generation API.

Usage

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.

Example

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/

Deployment

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.

Option 1: Deploy via Cloudflare Dashboard (GitHub Integration)

This is the easiest way to deploy and keep your worker updated.

  1. 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.
  2. Log in to Cloudflare: Go to the Cloudflare Dashboard and log in.
  3. Navigate to Workers & Pages: In the sidebar, click on Workers & Pages -> Overview.
  4. Create a Worker: Click the Create application button, then select the Workers tab and click Create Worker.
  5. 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-API repository.
  6. Configure and Deploy:
    • Project Name: Choose a name for your API.
    • Production branch: Usually main or master.
    • Framework preset: Select None (or it might auto-detect).
    • Build command: npm run build (if applicable) or leave empty if using wrangler. 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.

Option 2: Deploy via Command Line (Wrangler)

  1. Clone your fork:
    git clone https://github.com/your-username/Cloudflare-QRCode-generation-API.git
    cd Cloudflare-QRCode-generation-API
  2. Install Dependencies:
    npm install
  3. Login to Cloudflare:
    npx wrangler login
  4. Deploy:
    npx wrangler deploy

Your API will be live at https://your-worker-name.your-subdomain.workers.dev.

About

Easy Cloudflare Worker QR code generation API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 88.6%
  • JavaScript 11.4%