โ† All posts

QR Code API: Create and Update Codes from Your Own Code

๐Ÿ• 7 min readยทFor: Developers, agencies
APIdevelopers

You'll learn: How to create dynamic QR codes, change where they lead and read their scan counts from your own system with the Scnr REST API.

What can the Scnr QR code API do?

The Scnr QR code API lets your own software do what the dashboard does: create dynamic QR codes, change their destination, switch them off, and read their scan statistics. You send simple HTTPS requests with an API key, and get JSON back.

It is useful when codes come from data you already have: one code per product in your shop system, per order, per booking or per event ticket page. Instead of clicking through the dashboard a hundred times, a short script does it.

A laptop on a tidy desk with a coffee and a notebook, ready for work
A laptop on a tidy desk with a coffee and a notebook, ready for work

Before you start

  • Plan: the API is part of the Team and Business plans. See pricing.
  • Base address: https://scnr.tharkak.com/api/v1
  • Format: send JSON with the header Content-Type: application/json; answers are JSON.
  • Limits: 300 requests and 60 writes per 15 minutes per key. Your plan's code limits apply to the API too.

The API gives you the code's record, including its slug. The QR code itself encodes the short link https://scnr.tharkak.com/<slug> (or your custom domain, if you set one up). You draw the image with any QR library, or download it from the dashboard.

Step by step: your first API calls

Step 1: Create an API key

In Scnr, open Settings, choose Members, and find the API keys section. Press Create API key. The key starts with sk_live_ and is shown only once, so copy it into your password manager or server environment straight away.

The API key section with a sample request
The API key section with a sample request

Keep the key on your server. Never put it in a web page or a mobile app, where anyone can read it. A key can manage codes and read statistics, but it cannot change billing, team members or other keys. You can revoke a key at any time from the same screen.

Step 2: Check the key works

List your codes:

curl https://scnr.tharkak.com/api/v1/qr \
  -H "Authorization: Bearer sk_live_your_key"

You get a JSON list of your codes, each with its stats. A 401 means the key is wrong or revoked.

Step 3: Create a dynamic code

curl -X POST https://scnr.tharkak.com/api/v1/qr \
  -H "Authorization: Bearer sk_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Table 7 menu",
    "destination_url": "https://yourcafe.lk/menu",
    "qr_type": "url",
    "is_dynamic": true
  }'

The answer is 201 Created with the new code's record. The part you need is the slug:

{
  "slug": "k3Xp9a",
  "title": "Table 7 menu",
  "destination_url": "https://yourcafe.lk/menu",
  "qr_type": "url",
  "is_dynamic": true,
  "is_active": true
}

That code now lives at https://scnr.tharkak.com/k3Xp9a. Optional fields include client (a folder name), tags (a list), and slug to choose your own back-half, such as table-7.

Step 4: Turn the slug into a QR image

Any QR library works. In Node.js, with the qrcode package:

import QRCode from 'qrcode';
await QRCode.toFile('table-7.svg', 'https://scnr.tharkak.com/k3Xp9a', { type: 'svg' });

Python's qrcode package and most other languages have an equivalent. Save SVG for print; see SVG vs PNG.

Step 5: Change where a code leads

curl -X PUT https://scnr.tharkak.com/api/v1/qr/k3Xp9a \
  -H "Authorization: Bearer sk_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{ "destination_url": "https://yourcafe.lk/lunch-menu" }'

The answer is { "success": true, "slug": "k3Xp9a", "updated_at": "..." }, and the next scan goes to the new address. Send "is_active": false the same way to switch a code off.

Step 6: Read the scan numbers

curl https://scnr.tharkak.com/api/v1/analytics/k3Xp9a/summary \
  -H "Authorization: Bearer sk_live_your_key"

You get total_scans, unique_visitors, mobile_pct, first_scan and last_scan. For a daily chart, call /analytics/k3Xp9a/timeseries?days=30. For every scan as a spreadsheet, call /analytics/k3Xp9a/events.csv.

The analytics page with scans over time and the totals
The analytics page with scans over time and the totals

The full list of endpoints

MethodPathWhat it does
GET/qrList your codes, each with its stats
POST/qrCreate a code
GET/qr/:slugOne code
PUT/qr/:slugUpdate title, destination, active state, style and more
DELETE/qr/:slugDelete a code and its scan data
GET/analytics/:slug/summaryTotals for one code
GET/analytics/:slug/timeseries?days=30Daily scans, within your plan's history
GET/analytics/:slug/countriesTop 10 countries
GET/analytics/:slug/devices, /os, /browsers, /hoursBreakdowns
GET/analytics/:slug/recentThe last 20 scans
GET/analytics/:slug/events.csvRaw scans as CSV, newest 10,000

The same table is in the app under API Docs once your plan includes the API.

Errors

Errors come back as JSON with a message and, where useful, a code, for example { "error": "...", "code": "LIMIT_QR_CODES" }.

  • 400: something in your request is wrong; the message says what.
  • 401: bad or revoked key.
  • 403: a plan limit or a feature your plan does not include.
  • 404: no code with that slug in your account.
  • 409: the custom back-half you asked for is taken.
  • 429: too many requests; wait and retry.

Example: an online bookshop in Colombo

This is an example, not a real customer. Ishara runs an online bookshop in Colombo with her own stock system. Each new book gets a shelf label. She added 20 lines to her stock script: when a book is added, it calls POST /qr with the book's page, saves the slug, and prints the label with the QR code. When a book sells out, the script points the code at "similar books" with a PUT. Every Monday another call reads each code's summary, so she sees which shelf labels customers actually scan.

Common questions

Q: Is there a free QR code API?
A: Scnr's API is part of the Team and Business plans. For a one-off code you can use the free QR code generator instead.

Q: Can I create Wi-Fi, vCard or page codes through the API?
A: The create call takes qr_type and content_data, so other types are possible. Link codes are the simplest place to start.

Q: Can I bulk create without writing code?
A: Yes. Team and up can upload a CSV in Bulk create. See bulk QR code generator.

Q: Can Scnr tell my system when something happens?
A: The Business plan adds webhooks, which send your server a signed message when, for example, a code is created or updated.

Start building

Create a key in Settings under Members, then try the calls above against a test code. Compare plans on pricing, and if you just need many codes once, start with bulk create from a spreadsheet.

Ready to create?