Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/dadu0699/qr-code/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you through cloning the repository, starting a local development server, and making your first request to POST /api/qr/generate. By the end you will have a working SVG QR code saved to your machine and a clear understanding of the request/response shape.
1

Prerequisites

Make sure the following tools are installed before continuing.Node.js v24 or later
node --version
# Expected: v24.x.x or higher
pnpm
pnpm --version
# Expected: 11.x.x or higher
If pnpm is not installed, enable it via Node.js’s built-in Corepack:
corepack enable
corepack prepare pnpm@latest --activate
2

Clone & Install

Clone the repository and install all dependencies with pnpm.
git clone https://github.com/dadu0699/qr-code.git
cd qr-code
pnpm install
pnpm resolves the exact versions pinned in pnpm-lock.yaml and links packages via a content-addressed store, keeping your node_modules lean.
3

Start the Dev Server

Launch the Astro development server. Wrangler generates the Cloudflare Workers type declarations first, then Astro starts with hot-module replacement enabled.
pnpm dev
The server starts on port 4321. You should see output similar to:
┃ Local    http://localhost:4321/
┃ Network  use --host to expose
Open http://localhost:4321 in a browser to explore the built-in web UI, or proceed to the next step to call the API directly.
4

Make Your First Request

With the dev server running, send a POST request to /api/qr/generate. The endpoint accepts a JSON body and returns an image/svg+xml response.
curl -X POST http://localhost:4321/api/qr/generate \
  -H 'Content-Type: application/json' \
  -d '{"url": "https://github.com/dadu0699/qr-code"}'
A successful response returns HTTP 200 with Content-Type: image/svg+xml and an SVG document in the body:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ...">
  <!-- QR code path data -->
</svg>
When no color object is provided, the API uses the default color scheme: dark #000000 (foreground modules) and light #FFFFFF (background). These defaults maximise compatibility with all standard QR code scanners.
You can also pass custom hex colors to match your brand:
curl -X POST http://localhost:4321/api/qr/generate \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://github.com/dadu0699/qr-code",
    "color": {
      "dark": "#1a1a2e",
      "light": "#f0f0f0"
    }
  }'
Valid color formats are #RGB, #RGBA, #RRGGBB, and #RRGGBBAA. Passing any other format returns a 400 error with a descriptive JSON message.
5

View the SVG

Save the SVG to a file and open it directly in your browser or any SVG viewer:
curl -X POST http://localhost:4321/api/qr/generate \
  -H 'Content-Type: application/json' \
  -d '{"url": "https://github.com/dadu0699/qr-code"}' \
  -o qr-code.svg

# macOS
open qr-code.svg

# Linux (xdg-open)
xdg-open qr-code.svg

# Windows
start qr-code.svg
Because the response is a plain SVG document, you can also embed it inline in any HTML page:
<!-- Fetch and inject the SVG markup inline -->
<div id="qr"></div>
<script>
  fetch('/api/qr/generate', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ url: 'https://example.com' }),
  })
    .then((r) => r.text())
    .then((svg) => {
      document.getElementById('qr').innerHTML = svg;
    });
</script>

Example Request & Response

Request body shape (QRCodeRequest):
{
  "url": "https://github.com/dadu0699/qr-code",
  "color": {
    "dark": "#000000",
    "light": "#FFFFFF"
  }
}
FieldTypeRequiredDescription
urlstring✅ YesThe HTTP or HTTPS URL to encode. Maximum 2 048 characters.
color.darkstring❌ NoHex color for QR modules (foreground). Defaults to #000000.
color.lightstring❌ NoHex color for the background. Defaults to #FFFFFF.
Success response:
HTTP/1.1 200 OK
Content-Type: image/svg+xml
Error response (example — invalid URL protocol):
{
  "error": "URL protocol must be http or https"
}
For the complete list of request parameters, validation rules, and all possible error responses, see the API Reference — Generate endpoint and the API Overview.

Build docs developers (and LLMs) love