Installation

npm install codeqr

Basic Usage

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

import { CodeQR } from "codeqr";

// Initialize the CodeQR SDK with your API key
const codeqr = new CodeQR({
  token: process.env.CODEQR_API_KEY, // optional, defaults to CODEQR_API_KEY
});

// Create a new link
const link = await codeqr.links.create({
  url: "https://google.com",
});

console.log(link.shortLink); // e.g. https://codeqr.link/abc123

// Get analytics for the link
const analytics = await codeqr.analytics.retrieve({
  link_id: link.id,
  groupBy: "timeseries",
  interval: "30d",
});

console.log(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 TypeScript SDK with any JavaScript framework:

  1. Usage with Next.js
  2. Usage with Remix
  3. Usage with Nuxt
  4. Usage with Express

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

Additional Resources