Optionally, you can also pass an externalId field which is a unique identifier for the link in your own database to associate it with the link in CodeQR’s system.
CodeQR TypeScript SDK provides a method to upsert a link – where an existing link is updated if it exists, or a new link is created if it doesn’t. so you don’t have to worry about checking if the link already exists.
CodeQR allows you to retrieve analytics for a link using the CodeQR TypeScript SDK.
server/api/analytics.get.ts
import { ClicksTimeseries } from "codeqr/models/components";export default defineEventHandler(async () => { try { // Retrieve the timeseries analytics for the last 7 days for a link const response = await codeqr.analytics.retrieve({ linkId: "clv3o9p9q000au1h0mc7r6l63", interval: "7d", groupBy: "timeseries", }); const timeseries = response as ClicksTimeseries[]; return timeseries; } catch (error) { console.error(error); return error; }});
Similarly, you can retrieve analytics for a link using the externalId field.
server/api/analytics.get.ts
// Retrieve the timeseries analytics for the last 7 days for a linkconst response = await codeqr.analytics.retrieve({ externalId: "ext_12345", interval: "7d", groupBy: "timeseries",});const timeseries = response as ClicksTimeseries[];