Contentful import tool
Contentful provides a content infrastructure for digital teams to power content in websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship digital products faster.
This Command Line Tool (CLI) helps you to import files generated by contentful-export to a destination space.
Installation
We recommend you install the CLI via npm:
npm install -g contentful-import
Usage and examples
Usage: contentful-import [options]
Options:
--version Show version number [boolean]
--space-id ID of the destination space [string] [required]
--management-token Contentful management API token for the destination
space [string] [required]
--content-file JSON file that contains data to be import to your
space [string] [required]
--content-model-only Import only content types[boolean] [default: false]
--skip-content-model Skip importing content types and locales
[boolean] [default: false]
--skip-locales Skip importing locales [boolean] [default: false]
--skip-content-publishing Skips content publishing. Creates content but does
not publish it [boolean] [default: false]
--error-log-file Full path to the error log file [string]
--proxy Proxy configuration in HTTP auth format: host:port
or user:password@host:port [string]
--config An optional configuration JSON file containing all
the options for a single run
Example
contentful-import \
--space-id spaceID \
--management-token managementToken \
--content-file exported-file.json \
or
contentful-import --config example-config.json
You can create your own configuration file based on the example-config.json file.
Usage as a library
While this tool is intended for use as a command line tool, you can also use it as a Node library:
let spaceImport = require('contentful-import')
let options = {
content: {entries:..., contentTypes:..., locales:...},
spaceId: 'SPACE_ID',
managementToken: 'MANAGEMENT_TOKEN'
}
spaceImport(options)
.then((output) => {
console.log('Data Imported successfully')
})
.catch((err) => {
console.log('oh no! errors occurred!', err)
})
The options
object can contain any of the CLI options, but written with a camelCase pattern instead and no dashes. For example --space-id
would become spaceId
.
Importing to a space with existing content
- Both source space and destination space must share the same content model structure. In order to achieve that, please use the migration-cli.
- Content transformations are also not supported, please use the migration-cli.
- Entities existence are determined based on their ID:
- If an entity does not exist in the destination space, it will be created.
- If an entity already exists in the destination space, it will be updated.
- Publishing strategy:
- If an entity is in draft, it will be created as draft in the destination space.
- If an entity is published and has pending changes (updated) in the source space, it will be published with the latest changes in the destination space.
Limitations
- This tool currently does not support the import of space memberships.
- This tool currently does not support the import of roles.
- This tool is expecting the target space to have the same default locale as your previously exported space.
- Imported webhooks with credentials will be imported as normal webhooks. Credentials should be added manually afterwards.
- If you have custom UI extensions, you need to reinstall them manually in the new space.
Changelog
Read the releases page for more information.
License
This project is licensed under MIT license