0

Get Shop

by
Published Nov 8, 2023

Get the store's name, domains, plan, currency, timezone, units and limits.

Script shopify Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 2 hours ago
1
//native
2

3
/**
4
 * Get Shop
5
 * Get the store's configuration: name, domains, plan, currency and enabled presentment currencies, timezone, units, address and resource limits.
6
 */
7
export async function main(auth: RT.Shopify) {
8
  const response = await fetch(
9
    `https://${auth.store_name}.myshopify.com/admin/api/2026-10/graphql.json`,
10
    {
11
      method: "POST",
12
      headers: {
13
        "X-Shopify-Access-Token": auth.token,
14
        "Content-Type": "application/json",
15
        Accept: "application/json",
16
      },
17
      body: JSON.stringify({
18
        query: `query { shop { id name email contactEmail shopOwnerName myshopifyDomain url primaryDomain { host url sslEnabled } plan { publicDisplayName partnerDevelopment shopifyPlus } currencyCode enabledPresentmentCurrencies ianaTimezone timezoneAbbreviation timezoneOffset weightUnit unitSystem taxesIncluded taxShipping orderNumberFormatPrefix orderNumberFormatSuffix shopAddress { address1 address2 city provinceCode zip countryCodeV2 phone } resourceLimits { locationLimit maxProductOptions maxProductVariants } features { giftCards storefront sellsSubscriptions reports } setupRequired checkoutApiSupported createdAt updatedAt } }`,
19
      }),
20
    }
21
  )
22

23
  if (!response.ok) {
24
    throw new Error(`${response.status} ${await response.text()}`)
25
  }
26

27
  const { data, errors } = await response.json()
28
  if (errors) {
29
    throw new Error(JSON.stringify(errors))
30
  }
31

32
  return data.shop
33
}
34

Other submissions
  • Submitted by hugo697 Typescript (fetch-only)
    Created 528 days ago
    1
    type Shopify = {
    2
      token: string;
    3
      store_name: string;
    4
    };
    5
    /**
    6
     * Retrieves the shop's configuration
    7
     * Retrieves the shop's configuration
    8
     */
    9
    export async function main(
    10
      auth: Shopify,
    11
      api_version: string = "2023-10",
    12
      fields: string | undefined
    13
    ) {
    14
      const url = new URL(
    15
        `https://${auth.store_name}.myshopify.com/admin/api/${api_version}/shop.json`
    16
      );
    17
      for (const [k, v] of [["fields", fields]]) {
    18
        if (v !== undefined && v !== "") {
    19
          url.searchParams.append(k, v);
    20
        }
    21
      }
    22
      const response = await fetch(url, {
    23
        method: "GET",
    24
        headers: {
    25
          "X-Shopify-Access-Token": auth.token,
    26
        },
    27
        body: undefined,
    28
      });
    29
      if (!response.ok) {
    30
        const text = await response.text();
    31
        throw new Error(`${response.status} ${text}`);
    32
      }
    33
      return await response.json();
    34
    }
    35