Installation

pip install codeqr

Basic Usage

Here’s how you can use the CodeQR Python SDK to create a link and retrieve click analytics in timeseries format for it:

import os
import codeqr
from codeqr.models import operations

# Initialize the CodeQR SDK with your API key
d = codeqr.CodeQR(
    token=os.environ['CODEQR_API_KEY'], # optional, defaults to CODEQR_API_KEY
)

# Create a new link
res = d.links.create(request={
    "url": "https://google.com",
})

print(res.short_link) # e.g. https://codeqr.link/abc123

# Get analytics for the link
analytics = d.analytics.retrieve(request={
    "link_id": res.id,
    "interval": "30d",
    "group_by": "timeseries",
})

print(analytics) # e.g. [{ "start": "2024-01-01", "clicks": 100 }]

For more usage examples:

  1. Organizing links by external ID, tenant ID, tags, etc
  2. Bulk link operations (create, update, delete)
  3. Retrieving link analytics

Frameworks

You can use the CodeQR Python SDK with any Python framework:

  1. Usage with Flask
  2. Usage with Django

If you’re using a different Python framework, you can refer to the Python SDK quickstart for a basic example.

Additional Resources