API Client

Store

Read store configuration and metadata using client.store.get — currency, timezone, domain, and more.

client.store gives your plugin access to the merchant's store configuration. This is typically the first call a plugin makes after installation to understand the store's locale, currency, and domain settings.

Required Scopes

OperationRequired Scope
getread:store

HTTP Mapping

MethodHTTP VerbPath
get()GET/store

Methods

get

Retrieve the store's configuration and metadata.

const store = await client.store.get();

console.log(store.name);      // "My Fashion Store"
console.log(store.domain);    // "my-fashion-store.com"
console.log(store.currency);  // "DOP"
console.log(store.timezone);  // "America/Santo_Domingo"
console.log(store.locale);    // "es-DO"

Common Use Cases

Formatting prices with the correct currency

const store = await client.store.get();
const { data: products } = await client.products.list({ page: 1, per_page: 10 });

const formatter = new Intl.NumberFormat(store.locale, {
  style: "currency",
  currency: store.currency,
});

products.forEach((product) => {
  console.log(`${product.name}: ${formatter.format(product.price)}`);
});

Detecting locale for translated content

const store = await client.store.get();

// Load the correct translation file based on the store's locale
const translations = await loadTranslations(store.locale);

Building store-specific configurations

const store = await client.store.get();

// Store details in your plugin's own database,
// keyed by store domain for multi-tenant isolation
await db.storeConfigs.upsert({
  where: { domain: store.domain },
  update: { currency: store.currency, timezone: store.timezone },
  create: {
    domain: store.domain,
    name: store.name,
    currency: store.currency,
    timezone: store.timezone,
  },
});

Error Handling

import { AuthorizationError } from "@whatalo/plugin-sdk";

try {
  const store = await client.store.get();
} catch (error) {
  if (error instanceof AuthorizationError) {
    // Plugin does not have read:store scope
    console.log(`Missing scope: ${error.requiredScope}`);
  } else {
    throw error;
  }
}

See Errors & Rate Limits for the full error class reference.

On this page