Import Catalog Data

Last updated 3 months ago


Moltin flexible API allows you to quickly and easily import data. CSV files are a very common way to extract and share data. All endpoint are read write and update, meaning you can import products, customer and orders.

In this guide we will look at importing product data, and establishing relationships in the API to have a functional product catalog organized programatically.

Setup Summary

  1. Prepare a file with data and setup a project with Moltin.

  2. Install the sample script from GitHub.

  3. Review the code in the sample script. The code can be customized according to your needs.

  4. Review the commands that control how the script is run.

  5. Upload new/updated data programatically.


Before you proceed with the import, you'll need:

Scenario setup

In this guide, we will look to implement a CSV file of products that have main images, Category, Collection and Brand.

To use another format adjust to the file format you need delimiter: ',' (

  1. Download the sample Shopify data. Use the data file to follow along with the guide.

2. Install the script to upload the data you've created to Moltin.

git clone

3. Use this command to install the packages the script above uses.

//In terminal navigate to the folder where you cloned the repo
npm install

Once the script and the command run successfully, your Moltin project will have a catalog of data you've specified in the data file.

Organize your data

It is recommended to review your data before the upload, so that it matches Moltin standards. If you're using the sample data file, skip this step.

Adjust the data model

Adjust the data model to match your CSV headers. The names of the headers in your CVS file need to match your code.

The only header that matter is image that will be used as the main image. This column must have the header main_image. All other images will be add as files to the product.















Ocean Blue Shirt

Ocean blue cotton shirt with a narrow collar and buttons down the front and long sleeves. Comfortable fit and tiled kalidoscope patterns.





Cool Brand


Top Picks

Object to match to headers
Where the data is returned
module.exports = async function(path = ".") {
//need to be able to take in the objects we want to use
const [
//objects in order of maps
] = await Promise.all([
//source data to parse
readCsvToArray(`${path}`, [
//The parsed data will be returned
return {
inventory: catalog

Customize Moltin catalog objects

In the import folder you will see all of the Moltin catalog objects (Brands, Categories, Collections and Main Image). This is where you can match the parsed data to the data you want to send to Moltin. In this example we will add Products with Brand, Collection, Category and file relationships.

Create Brands, Categories, Collections and Main Images

Main Image
const brandM = await Moltin.Brands.Create({
type: 'brand',
name: brand.brand,
description: brand.brand,
slug: brand.brand.replace(/[^A-Z0-9]/gi, '_'),
status: 'live'
const categoryM = await Moltin.Categories.Create({
type: 'category',
name: category.category,
description: category.category,
slug: category.category.replace(/[^A-Z0-9]/gi, '_'),
status: 'live'
const collectionM = await Moltin.Collections.Create({
type: 'collection',
name: collection.collection,
description: collection.collection,
slug: collection.collection.replace(/[^A-Z0-9]/gi, '_'),
status: 'live'
// need to identify what you want for your main image
const options = {
url: image.main_image,
dest: `data/temp/${image.main_image}`

These will create the objects in Moltin. You can manipulate these to pass any data you want to these objects. This is also a great place to pass custom data to these objects using Flows.

Create a Product

Similar to the above objects this is where you can configure the data object to have all of the information you want to pass to the Moltin product object. By default, imported Products will have the draft status. You can change this by updating the status field form draft to live.

Slug doesn't support foreign characters.

Create Product
let productM = await Moltin.Products.Create({
type: 'product',
name: product.title,
slug: product.title.replace(/[^A-Z0-9]/gi, '_'),
status: 'draft',
price: [
amount: Number(product.price) * 100,
currency: 'USD',
includes_tax: true
sku: product.sku,
manage_stock: false,
commodity_type: 'physical',
description: product.description

Create Product catalogue relationships

Review the relationships you wish to establish in your catalog. The key is to use the id from the newly created product, and then find the corresponding catalogue attribute (brand, category, etc).


// Find the category for the product from the list of already uploaded categories.
var productsCategory = categoriesM.find(function(productsCategory) {
return productsCategory.categories === product.categories;
Main Image
//TIE PRODUCT to Brand
'Assigning product id [%s] with brand name [%s]',,
const productsbrand = brandsM.find(function(productsbrand) {
return === product.brand;
await Moltin.Products.CreateRelationships(,
//TIE PRODUCT to Category
"Assigning product id [%s] with category name [%s]",,
const productscategory = categoryM.find(function(productscategory) {
return === product.category;
await Moltin.Products.CreateRelationships(,
//TIE PRODUCT to Collection
"Assigning product id [%s] with collection name [%s]",,
var productscollection = collectionsM.find(function(productscollection) {
return === product.collection;
await Moltin.Products.CreateRelationships(,
//Need to format to match the file name used in images.js
const fullName = + ".jpg";
console.log("Assigning image %s to %s",, fullName);
//TIE PRODUCT to MainImage
const productsMainImage = imagesImport.find(function(productsMainImage) {
return productsMainImage.file_name === fullName;
"Assigning image %s to %s",
await Moltin.Products.CreateRelationshipsRaw(,
type: "main_image"

Add your site credentials

Add in your Moltin client token in the top of the moltin.js file.

Client Id
const Moltin = MoltinGateway({
client_id: "MOLTIN_CLIENT_ID",
client_secret: "MOLTIN_CLIENT_SECRET"

Run the script

node app.js "Path to your file"
node app.js "/Users/[username]/Downloads/apparel.csv"

If you are using your own data update to match the path to your file

Options for running the script

If you are re-running the script, you can selectively skip certain steps (of upload) or require that a script first cleans up your store:

node app.js "path" --delete=<brands> --delete=<another entity> --skip=<products> --skip=<another entity>

You can clean: products, categories, brands, and Files (images). To request that multiple entities be cleaned please use --delete=<entity> for each entity. Delete is for all, you can't skip anything.

Where to go from here

This is the most basic script that can be used to get you started. This can be extended to solve parent children hierarchy need and product variations. The general paradigm can also be used in other language and environments.