Skip to main content

JavaScript/Node.js

Create a QR Code

create-qr-code.js
const response = await fetch('https://management.scanova.io/qrcode/', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'My QR Code',
    category: '1',
    qr_type: 'dy',
    info: JSON.stringify({
      type: 'url',
      data: { url: 'https://scanova.io' }
    })
  })
});

const qrCode = await response.json();
console.log('QR Code created:', qrCode);

Get QR Code Analytics

get-analytics.js
const response = await fetch('https://management.scanova.io/analytics/qrcode/?from=2025-01-01&to=2025-01-31&type=count,device,os', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    filter_by: 'qrid',
    q: ['Qf94b25d768294148']
  })
});

const analytics = await response.json();
console.log('Analytics:', analytics);

Python

Create a QR Code

create_qr_code.py
import requests
import json

url = "https://management.scanova.io/qrcode/"
headers = {
    "Authorization": "YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {
    "name": "My QR Code",
    "category": "1",
    "qr_type": "dy",
    "info": json.dumps({
        "type": "url",
        "data": {"url": "https://scanova.io"}
    })
}

response = requests.post(url, headers=headers, json=data)
qr_code = response.json()
print("QR Code created:", qr_code)

List QR Codes

list_qr_codes.py
import requests

url = "https://management.scanova.io/qrcode/"
headers = {
    "Authorization": "YOUR_API_KEY"
}

params = {
    "page": 1,
    "ordering": "-created"
}

response = requests.get(url, headers=headers, params=params)
qr_codes = response.json()
print("QR Codes:", qr_codes)

PHP

Create a QR Code

create_qr_code.php
<?php
$url = "https://management.scanova.io/qrcode/";
$headers = [
    "Authorization: YOUR_API_KEY",
    "Content-Type: application/json"
];

$data = json_encode([
    "name" => "My QR Code",
    "category" => "1",
    "qr_type" => "dy",
    "info" => json_encode([
        "type" => "url",
        "data" => ["url" => "https://scanova.io"]
    ])
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$qr_code = json_decode($response, true);
echo "QR Code created: " . json_encode($qr_code);

curl_close($ch);
?>

Update QR Code

update_qr_code.php
<?php
$qrid = "Qf94b25d768294148";
$url = "https://management.scanova.io/qrcode/{$qrid}/";
$headers = [
    "Authorization: YOUR_API_KEY",
    "Content-Type: application/json"
];

$data = json_encode([
    "name" => "Updated QR Code Name",
    "info" => json_encode([
        "type" => "url",
        "data" => ["url" => "https://updated-url.com"]
    ])
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$updated_qr_code = json_decode($response, true);
echo "QR Code updated: " . json_encode($updated_qr_code);

curl_close($ch);
?>

cURL

Create a QR Code

create_qr_code.sh
curl -X POST "https://management.scanova.io/qrcode/" \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My QR Code",
    "category": "1",
    "qr_type": "dy",
    "info": "{\"type\":\"url\",\"data\":{\"url\":\"https://scanova.io\"}}"
  }'

Get QR Code Analytics

get_analytics.sh
curl -X POST "https://management.scanova.io/analytics/qrcode/?from=2025-01-01&to=2025-01-31&type=count,device,os" \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter_by": "qrid",
    "q": ["Qf94b25d768294148"]
  }'

Download QR Code

download_qr_code.sh
curl -X GET "https://management.scanova.io/qrcode/Qf94b25d768294148/download/?size=500" \
  -H "Authorization: YOUR_API_KEY" \
  -o "qr_code.png"

Advanced Examples

Restaurant Menu QR Code

restaurant-menu.js
const menuData = {
  name: "Restaurant Menu QR Code",
  category: "25", // Restaurant category
  qr_type: "dy",
  info: JSON.stringify({
    type: "restaurant",
    data: {
      restaurant_name: "My Restaurant",
      menu_items: [
        {
          name: "Pizza Margherita",
          price: "$12.99",
          description: "Fresh mozzarella and basil"
        },
        {
          name: "Pasta Carbonara",
          price: "$14.99",
          description: "Creamy pasta with bacon"
        }
      ],
      contact_info: {
        phone: "+1-555-0123",
        address: "123 Main St, City, State"
      }
    }
  })
};

const response = await fetch('https://management.scanova.io/qrcode/', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(menuData)
});

const menuQR = await response.json();
console.log('Menu QR Code created:', menuQR);

Event Registration QR Code

event_registration.py
import requests
import json

event_data = {
    "name": "Tech Conference 2025",
    "category": "20",  # Event category
    "qr_type": "dy",
    "info": json.dumps({
        "type": "event",
        "data": {
            "event_name": "Tech Conference 2025",
            "date": "2025-06-15",
            "time": "09:00",
            "venue": "Convention Center",
            "description": "Annual technology conference",
            "registration_url": "https://events.scanova.io/tech-conf-2025"
        }
    })
}

response = requests.post(
    "https://management.scanova.io/qrcode/",
    headers={"Authorization": "YOUR_API_KEY", "Content-Type": "application/json"},
    json=event_data
)

event_qr = response.json()
print("Event QR Code created:", event_qr)

Lead Generation Form

lead_generation.php
<?php
$leadData = [
    "name" => "Lead Generation QR Code",
    "category" => "26", // Feedback/Form category
    "qr_type" => "dy",
    "info" => json_encode([
        "type" => "feedback",
        "data" => [
            "form_title" => "Get Our Newsletter",
            "fields" => [
                ["type" => "text", "label" => "Name", "required" => true],
                ["type" => "email", "label" => "Email", "required" => true],
                ["type" => "phone", "label" => "Phone", "required" => false]
            ],
            "submit_button_text" => "Subscribe",
            "thank_you_message" => "Thank you for subscribing!"
        ]
    ])
];

$response = file_get_contents("https://management.scanova.io/qrcode/", false, stream_context_create([
    "http" => [
        "method" => "POST",
        "header" => "Authorization: YOUR_API_KEY\r\nContent-Type: application/json\r\n",
        "content" => json_encode($leadData)
    ]
]));

$leadQR = json_decode($response, true);
echo "Lead generation QR Code created: " . json_encode($leadQR);
?>

Error Handling

JavaScript Error Handling

error_handling.js
async function createQRCode(data) {
  try {
    const response = await fetch('https://management.scanova.io/qrcode/', {
      method: 'POST',
      headers: {
        'Authorization': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(data)
    });

    if (!response.ok) {
      const error = await response.json();
      throw new Error(`API Error: ${error.message || response.statusText}`);
    }

    return await response.json();
  } catch (error) {
    console.error('Failed to create QR code:', error.message);
    throw error;
  }
}

Python Error Handling

error_handling.py
import requests
from requests.exceptions import RequestException

def create_qr_code(data):
    try:
        response = requests.post(
            "https://management.scanova.io/qrcode/",
            headers={"Authorization": "YOUR_API_KEY", "Content-Type": "application/json"},
            json=data
        )
        response.raise_for_status()
        return response.json()
    except requests.exceptions.HTTPError as e:
        print(f"HTTP Error: {e}")
        if e.response.status_code == 401:
            print("Invalid API key")
        elif e.response.status_code == 429:
            print("Rate limit exceeded")
    except RequestException as e:
        print(f"Request failed: {e}")
    except Exception as e:
        print(f"Unexpected error: {e}")