Skip to content

About

QR Code API by ChartQuery: Generate styled QR codes as SVG or PNG. Python, TypeScript, cURL, PHP, C#, Go, Java, Ruby examples.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QR Code API by ChartQuery

QR Code API

Discord Get API key API docs License: MIT

The ChartQuery QR Code API generates styled QR codes — dot styles, colors, gradients, custom corners and all QR versions — as SVG (default) or PNG.

  • QR Code API — Generate a styled QR code via GET.

Use it for tickets, packaging, marketing campaigns, payments, Wi-Fi access and vCards.

Endpoint Request Credits
QR Code API GET /v1/qrcode 3

Table of contents

How it works

  1. Create a ChartQuery account and copy your API key from the dashboard.
  2. Call https://api.chartquery.com with the header x-api-key: YOUR_API_KEY.
  3. Use the result in your app — no infrastructure to run.
export CHARTQUERY_API_KEY="your-api-key"
pip install requests        # Python
# TypeScript: Node.js 18+ (native fetch), run with `npx tsx file.ts`

QR Code API

Generate a styled QR code via GET. Output: SVG (default) or PNG. Supports dot styles, gradients, custom corners and all QR versions.

GET https://api.chartquery.com/v1/qrcode · 3 credits per request · API reference

Request parameters

Parameter In Type Required Description
data query string ✅ Data to encode in the QR code.
size query number — Width and height of the code, in the selected unit. Default: 200 pixels.
ec_level query string (L, M, Q, H) — Error correction. Default: M. A higher level survives more damage.
dot_type query string (square, rounded, dots, diamond, classy, classy-rounded) — Shape of each module. Default: square.
color query string — Module color as CSS hex. Default: #000. Paste the raw value, including #.
shape query string (square, circle) — Outer shape of the code. Default: square.
dot_size query number — Module size ratio, from 0.1 to 1. Default: 1, which fills each cell.
background query string — Background color. Default: #fff. Paste the raw value, including #.
margin query number — Quiet zone around the code, in modules. Default: 4. The QR spec recommends at least 4.
version query number — QR version, from 1 to 40. It sets the grid size and the capacity.
mode query string (auto, numeric, alphanumeric, byte) — Encoding mode. Default: auto.
mask query number — Mask pattern, from 0 to 7.
unit query string (px, mm, in, cm) — Unit for size. Default: px.
xml_declaration query boolean — Prepend an XML declaration to the SVG.
aria_label query string — Accessible name on the SVG.
title query string — SVG title, shown as a tooltip.
desc query string — Longer SVG description.
format query string (svg, png) — Output format. Default: svg.
share query boolean — Persist the result and return share URLs instead of the image.

Python example

import os

import requests

API_KEY = os.environ["CHARTQUERY_API_KEY"]
HEADERS = {"x-api-key": API_KEY}

response = requests.get(
    "https://api.chartquery.com/v1/qrcode",
    headers=HEADERS,
    params={
        "data": "https://chartquery.com",
        "format": "png",
    },
    timeout=120,
)
response.raise_for_status()

with open("qrcode.png", "wb") as f:
    f.write(response.content)
print("Saved qrcode.png", len(response.content), "bytes")

TypeScript example

import { writeFile } from "node:fs/promises";

const headers = { "x-api-key": process.env.CHARTQUERY_API_KEY!, "Content-Type": "application/json" };

const params = new URLSearchParams({
  "data": "https://chartquery.com",
  "format": "png",
});

const response = await fetch(`https://api.chartquery.com/v1/qrcode?${params}`, { headers });
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);

await writeFile("qrcode.png", Buffer.from(await response.arrayBuffer()));
console.log("Saved qrcode.png");

Output

The response body is the generated file (saved as qrcode.png in every example). Error responses are JSON with an explanatory message.

Code examples in other languages

Ready-to-run examples live in examples/; each reads your key from CHARTQUERY_API_KEY.

Language qrcode
cURL (Bash) qrcode.sh
PHP qrcode.php
C# Qrcode.cs
Go qrcode.go
Java QrcodeExample.java
Ruby qrcode.rb
Node.js qrcode.mjs

Use cases

  • Marketing — Branded QR codes for print and packaging.
  • Tickets & events — Generate unique QR codes per attendee.
  • Wi-Fi & contacts — Encode Wi-Fi credentials, vCards, emails or SMS.

Why ChartQuery?

  • Images in one request — the response body is the PNG/SVG/PDF, ready for emails, PDFs, dashboards, Slack or <img> tags.
  • Charts, diagrams, QR codes, barcodes, labels — Chart.js configs, 28 diagram languages (Mermaid, Graphviz, PlantUML, D2…), 25+ barcode formats.
  • AI generation — describe a chart or diagram in plain English and get the rendered image.
  • No rendering infrastructure — no headless browser, fonts or libraries to maintain.
  • Copy-paste examples — Python and TypeScript in each README, 7 more languages in examples/.

FAQ

How do I authenticate?

Create an account on ChartQuery, copy your API key and send it in the x-api-key header of every request to https://api.chartquery.com.

How much does a request cost?

Credits per call: /v1/qrcode 3. See ChartQuery pricing.

What does the API return?

The response body is the file itself (image or document). Save it directly to disk or stream it to your storage — every example in this repository writes the file locally.

Which languages are supported?

Any language that can make an HTTP request. This README shows Python and TypeScript; the examples/ folder contains cURL, PHP, C#, Go, Java, Ruby and Node.js.

Official SDKs

Use ChartQuery from your own language with a typed client:

SDK Package Install
Node.js @chartquery/sdk npm install @chartquery/sdk
Python chartquery pip install chartquery
Go chartquery-go go get github.com/chartquery/chartquery-go
.NET ChartQuery dotnet add package ChartQuery
Ruby chartquery gem install chartquery
PHP chartquery/sdk composer require chartquery/sdk
Java chartquery-java build from source, see its README
CLI @chartquery/cli npm install -g @chartquery/cli
MCP server @chartquery/mcp npx -y @chartquery/mcp

Related repositories

Support


ChartQuery
Built by ChartQuery. Examples are released under the MIT license.

About

QR Code API by ChartQuery: Generate styled QR codes as SVG or PNG. Python, TypeScript, cURL, PHP, C#, Go, Java, Ruby examples.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors