# Other

> Ajax API endpoints for storefront reference data: phone codes, currencies, countries and provinces, the visitor's country, coupons, and the language pack.

The other APIs return the reference data a storefront needs: phone codes, currencies, countries, provinces, the country the visitor is browsing from, the currencies the store has enabled, the coupons a product offers, and the language pack of the theme.

## List country calling codes

```text
GET /{locale}/api/phone
```

Get phone-related information data.

### Example request

**Example request using Fetch**

```javascript
fetch(window.SHOPLAZZA.routes.root + '/api/phone')
  .then((response) => response.json())
  .then((data) => {
    // Do something...
  });
```

### Response

**Schema | Example**

*   Array [

- `cn_name` string

  Chinese name of the country.
- `flag` string

  URL of the flag image.
- `iso_code_2` string

  ISO 3166-1 alpha-2 country code.
- `iso_code_3` string

  ISO 3166-1 alpha-3 country code.
- `name` string

  English name of the country.
- `phone_code` string

  International dialling code of the country.
- `phone_key` string

  Key combining the country code and the dialling code, for example `AF_93`.
*   ]

```json
[
  {
    "cn_name": "阿富汗",
    "flag": "https://imglib.shoplazza.com/42757bc371af7061a1775697529b55c6.png",
    "iso_code_2": "AF",
    "iso_code_3": "AFG",
    "name": "Afghanistan",
    "phone_code": "93",
    "phone_key": "AF_93"
  },
  {
    "cn_name": "奥兰群岛",
    "flag": "https://imglib.shoplazza.com/Aland.png",
    "iso_code_2": "AX",
    "iso_code_3": "ALA",
    "name": "Aland lslands",
    "phone_code": "358",
    "phone_key": "AX_358"
  },
  {
    "cn_name": "津巴布韦",
    "flag": "https://imglib.shoplazza.com/eb2d7eafed41ce90f19b6b94055291a7.png",
    "iso_code_2": "ZW",
    "iso_code_3": "ZWE",
    "name": "Zimbabwe",
    "phone_code": "263",
    "phone_key": "ZW_263"
  }
]
```

## List the currencies the platform supports

```text
GET /{locale}/api/currency
```

Get currency-related information data.

### Example request

**Example request using Fetch**

```javascript
fetch(window.SHOPLAZZA.routes.root + '/api/currency')
  .then((response) => response.json())
  .then((data) => {
    // Do something...
  });
```

### Response

**Schema | Example**

*   Array [

- `cn_name` string

  Chinese name of the currency.
- `code` string

  Currency code, for example `USD`.
- `currency_id` number

  Currency ID.
- `flag` string

  URL of the flag image.
- `symbol_left` string

  Symbol shown to the left of the amount.
- `symbol_right` string

  Symbol shown to the right of the amount.
- `title` string

  Display name of the currency in the storefront language.
- `value` number
*   ]

```json
[
  {
    "cn_name": "美元",
    "code": "USD",
    "currency_id": 1,
    "flag": "//img.staticdj.com/411902f97f55701c425aeb0b1df78fed.png",
    "symbol_left": "$",
    "symbol_right": "",
    "title": "United States Dollars (USD)",
    "value": 0
  },
  {
    "cn_name": "欧元",
    "code": "EUR",
    "currency_id": 2,
    "flag": "//img.staticdj.com/8e76e4a274e105aaeca38a9e00f76821.png",
    "symbol_left": "€",
    "symbol_right": "",
    "title": "Euro (EUR)",
    "value": 0
  },
  {
    "cn_name": "伊朗里亚尔",
    "code": "IRR",
    "currency_id": 152,
    "flag": "//img.staticdj.com/df0e6a9526632c7f50447e2d28d7766e.png",
    "symbol_left": "",
    "symbol_right": "﷼",
    "title": "Iranian Rial (IRR)",
    "value": 0
  }
]
```

## List countries and regions

```text
GET /{locale}/api/country
```

Get country-related information data.

### Example request

**Example request using Fetch**

```javascript
fetch(window.SHOPLAZZA.routes.root + '/api/country')
  .then((response) => response.json())
  .then((data) => {
    // Do something...
  });
```

### Response

**Schema | Example**

*   Array [

- `cn_name` string

  Chinese name of the country.
- `continent` string

  Continent the country belongs to.
- `country_id` number

  Country ID.
- `flag` string

  URL of the flag image.
- `iso_code_2` string

  ISO 3166-1 alpha-2 country code.
- `iso_code_3` string

  ISO 3166-1 alpha-3 country code.
- `name` string

  English name of the country.
- `phone_code` string

  International dialling code of the country.
*   ]

```json
[
  {
    "cn_name": "阿富汗",
    "continent": "AS",
    "country_id": 1,
    "flag": "https://imglib.shoplazza.com/42757bc371af7061a1775697529b55c6.png",
    "iso_code_2": "AF",
    "iso_code_3": "AFG",
    "name": "Afghanistan",
    "phone_code": "93"
  },
  {
    "cn_name": "奥兰群岛",
    "continent": "EU",
    "country_id": 2,
    "flag": "https://imglib.shoplazza.com/Aland.png",
    "iso_code_2": "AX",
    "iso_code_3": "ALA",
    "name": "Aland lslands",
    "phone_code": "358"
  },
  {
    "cn_name": "津巴布韦",
    "continent": "AF",
    "country_id": 240,
    "flag": "https://imglib.shoplazza.com/eb2d7eafed41ce90f19b6b94055291a7.png",
    "iso_code_2": "ZW",
    "iso_code_3": "ZWE",
    "name": "Zimbabwe",
    "phone_code": "263"
  }
]
```

## List the provinces of a country or region

```text
GET /{locale}/api/country/{country_code}/province
```

Get province-related information data from country code Alpha-2.

### Example request

**Example request using Fetch**

```javascript
fetch(window.SHOPLAZZA.routes.root + '/api/country/CN/province')
  .then((response) => response.json())
  .then((data) => {
    // Do something...
  });
```

### Request parameters

- `country_code` string

  Two-letter country code, such as `CN`.

### Response

**Schema | Example**

*   Array [

- `cn_name` string

  Chinese name of the province.
- `code` string

  Code of the province.
- `country_code2` string

  Code of the country the province belongs to.
- `name` string

  English name of the province.
- `old_code` string

  Legacy code of the province.
- `province_id` number

  Province ID.
*   ]

```json
[
  {
    "cn_name": "安徽省",
    "code": "CN-AH",
    "country_code2": "CN",
    "name": "Anhui",
    "old_code": "ANH",
    "province_id": 615
  },
  {
    "cn_name": "北京市",
    "code": "CN-BJ",
    "country_code2": "CN",
    "name": "Beijing",
    "old_code": "BJG",
    "province_id": 616
  },
  {
    "cn_name": "浙江省",
    "code": "CN-ZJ",
    "country_code2": "CN",
    "name": "Zhejiang",
    "old_code": "ZHE",
    "province_id": 648
  }
]
```

## Get the visitor's IP address and country

```text
GET /{locale}/api/ip-info
```

Get the IP address of the visitor and the country it resolves to. Takes no parameters.

### Example request

**Example request using Fetch**

```javascript
fetch(window.SHOPLAZZA.routes.root + '/api/ip-info')
  .then((response) => response.json())
  .then((data) => {
    // Do something...
  });
```

### Response

**Schema | Example**

- `country` string

  Two-letter country code resolved from the visitor's IP address.
- `ip` string

  The visitor's IP address.

```json
{
  "country": "US",
  "ip": "203.0.113.10"
}
```

## List the currencies the store has enabled

```text
GET /{locale}/api/multi-currency/finance-list
```

Get the currencies the store has enabled and the default currency among them. Takes no parameters.

### Example request

**Example request**

```javascript
fetch(window.SHOPLAZZA.routes.root + '/api/multi-currency/finance-list')
  .then((response) => response.json())
  .then((data) => {
    // do something...
  });
```

### Response

The example is trimmed to three currencies.

**Schema | Example**

- `state` number

  Request result flag; `success` or `0` means the request succeeded.
- `msg` string

  Result message returned with the response.
- `data` object

  The response payload.

  - `default_code` string

    Code of the store's default currency.
  - `open_state` number
  - `list` object[]

    Currencies enabled for the store.

    *   Array [

    - `code` string

      Currency code, for example `USD`.
    - `title` string

      Display name of the currency in the storefront language.
    - `name` string

      English name of the currency.
    - `symbol` string

      Currency symbol.
    - `flag` string

      URL of the flag image.
    - `default` number

      Whether this is the default currency; `1` yes, `0` no.
    - `format` string
    - `currency_symbol_pos` string

      Where the currency symbol is placed, `left` or `right`.
    - `finance` number
    *   ]

```json
{
  "state": 0,
  "msg": "请求成功",
  "data": {
    "default_code": "USD",
    "open_state": 1,
    "list": [
      {
        "code": "USD",
        "title": "美元(USD)",
        "name": "United States Dollars (USD)",
        "symbol": "$",
        "flag": "//img.staticdj.com/411902f97f55701c425aeb0b1df78fed.png",
        "default": 1,
        "format": "amount",
        "currency_symbol_pos": "left",
        "finance": 1
      },
      {
        "code": "CNY",
        "title": "中国人民币(CNY)",
        "name": "Chinese Yuan Renminbi (CNY)",
        "symbol": "¥",
        "flag": "//img.staticdj.com/8990b1b7cab189e38913017d3887b918.png",
        "default": 0,
        "format": "amount",
        "currency_symbol_pos": "left",
        "finance": 6.71915
      },
      {
        "code": "JPY",
        "title": "日元(JPY)",
        "name": "Japanese Yen (JPY)",
        "symbol": "¥",
        "flag": "//img.staticdj.com/e2393bdde2c379e21d71ffbe77cc2739.png",
        "default": 0,
        "format": "amount",
        "currency_symbol_pos": "left",
        "finance": 155.872505
      }
    ]
  }
}
```

## List the coupons a customer can claim for a product

```text
GET /{locale}/api/discount-code/coupons
```

Get the coupons a customer can claim for one product.

### Example request

**Example request**

```javascript
fetch(window.SHOPLAZZA.routes.root + '/api/discount-code/coupons?product_id=14a309ec-b966-4cf9-a9bb-33baa821fdbc')
  .then((response) => response.json())
  .then((data) => {
    // do something...
  });
```

### Request parameters

- `product_id` string

  The id of the product.

### Response

The store used here runs no coupon campaign, so the list in the example is empty.

**Schema | Example**

- `data` undefined[]

  The response payload.

```json
{
  "data": []
}
```

## Get the language pack of a theme

```text
GET /{locale}/api/front/themes/languages
```

Get the language pack of a theme: the translated strings the storefront renders, grouped into catalogues.

### Example request

**Example request**

```javascript
fetch(window.SHOPLAZZA.routes.root + '/api/front/themes/languages?catalogues=all&theme_id=1709a232-7dc7-4412-9209-be8baf14b66f')
  .then((response) => response.json())
  .then((data) => {
    // do something...
  });
```

### Request parameters

- `catalogues` string

  The catalogues to return. Pass `all` to get every catalogue.
- `theme_id` string

  The id of the theme.

### Response

The example below leaves out most of the translation keys.

**Schema | Example**

- `data` object

  The response payload.

  - `config` object

    Storefront translation entries, grouped by section.

    - `bag` object

      Translation entries for the shopping bag.

      - `` object
    - `blog` object

      Translation entries for the blog.

      - `` object
    - `cart` object

      Translation entries for the cart.

      - `` object
  - `language` string

    Language code of the returned content, for example `en-US`.
- `msg` string

  Result message returned with the response.
- `state` number

  Request result flag; `success` or `0` means the request succeeded.

```json
{
  "data": {
    "config": {
      "bag": {},
      "blog": {},
      "cart": {}
    },
    "language": "en-US"
  },
  "msg": "请求成功",
  "state": 0
}
```
