Dynamic QR code API

Automate your QR code creation or add QR code features to your product

requests.post( 'https://hovercode.com/api/v1/hovercode/create/', headers={'Authorization': 'Token YOUR-TOKEN'}, json=data, timeout=10 )

Introduction

Hovercode’s API lets you create and update dynamic QR codes programatically. It’s ideal if you need to create a lot of QR codes or if you want to add QR code generation to your product or service.

The pricing to use the API is the same as our regular pricing (it's based on the number of QR codes you need to create)

This API is in active development, so if there’s a missing feature or if you have any feedback, let us know and we can help.

Authentication

Our API uses token authentication, so with every request, you should send an authorisation token in the header like so:

Authorization: Token YOUR-TOKEN

You can find your token in your settings area while logged in. Be sure to keep your token private and secure (like you would a password) as anyone who has access to it can use the API with your credits.

Create dynamic QR codes

https://hovercode.com/api/v1/hovercode/create/

This is the main use of the API. Use this endpoint to generate dynamic QR codes. By default, this endpoint returns the created QR code as an SVG string. You can either embed it directly into your site, or save the SVG string as an SVG file and convert it to any format you like.

If you want to QR code as a .png, set generate_png to true in your POST request body. This leads to a slower response, but the response will include a link to the QR code as a .png file as well as one as a .svg file.

Paramater name Required Description
workspace Required Every account has a workspace ID. You can find yours with your API token in your settings area
link Required This is the URL you want the QR code to scan to
display_name Not required You can optionally add a display name to your QR codes so they are easier to organise in your Hovercode dashboard (the display_name isn't customer facting)
square Not required (defaults to false) Your generated QR code will be round be default. Set this to true to create a square QR code
border Not required (defaults to 'Medium') Your generated QR code will have a "Medium" sized border by default. You can remove the border by setting this to "No border" or change the size by setting it to "Small" or "Large"
logo_url Not required Optionally add a url to an image to use it as a logo in your QR code. Don't use a massive image file and stick with pngs or jpegs
primary_color Not required (defaults to #111111) Change the color of your QR code by adding a valid HEX color code (including the '#')
domain Not required (defaults to the default domain from your workspace) If you have multiple custom domains linked to your workspace, you can specify which you want to use here.
generate_png Not required (defaults to false) Set this to true to include a .png and .svg QR code in your response. This slows down the response. Without this set to true, the QR code is only returned as an SVG string. You can retrieve the .png or .svg file in future requests even if this has not been sert to true.

This example uses Python requests, but you can achieve something similar with Ruby, JavaScript etc. More code examples coming soon (please get in touch if you have any questions)

import requests

data = {
    "workspace": "YOUR-WORKSPACE-ID",
    "link": "https://twitter.com/hovercodeHQ",
    "primary_color": "#1DA1F2"
}

response = requests.post(
    'https://hovercode.com/api/v1/hovercode/create/',
    headers={'Authorization': 'Token YOUR-TOKEN'},
    json=data,
    timeout=10
)

response.json() returns the following (with the SVG string truncated in this example)

{
  "id":"29067354-7659-404e-945e-4ebb7be21f2e",
  "link":"https://twitter.com/hovercodeHQ",
  "display_name":"None",
  "square":false,
  "logo":"None",
  "primary_color":"#1DA1F2",
  "svg":"<svg class=\"m-auto\" xmlns=\"http://www.w3.org/2000/svg...,
  "svg_file":"None",
  "png":"None",
  "created":"2022-09-20T14:00:50.587855Z"
}

This is the resulting QR code:

Here's an example using more features:

import requests

data = {
    "workspace": "YOUR-WORKSPACE-ID",
    "link": "https://twitter.com/hovercodeHQ",
    "primary_color": "#1DA1F2",
    "square": True,
    "logo_url": "https://hovercode.com/static/website/images/logo.png",
    "generate_png": True
}

response = requests.post(
    'https://hovercode.com/api/v1/hovercode/create/',
    headers={'Authorization': 'Token YOUR-TOKEN'},
    json=data,
    timeout=10
)

And with response.json()

{
   "id": "9c2aa461-bec0-46b8-9ed2-0edde02b164c",
   "link":"https://twitter.com/hovercodeHQ",
   "display_name":"None",
   "square":true,
   "border": "No border",
   "logo":"https://media.hovercode.com/media/logos/4510095f-a9e5-48d6-870f-f81362e4bd8d.png",
   "primary_color":"#1DA1F2",
   "svg":"<svg class=\"m-auto\" xmlns=\"http://www.w3.org/2000/svg\...",
   "svg_file":"https://media.hovercode.com/media/codes/9c2aa461-bec0-46b8-9ed2-0edde02b164c.svg",
   "png":"https://media.hovercode.com/media/codes/9c2aa461-bec0-46b8-9ed2-0edde02b164c.png",
   "created":"2022-09-21T06:05:40.068874Z"
}

And here's the resulting QR code (not the most attractive QR code, but it gives you an idea of the features you can use with the API)

Get QR codes

https://hovercode.com/api/v1/hovercode/

Use this endpoint to retrieve a QR code that was previously created. Even if generate_png wasn't set when creating the QR code, it will include the .png and .svg files of the QR code if it was created more than a few seconds before your call.

import requests

response = requests.get(
    'https://hovercode.com/api/v1/hovercode/QR-CODE-ID/',
    headers={'Authorization': 'Token YOUR-TOKEN'},
    timeout=10
)

And the response (with response.json())

{
   "id": "9c2aa461-bec0-46b8-9ed2-0edde02b164c",
   "link":"https://twitter.com/hovercodeHQ",
   "display_name":"None",
   "square":true,
   "logo":"https://media.hovercode.com/media/logos/4510095f-a9e5-48d6-870f-f81362e4bd8d.png",
   "primary_color":"#1DA1F2",
   "svg":"<svg class=\"m-auto\" xmlns=\"http://www.w3.org/2000/svg\...",
   "svg_file":"https://media.hovercode.com/media/codes/9c2aa461-bec0-46b8-9ed2-0edde02b164c.svg",
   "png":"https://media.hovercode.com/media/codes/9c2aa461-bec0-46b8-9ed2-0edde02b164c.png",
   "created":"2022-09-21T06:05:40.068874Z"
}

Update QR codes

https://hovercode.com/api/v1/hovercode/QR-CODE-ID/update/

The power of dynamic QR codes is that you can change their scan destination after they're created. You can update the display_name or the link (or both).

import requests

data = {
    "link": "https://twitter.com/ramykhuffash",
}

response = requests.put(
    'https://hovercode.com/api/v1/hovercode/QR-CODE-ID/update/',
    headers={'Authorization': 'Token YOUR-TOKEN'},
    json=data,
    timeout=10
)

The response (response.json()) will be exactly the same as you see with the other endpoints.

Delete QR codes

https://hovercode.com/api/v1/hovercode/QR-CODE-ID/delete/

Here's how you delete QR codes programatically - this deletes them permanently and they will no longer scan to their intended destination.

import requests
response = requests.delete(
    'https://hovercode.com/api/v1/hovercode/QR-CODE-ID/delete/',
    headers={'Authorization': 'Token YOUR-TOKEN'},
    timeout=10
)

This returns a status 204 if the delete was successful


This QR code API is in active development so please send us any feedback you have or let us know if there's anything we can do to help you get set up.