# Share to Reach reporting API v1

Create a key in Settings > Reporting API & data connections. Available to active paid subscribers; one-time link/credit purchases alone do not qualify. Requests check subscription access, account status, key expiry and revocation every time. Cancelling/refunding access prevents further pulls once the paid entitlement ends. Exported copies remain in your reporting tool.

## Authentication and limits

GET https://s2r.io/api/reporting/v1
Authorization: Bearer YOUR_KEY

Never put keys in query strings. Keys are shown once, stored as hashes, and scoped to your workspace's read-only reporting data. Up to five live keys, with 30/90/365 day expiry. Revoke from Settings at any time, including after your plan expires. Use separate keys per integration and rotate before expiry.

60 requests/minute per workspace; 120/minute per source IP. For 429, wait for the Retry-After header and retry the same cursor. No changes/uploads are permitted through this API. Account passwords, session tokens, API-key hashes, domain-verification tokens, PDF password hashes and raw uploaded files are excluded.

## Data and pagination

GET /api/reporting/v1 lists datasets, columns and date fields. Each dataset is at /api/reporting/v1/{dataset}:

- links: destinations, short URLs, campaigns, tags, UTMs, status and creation dates. QR images encode these stable short links and are not a separate entity.
- events: individual clicks and QR scans, including anonymous visitor identifier, time, device/browser/OS, geography, referrer, channel, bot flag and UTMs. Filter channel = qr for scans; filter bot = 0 to match human-visit reports.
- daily: link/day aggregate clicks and QR totals.
- campaigns, domains: metadata and status.
- flipbooks: publication metadata, short reader URLs, page/file sizes, publishing and reader settings.
- flipbook_events: individual reader events, page, reading seconds, device, referrer and UTMs.
- profile, workspace: account/workspace details (no authentication secrets or photo blobs).
- payments, subscriptions, invoices, billing_profile, entitlements, credits: billing records, invoice customer details, paid access and credit use. Payment amounts are integer minor currency units (e.g. paise for INR). Invoice PDFs and publication files are not returned.

All retained history is available; no one- or two-year cutoff. Empty datasets return fields and an empty data array. JSON-encoded columns (utm, details) are strings; parse them in your tool when needed. Boolean flags are 0/1. Timestamps use UTC ISO 8601; daily.day is YYYY-MM-DD. Anonymous visitor IDs are not identifiable contact records.

Query parameters:
- limit: 1–1000, default 500.
- since / until: optional inclusive UTC YYYY-MM-DD dates, applied to the dataset's advertised date field. Unsupported on credits. No date filter by default.
- cursor: opaque continuation value returned by the previous page. Do not modify it. Keep dataset and date filters unchanged.
- format: json (default) or csv.

JSON response: {dataset, fields, data, next_cursor, has_more}. Follow next_cursor until null; a single request is not a complete large export. CSV returns X-Has-More and X-Next-Cursor headers; append subsequent pages without repeating their header row. CSV escapes formula-leading text to protect spreadsheet imports.

Each pagination sequence excludes newly inserted rows after its initial high-water mark. Existing rows may change during a refresh; this is not a transactionally frozen backup. For links, billing and other mutable records, perform full refreshes and join on IDs. Do not use creation-date filters as an updated-since sync. To fetch new analytics events, use overlapping date windows and deduplicate by event id. No deletion feed is provided.

Error codes: 400 invalid parameters/cursor; 401 missing, revoked or expired key; 403 inactive paid access; 404 unknown dataset; 405 write method; 429 rate limit. Error JSON contains error text. Clients should stop on 401/403 and retry only temporary failures.

## Excel and Power BI

Download share-to-reach.pq from this folder. In Power Query, create a Text parameter named S2RApiKey and set it to your key. Create a Blank Query, open Advanced Editor, paste the template and set Dataset. Choose Anonymous for https://s2r.io when prompted: the template sends the Authorization header itself. The query follows every page. Repeat for other datasets; join events.link_id to links.id and flipbook_events.book_id to flipbooks.id. Expand the JSON string columns as needed and assign date/number types in Power Query.

Keep the workbook/PBIX and its parameters private: a parameter is not a secret vault. Publishing or sharing the editable query can reveal the key. For managed deployments, use your organization's approved credential-aware connector or gateway. Power BI Service scheduled refresh requires data-source credentials/settings in that service; this template alone does not configure a refresh schedule. Large refreshes can reach rate limits: stagger datasets and retry after the stated interval.

Microsoft reference: https://learn.microsoft.com/powerquery-m/web-contents

## Google Sheets and Looker Studio (formerly Google Data Studio)

Download share-to-reach.gs. Open a private Google Sheet, Extensions > Apps Script, paste the script. Add S2R_API_KEY under Project Settings > Script Properties, set DATASET and run syncShareToReach. Google will request access to the spreadsheet and external requests. Restrict script editors, who can read script properties. You can add a time-driven trigger after confirming a successful manual refresh. Each run replaces its own S2R_DATASET worksheet; do not manually edit that imported worksheet.

The starter importer caps at 50,000 rows and four minutes to respect Apps Script execution limits; it fails without replacing your sheet if a fetch fails or exceeds those limits. The API itself has no 50,000-row cap. Use date windows, Power Query or a data pipeline for larger histories.

In Looker Studio choose Create > Data source > Google Sheets, select this spreadsheet and its imported worksheet, then build the report. There is no built-in direct generic REST connection being claimed here; the supplied Sheets importer is the bridge. Configure field types in Looker Studio; Sheets and report refresh timings are separate.

Google references:
https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
https://cloud.google.com/looker/docs/studio/connect-to-google-sheets

## Other data warehouses and tools

Use any HTTPS client or ETL tool supporting Bearer authorization, JSON and cursor pagination. Store the key in its secret manager. Iterate datasets and pages, preserve IDs, retry 429 with Retry-After, and deduplicate incremental analytics pulls. API responses use Cache-Control: no-store. No additional Share to Reach API charge is added; external tool fees and quotas may apply.
