Skip to main content
Guide version 1.0 · SDK v1 · Updated 2026-09-07 An Eyk data app is your own web app (a supplier portal, an operations screen, an internal dashboard) that reads live data from Eyk. Eyk handles sign-in, authorization, and querying. You build the interface.

For coding agents

You have this guide and an App ID (app_...). Do these three things, in order:
  1. Load the SDK with one script tag carrying the App ID. Wait for window.eykSdk.
  2. Add sign-in: call getSession() on page load; show a sign-in button that calls signIn() when the session is null.
  3. Run queries with query() once a session exists. Discover member names with listMetrics().
Rules that prevent the common failures:
  • Use the App ID exactly as given. Never invent, shorten, or hardcode a different one.
  • Never call signIn() automatically on page load. Only call it from a user action (a button click).
  • Never run query() before getSession() returned a session. A signed-out query rejects with AUTH_REQUIRED; it does not redirect.
  • Never call the Eyk API directly. The SDK is the whole contract; there are no other endpoints to integrate.
  • Never add a backend, proxy, API key, or secret for Eyk. The SDK runs in the browser and holds the user’s own session.
  • Use member names from listMetrics() or from this guide. Do not guess names.
You are done when: the page loads without console errors, a signed-out visitor sees a sign-in button, clicking it goes to Eyk and returns to the same page signed in, and a query renders rows. See Verification.

Before you start

Someone with the Admin role in the Eyk organization must do this in Eyk under AgenticData apps. Agents cannot do it.
  1. Register a data app. Each app gets a name and an App ID (app_...). The App ID is public and safe to put in frontend code.
  2. Add allowed origins. An origin is scheme://host[:port] with no path. Sign-in only returns users to a registered origin. https:// is required except for http://localhost:<port>, so add your local development origin too.
  3. Invite the people who will use the app as members of the organization. Only approved members can sign in to a data app. What they see is governed by their access in Eyk, the same as in the Eyk dashboard.

Step 1: load the SDK

Add one script tag to the <head> of every page that uses Eyk. Replace the App ID with yours.
The SDK sets window.eykSdk and dispatches an eyksdk:ready event on window. Because the script is async, the event can fire before your code runs. Always check the global first:
Same result, useful in bundled apps where you do not control index.html:
eykSdk.init({ appId }) also exists for a script loaded without data-app-id. Calling init with a different App ID clears the current session.
Type declarations are served next to the script at https://edge.eykdata.com/sdk/v1/eyk-sdk.d.ts. Download the file into your project and import its types, or copy the SDK reference below. The file declares window.eykSdk and the eyksdk:ready event.
An App ID belongs to one Eyk environment. Apps registered on the Eyk test platform load the SDK from https://edge.eykdata.dev/sdk/v1/eyk-sdk.js instead. The Manual setup section of the app’s detail page in Eyk always shows the exact script tag for that app.
Do not load the script twice. A second embed is ignored and keeps the live session. Do not bundle or self-host the script: the hosted URL is the contract and receives fixes.

Step 2: add sign-in

Sign-in is a full-page redirect to Eyk and back to your page. The SDK completes the exchange when the page reloads, inside getSession().
Behavior to rely on:
  • getSession() resolves null when nobody is signed in. It never redirects.
  • signIn() defaults returnTo to the current URL. The origin of returnTo must be an allowed origin of the app, or Eyk shows an error page instead of a login.
  • After returning, the SDK removes the code and state parameters from the URL. Your own query parameters survive the round trip.
  • A session survives page reloads for about 7 days without a new redirect. Then the next getSession() returns null and the user signs in again.
  • Signing out in one tab signs out the other tabs of the same app.
  • Sign-in needs a secure context: https://, or http://localhost. Inside a cross-origin iframe the redirect flow cannot run.
Do not redirect to sign-in automatically when getSession() returns null. A failed or cancelled sign-in then loops back into the redirect, and visitors who are not Eyk members get bounced to a login they cannot complete. Render a button.
The same flow as a hook. sdk is available in both signed-out and signed-in states, so the sign-in button can call it.

Step 3: run queries

Ask for measures and dimensions by name. Results come back already filtered to what the signed-in user may see.
Each row is an object keyed by member name. A time dimension queried with a granularity appears twice: as the base name and as name.<granularity> (the start of the bucket). Both are ISO timestamps.
Measure values can arrive as strings. Coerce them with Number() before you add or format them.

Query shape

Discover member names

listMetrics() returns the catalog the signed-in user may query. Use it to find names and to build pickers; do not guess names.
The main metrics:

Query rules

  • Do not mix measures from different fact metrics in one query. fact_sales_items.net_sales with fact_attributions.channel_cost is invalid. Run two queries and combine in your app.
  • Time dimension names are base names. Wrong: { dimension: "fact_sales_items.line_timestamp.month" }. Right: { dimension: "fact_sales_items.line_timestamp", granularity: "month" }. The suffixed form only appears in result keys.
  • fact_attributions uses one attribution model per query. The default model is applied when you add no filter. To pick another, filter on dim_attribution_models.display_name with one value, for example "Last Touch".
  • Members you cannot see read as unknown. A hidden or restricted member fails with INVALID_QUERY and reason unknown_member, never with a permission error.
  • Keep queries aggregated. Pull grouped rows for the period you display, not every order. limit caps at 10000 rows.
More examples:

Errors

Every rejected promise from getSession(), signIn(), signOut(), query(), and listMetrics() is an EykError with name: "EykError", a code, a message, and optional details and HTTP status. Wrong use of the SDK itself (no App ID, wrong argument type) throws a TypeError synchronously instead.

Verification

Run through this list before you call the integration done.
  1. Load: open the page. window.eykSdk.version is a string in the console. No SDK errors.
  2. Signed out: the page shows a sign-in button and does not redirect on its own.
  3. Sign in: clicking the button goes to Eyk. After signing in, the browser returns to the page you started on, with clean URL parameters, and getSession() returns { user: { email, name } }.
  4. Query: a query returns { rows } with the members you asked for. Numbers render correctly after Number().
  5. Sign out: after signOut(), getSession() returns null and the sign-in button is back.
  6. Local development: the same works on http://localhost:<port> after that origin is added to the app’s allowed origins.

Common mistakes

SDK reference

The script URL, the data-app-id attribute, the method names, the query shape, and the error codes above are a frozen v1 contract. Breaking changes ship as /sdk/v2/; v1 embeds keep working.
🤝 Questions or stuck on a query? Reach the Eyk team through the in-product chat.