Languages

Moltin provides a multilingual service for the Product API. Using the Settings API you can add additional supported languages, and when you update a product, you can specify the X-Moltin-Language header.

To be able to create translations, you'll need to first add the desired language(s) to your store settings. You can read more about how you can achieve this here.

You can create translations for both product name and description fields.

Create a Translation

PUT https://api.moltin.com/v2/products/:id

Path Parameters

NameTypeDescription

id

string

The ID of the product you wish to update

Headers

NameTypeDescription

X-Moltin-Language

string

The language code defined in project settings

Authorization

string

The Bearer token to grant access to the API

Request Body

NameTypeDescription

description

string

The translated description value

name

string

The translated name value

id

string

The Product ID

type

string

Always product

{
    "data": {
        "type": "product",
        "id": "67b482da-e9db-4eb1-b279-f63989017a66",
        "name": "nombre del producto",
        "slug": "producto",
        "sku": "PROD-001",
        "manage_stock": true,
        "description": "descripción del producto",
        "price": [
            {
                "amount": 2000,
                "currency": "USD",
                "includes_tax": false
            }
        ],
        "status": "live",
        "commodity_type": "physical",
        "meta": {
            "timestamps": {
                "created_at": "2019-07-03T09:01:28+00:00",
                "updated_at": "2019-07-03T09:03:04+00:00"
            },
            "display_price": {
                "with_tax": {
                    "amount": 2000,
                    "currency": "USD",
                    "formatted": "$20.00"
                },
                "without_tax": {
                    "amount": 2000,
                    "currency": "USD",
                    "formatted": "$20.00"
                }
            },
            "stock": {
                "level": 0,
                "availability": "out-stock"
            }
        },
        "relationships": {}
    }
}
curl -X PUT https://api.moltin.com/v2/products/:id \
    -H "Authorization: Bearer XXXX" \ 
    -H "X-Moltin-Language: es" \ 
    -H "Content-Type: application/json" \
    -d $'{
      "data": {
        "type": "product",
        "id": "{PRODUCT_ID}",
        "slug": "producto",
        "name": "nombre del producto",
        "description": "descripción del producto"
      }
    }'

If the requested language does not have a translation available, the default language will be returned.

Get all Products by Preferred Language

GET https://api.moltin.com/v2/products

Headers

NameTypeDescription

X-Moltin-Language

string

The language code as defined in project settings

Authorization

string

The Bearer token to grant access to the API

{
    "data": [
        {
            "type": "product",
            "id": "9eda5ba0-4f4a-4074-8547-ccb05d1b5981",
            "name": "nombre del producto",
            "slug": "crown",
            "sku": "CWLP100BLK",
            "manage_stock": true,
            "description": "descripción del producto",
            "price": [
                {
                    "amount": 47500,
                    "currency": "USD",
                    "includes_tax": true
                }
            ],
            "status": "live",
            "commodity_type": "physical",
            "meta": {
                "timestamps": {
                    "created_at": "2017-06-19T14:58:42+00:00",
                    "updated_at": "2018-04-10T09:12:05+00:00"
                },
                "display_price": {
                    "with_tax": {
                        "amount": 47500,
                        "currency": "USD",
                        "formatted": "$475.00"
                    },
                    "without_tax": {
                        "amount": 47500,
                        "currency": "USD",
                        "formatted": "$475.00"
                    }
                },
                "stock": {
                    "level": 500,
                    "availability": "in-stock"
                }
            },
            "relationships": {
                "files": {
                    "data": [
                        {
                            "type": "file",
                            "id": "7cc08cbb-256e-4271-9b01-d03a9fac9f0a"
                        }
                    ]
                },
                "categories": {
                    "data": [
                        {
                            "type": "category",
                            "id": "a636c261-0259-4975-ac8e-77246ec9cfe0"
                        }
                    ]
                },
                "main_image": {
                    "data": {
                        "type": "main_image",
                        "id": "7cc08cbb-256e-4271-9b01-d03a9fac9f0a"
                    }
                }
            },
            "material": null,
            "max_watt": null,
            "bulb_qty": null,
            "bulb": null,
            "new": null,
            "on_sale": null,
            "background_colour": "#d9d9d9",
            "finish": "test"
        }
    ],
    "links": {
        "current": "https://api.moltin.com/v2/products?page[limit]=100&page[offset]=0",
        "first": "https://api.moltin.com/v2/products?page[limit]=100&page[offset]=0",
        "last": null
    },
    "meta": {
        "results": {
            "total": 10,
            "all": 10
        },
        "page": {
            "limit": 100,
            "offset": 0,
            "current": 1,
            "total": 1
        }
    }
}
curl -X GET https://api.moltin.com/v2/products \
    -H "Authorization: Bearer XXXX" \ 
    -H "X-Moltin-Language: es"

Get a translated Product by ID

GET https://api.moltin.com/v2/products/:id

Path Parameters

NameTypeDescription

id

string

The ID of the product

Headers

NameTypeDescription

X-Moltin-Language

string

The language code as defined in project settings

Authorization

string

The Bearer token to grant access to the API

{
  "data": {
    "type": "product",
    "id": "6837058c-ae42-46db-b3c6-7f01e0c34b40",
    "name": "nombre del producto",
    "description": "descripción del producto.",
    // ...
  }
}
curl -X GET https://api.moltin.com/v2/products/:id \
    -H "Authorization: Bearer XXXX" \ 
    -H "X-Moltin-Language: es"

Last updated