Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including sphere-product-type-import with all npm packages installed. Try it out:

var sphereProductTypeImport = require("sphere-product-type-import")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

sphere-product-type-import v2.0.2

Library that helps with importing product type into the commercetools platform

commercetools logo


Travis Codecov npm semantic-release Commitizen friendly NPM version

A library that helps with importing product-types into the Commercetools Platform.
This library is built to be used in conjunction with sphere-node-cli.

Table of Contents


  • Import product types to your CTP project
  • Pre-validate product types using a JSON schema


The configuration object may contain:


Usage with sphere-node-cli

You can use the product type import from the command line using the sphere-node-cli. In order for the cli to import product types, the file to import from must be JSON and follow the this structure:

  "productTypes": [

Then you can import this file using the cli:

sphere-node-cli -t productType -p my-project-key -f /sample_dir/productTypes.json

You can pass a custom configuration as described above via the -c operator followed by a JSON String that represents your configuration

Direct usage

If you want more control, you can also use this library directly in JavaScript. To do this you first need to install it:

npm install sphere-product-type-import --save-dev

Then you can use it to import product types like so:

import ProductTypeImport from 'sphere-product-type-import'

const productType = {
  name: '<some-name>',
  description: '<some-description>'
const config = {
  importerConfig: {
    continueOnProblems: false
  sphereClientConfig: {
    config: {
      project_key: <PROJECT_KEY>,
      client_id: '*********',
      client_secret: '*********'
const productTypeImport = ProductTypeImport(config)

.then(() => {
  // done importing the productType
  // look at the summary to see errors
  // the summary hast the following structure
  // {
  //   errors: [],
  //   inserted: [<some-name>],
  //   successfulImports: 1
  // }

When there is an error during processing productTypes, process will by default save this error to summary.errors array and reject. If the configuration flag importerConfig.continueOnProblems is set to true the importer will only push error to summary and then continue with next productType.


See file for info on how to contribute to this library

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free