GET
/qrGenerate a QR code
Returns a scannable QR code as SVG.
scale sets the pixel size of each module (1-40) and margin the quiet zone in modules (0-20; keep it at 4 or more for reliable scanning). dark and light take hex colours. Set format=json to receive the raw module matrix instead of an image.
$0.0005 per call300 req/minFree allowance applies
Request
curl -X GET "https://www.twotic.dev/v1/qr/qr" \
-H "Authorization: Bearer $TWOTIC_KEY"const res = await fetch("https://www.twotic.dev/v1/qr/qr", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.TWOTIC_KEY}`,
},
})
if (!res.ok) throw new Error(await res.text())
const data = await res.json()
console.log(res.headers.get("X-Twotic-Cost"))import os, requests
res = requests.get(
"https://www.twotic.dev/v1/qr/qr",
headers={"Authorization": f"Bearer {os.environ['TWOTIC_KEY']}"},
)
res.raise_for_status()
data = res.json()
print(res.headers["X-Twotic-Cost"])package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://www.twotic.dev/v1/qr/qr", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("TWOTIC_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
fmt.Println(res.Header.Get("X-Twotic-Cost"))
}<?php
$ch = curl_init("https://www.twotic.dev/v1/qr/qr");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("TWOTIC_KEY"),
],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);require "net/http"
require "json"
uri = URI("https://www.twotic.dev/v1/qr/qr")
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV.fetch('TWOTIC_KEY')}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
http.request(req)
end
puts JSON.parse(res.body)
puts res["X-Twotic-Cost"]{
"mcpServers": {
"qr": {
"type": "http",
"url": "https://www.twotic.dev/api/mcp/qr",
"headers": { "Authorization": "Bearer tk_live_your_key" }
}
}
}Parameters
query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| data | string | required | The content to encode. Up to 800 characters submitted, ~213 bytes encoded.e.g. https://twotic.dev |
| format | string | optional | svg (default) returns an image; json returns the module matrix.one of: svg · json |
| scale | integer | optional | Pixels per module, 1-40. Defaults to 8.e.g. 8 |
| margin | integer | optional | Quiet zone in modules, 0-20. Defaults to 4. Below 4 harms scanning.e.g. 4 |
| dark | string | optional | Hex colour for the dark modules. Defaults to #000000.e.g. #0a0a0a |
| light | string | optional | Hex colour for the background. Defaults to #ffffff.e.g. #ffffff |
Response
200The QR code as an SVG image, or the module matrix as JSON.
400The content is too long or a parameter is invalid.
{
"error": "content_too_long",
"message": "That content is too long for a QR code at this error-correction level. The limit is about 213 bytes."
}As an agent tool
Connect https://www.twotic.dev/api/mcp/qr and this endpoint is exposed as the tool qr_generate.
Generate a scannable QR code encoding any text or URL, returned as SVG. Choose this whenever you need a machine-readable code for print or display — a link, a ticket reference, a payment string. Requires `data`; optional scale, margin, dark and light colours. Content limit is roughly 213 bytes. Use the wifi tool instead for network join codes.