• Stars
    star
    161
  • Rank 233,470 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated 24 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This tool allows you to export a Contentful space to a JSON dump

Contentful export tool

npm Build Status Dependency Status devDependency Status

semantic-release js-standard-style

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 is a library that helps you backup your Content Model, Content and Assets or move them to a new Contentful space. It will support Roles & Permissions in a future version.

To import your exported data, please refer to the contentful-import repository.

Usage as CLI

We moved the CLI version of this tool into our Contentful CLI. This allows our users to use and install only one single CLI tool to get the full Contentful experience.

Please have a look at the Contentful CLI export command documentation to learn more about how to use this as command line tool.

☁️ Pre-requisites && Installation

Pre-requisites

  • Node LTS

☁️ Installation

npm install contentful-export

Usage

const contentfulExport = require('contentful-export')

const options = {
  spaceId: '<space_id>',
  managementToken: '<content_management_api_key>',
  ...
}

contentfulExport(options)
  .then((result) => {
    console.log('Your space data:', result)
  })
  .catch((err) => {
    console.log('Oh no! Some errors occurred!', err)
  })

Querying

To scope your export, you are able to pass query parameters. All search parameters of our API are supported as documented in our API documentation.

const contentfulExport = require('contentful-export')

const options = {
  spaceId: '<space_id>',
  managementToken: '<content_management_api_key>',
  queryEntries: ['content_type=<content_type_id>']
}

contentfulExport(options)
...

The Export tool also support multiple inline queries.

const contentfulExport = require('contentful-export')

const options = {
  spaceId: '<space_id>',
  managementToken: '<content_management_api_key>',
  queryEntries: [
    'content_type=<content_type_id>',
    'sys.id=<entry_id>'
  ]
}

contentfulExport(options)
...

queryAssets uses the same syntax as queryEntries

Export an environment

const contentfulExport = require('contentful-export')

const options = {
  spaceId: '<space_id>',
  managementToken: '<content_management_api_key>',
  environmentId: '<environment_id>'
}

contentfulExport(options)
...

⚙️ Configuration options

Basics

spaceId [string] [required]

ID of the space with source data

environmentId [string] [default: 'master']

ID of the environment in the source space

managementToken [string] [required]

Contentful management API token for the space to be exported

deliveryToken [string]

Contentful Content Delivery API (CDA) token for the space to be exported.

Providing deliveryToken will export both entries and assets from the Contentful Delivery API, instead of the Contentful Management API. This may be useful if you want to export the latest published versions, as the management API always only exports the entirety of items, with the latest unpublished content. So if you want to make sure only to see the latest published changes, provide the deliveryToken.

Just to clarify: When Contentful Management API always returns the latest version (e.g. 50 in this case):

  "createdAt": "2020-01-06T12:00:00.000Z",
  "updatedAt": "2020-04-07T11:00:00.000Z",
  "publishedVersion": 23,
  "publishedAt": "2020-04-05T14:00:00.000Z",
  "publishedCounter": 1,
  "version": 50,

the Content Delivery API would return the publishedVersion (23). CDA responses don't include version number.

Note: Tags are only available on the Contentful Management API, so they will not be exported if you provide a Contenful Delivery Token. Tags is a new feature that not all users have access to.

Output

exportDir [string] [default: current process working directory]

Defines the path for storing the export JSON file

saveFile [boolean] [default: true]

Save the export as a JSON file

contentFile [string]

The filename for the exported data

Filtering

includeDrafts [boolean] [default: false]

Include drafts in the exported entries.

The deliveryToken option is ignored when includeDrafts has been set as true. If you want to include drafts, there's no point of getting them through the Content Delivery API.

includeArchived [boolean] [default: false]

Include archived entries in the exported entries

skipContentModel [boolean] [default: false]

Skip exporting content models

skipEditorInterfaces [boolean] [default: false]

Skip exporting editor interfaces

skipContent [boolean] [default: false]

Skip exporting assets and entries.

skipRoles [boolean] [default: false]

Skip exporting roles and permissions

skipTags [boolean] [default: false]

Skip exporting tags

skipWebhooks [boolean] [default: false]

Skip exporting webhooks

stripTags [boolean] [default: false]

Untag assets and entries

contentOnly [boolean] [default: false]

Only export entries and assets

queryEntries [array]

Only export entries that match these queries

queryAssets [array]

Only export assets that match these queries

downloadAssets [boolean]

Download actual asset files

Connection

host [string] [default: 'api.contentful.com']

The Management API host

proxy [string]

Proxy configuration in HTTP auth format: host:port or user:password@host:port

rawProxy [boolean]

Pass proxy config to Axios instead of creating a custom httpsAgent

maxAllowedLimit [number] [default: 1000]

The number of items per page per request

limit [number]

The total number of items to return. Can be used with entries or assets. If not provided, then all entries or assets will be returned. The entries or assets will be ordered using: sys.createdAt,sys.id.

headers [object]

Additional headers to attach to the requests.

Other

errorLogFile [string]

Full path to the error log file

useVerboseRenderer [boolean] [default: false]

Display progress in new lines instead of displaying a busy spinner and the status in the same line. Useful for CI.

⛑️ Troubleshooting

Proxy

Unable to connect to Contentful through your proxy? Try to set the rawProxy option to true.

contentfulExport({
  proxy: 'https://cat:[email protected]:1234',
  rawProxy: true,
  ...
})

Error: 400 - Bad Request - Response size too big.

Contentful response sizes are limited (find more info in our technical limit docs). In order to resolve this issue, limit the amount of entities received within a single request by setting the maxAllowedLimit option:

contentfulExport({
  proxy: 'https://cat:[email protected]:1234',
  rawProxy: true,
  maxAllowedLimit: 50
  ...
})

🗃️ Exported data structure

This is an overview of the exported data:

{
  "contentTypes": [],
  "entries": [],
  "assets": [],
  "locales": [],
  "tags": [],
  "webhooks": [],
  "roles": [],
  "editorInterfaces": []
}

Note: Tags feature is not available for all users. If you do not have access to this feature, the tags array will always be empty.

⚠️ Limitations

  • This tool currently does not support the export of space memberships.
  • Exported webhooks with credentials will be exported 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

More Repositories

1

contentful.js

JavaScript library for Contentful's Delivery API (node & browser)
TypeScript
1,189
star
2

rich-text

Libraries for handling and rendering Rich Text 📄
TypeScript
529
star
3

the-example-app.nodejs

Example app for Contentful in node.js
JavaScript
431
star
4

forma-36

A design system by Contentful
TypeScript
335
star
5

contentful-migration

🚚 Migration tooling for contentful
TypeScript
326
star
6

contentful-cli

The official Contentful command line interface. Use Contentful features straight from the command line!
JavaScript
322
star
7

contentful-management.js

JavaScript library for Contentful's Management API (node & browser)
TypeScript
270
star
8

extensions

Repository providing samples using the UI Extensions SDK
JavaScript
201
star
9

contentful.swift

A delightful Swift interface to Contentful's content delivery API.
Swift
195
star
10

starter-gatsby-blog

Gatsby starter for a Contentful project from the community.
JavaScript
194
star
11

cf-graphql

Generate a GraphQL schema out of your Contentful space
JavaScript
185
star
12

blog-in-5-minutes

Vue
170
star
13

field-editors

React components and extensions for building Contentful entry editor
TypeScript
148
star
14

contentful_middleman

Contentful Middleman is an extension to use the Middleman static site generator (Ruby) together with the API-driven Contentful CMS.
Ruby
145
star
15

Stargate

A communication channel from your Mac to your watch.
Swift
135
star
16

contentful.rb

Ruby client for the Contentful Content Delivery API
Ruby
135
star
17

apps

Apps on the Contentful Marketplace and resources to build them
TypeScript
132
star
18

ui-extensions-sdk

A JavaScript library to develop custom apps for Contentful
TypeScript
120
star
19

contentful.php

Official PHP Library for the Content Delivery API
PHP
113
star
20

discovery-app-react

A React.js based version of the Contentful Discovery app
JavaScript
111
star
21

contentful-import

Node module that uses the data provided by contentful-export to import it to contentful space
TypeScript
100
star
22

jekyll-contentful-data-import

Contentful Plugin for the Jekyll Static Site Generator
Ruby
99
star
23

create-contentful-app

Bootstrap a Contentful App
TypeScript
98
star
24

gallery-app-react

A React application example for the gallery space template.
JavaScript
97
star
25

contentful.net

.NET Library for Contentful's Content Delivery and Management API
C#
95
star
26

template-blog-webapp-nextjs

Next.js blog starter template
TypeScript
89
star
27

contentful-metalsmith

A plugin for Metalsmith that pulls content from the Contentful API
JavaScript
86
star
28

vault

Easy persistence of Contentful data for Android over SQLite.
Java
84
star
29

template-marketing-webapp-nextjs

Next.js marketing website starter template
TypeScript
80
star
30

contentful.java

Java SDK for Contentful's Content Delivery API
Java
74
star
31

create-contentful-extension

Create Contentful Extension is a CLI tool for developing in-app extensions without the hassle of managing build configurations.
JavaScript
71
star
32

ContentfulWatchKitExample

Example for a WatchKit app using the Contentful SDK
Swift
71
star
33

gallery-app-android

Android application example for the gallery space template.
Java
68
star
34

template-ecommerce-webapp-nextjs

Next.js ecommerce website starter template
TypeScript
63
star
35

compose-starter-helpcenter-nextjs

A sample website frontend for Compose with Next.js
TypeScript
59
star
36

live-preview

Preview SDK for both the field tagging connection + live content updates
TypeScript
56
star
37

contentful_rails

A ruby gem to help you quickly integrate Contentful into your Rails site
Ruby
52
star
38

contentful.objc

Objective-C SDK for Contentful's Content Delivery API and Content Management API.
Objective-C
50
star
39

contentful-resolve-response

Resolve items & includes of a Contentful API response into a proper object graph
JavaScript
46
star
40

contentful.py

Python client for the Contentful Content Delivery API https://www.contentful.com/developers/documentation/content-delivery-api/
Python
45
star
41

contentful-laravel

Laravel integration for the Contentful SDK.
PHP
44
star
42

contentful_model

A lightweight wrapper around the Contentful api gem, to make it behave more like ActiveRecord
Ruby
44
star
43

contentful-space-sync

Synchronize Contentful spaces
JavaScript
42
star
44

the-example-app.swift

Example app for Contentful in Swift
Swift
42
star
45

covid-19-site-template

#project-covid19
JavaScript
40
star
46

11ty-contentful-starter

Contentful 11ty starter project.
CSS
39
star
47

contentful-management.py

Python client for the Contentful Content Management API https://www.contentful.com/developers/documentation/content-management-api/
Python
36
star
48

product-catalogue-js

Product catalogue in JavaScript
JavaScript
36
star
49

contentful-management.rb

Ruby client for the Contentful Content Management API
Ruby
33
star
50

ContentfulBundle

Symfony Bundle for the Contentful SDK.
PHP
32
star
51

contribution-program

Contribute to the Contentful blog with pieces on "better ways to build websites". Get rewarded for each post you publish.
30
star
52

contentful_express_tutorial

A Simple Express js application Built on top of Contentful
JavaScript
30
star
53

rich-text-renderer.swift

Render Contentful Rich Text fields to native strings and views
Swift
29
star
54

contentful_jekyll_examples

Examples for Contentful and Jekyll Integration
29
star
55

11ty-contentful-gallery

Photo Gallery made using Contentful and 11ty.
Liquid
28
star
56

guide-app-sw

A generic guide app for shop guides
JavaScript
27
star
57

ls-postman-rest-api

26
star
58

gallery-app-ios

An iOS application example for the gallery space template.
Swift
26
star
59

contentful-management.java

Java library for using the Contentful Content Management API
Java
26
star
60

contentful-bootstrap.rb

Contentful CLI tool for getting started with Contentful
Ruby
24
star
61

contentful-graphql-playground-app

Contentful App to integrate GraphQL Playground
TypeScript
23
star
62

wordpress-exporter.rb

Adapter to extract data from Wordpress
Ruby
23
star
63

contentful-database-importer.rb

Adapter to extract data from SQL Databases https://www.contentful.com
Ruby
23
star
64

blog-app-android

Android application example for the blog space template.
Java
22
star
65

contentful-sdk-core

Core modules for the Contentful JS SDKs
TypeScript
22
star
66

contentful-persistence.swift

Simplified persistence for the Contentful Swift Library.
Swift
21
star
67

content-models

A set of example content models build with and for Contentful
19
star
68

product-catalogue-android

Android application example for the product catalogue space template.
Java
19
star
69

the-example-app.graphql.js

Example app for Contentful with GraphQL with React
JavaScript
19
star
70

boilerplate-javascript

Boilerplate project for getting started using javascript with Contentful
JavaScript
19
star
71

contentful-merge

CLI to merge entries between environments
TypeScript
18
star
72

the-example-app.php

Example app for Contentful in PHP
PHP
18
star
73

ng-contentful

Contentful module for AngularJS, providing access to the content delivery API
JavaScript
17
star
74

contentful_middleman_examples

A useful collection of examples using the `contentful_middleman` gem
Ruby
17
star
75

the-example-app.py

Example app for Contentful in Python
Python
17
star
76

The-Learning-Demo

Working repo for the new Learning Demo being developed by Learning Services
CSS
17
star
77

contentful-core.php

Foundation library for Contentful PHP SDKs
PHP
16
star
78

guide-app-ios

A generic iOS app for shop guides, styled as a guide to Coffee places.
Objective-C
16
star
79

starter-hydrogen-store

Example store starter template built with Contentful and Hydrogen framework from Shopify
JavaScript
16
star
80

contentful_django_tutorial

A Simple Django Application using Contentful
CSS
16
star
81

contentful-action

JavaScript
15
star
82

contentful-batch-libs

Library modules used by contentful batch utility CLI tools.
JavaScript
15
star
83

sveltekit-starter

Starter repo to get started with Sveltekit and Contentful
Svelte
15
star
84

contentful-scheduler.rb

Scheduling Server for Contentful entries
Ruby
15
star
85

blog-app-ios

An iOS application example for the blog space template.
Swift
15
star
86

the-example-app.kotlin

The example Android app. See how to connect to a sample space and use kotlin and Contentful unisono.
Kotlin
15
star
87

contentful-social.rb

Contentful Social Publishing Gem
Ruby
14
star
88

discovery-app-android

Contentful Discovery App for Android
Java
14
star
89

discovery-app

iOS app for previewing the content of Contentful Spaces
Objective-C
14
star
90

ls-content-as-code

Example content migration API scripts
JavaScript
13
star
91

blog-app-laravel

Example app using Contentful with Laravel.
PHP
13
star
92

slash-developers

THIS REPOSITORY IS DEPRECATED. Please do not open new PRs or issues.
HTML
13
star
93

node-apps-toolkit

A collection of helpers and utilities for creating NodeJS Contentful Apps
TypeScript
12
star
94

rich-text.php

Utilities for the Contentful Rich Text
PHP
12
star
95

the-example-app.csharp

Example app for Contentful in C#
C#
12
star
96

the-example-app.graphql.swift

The Example App and Contentful GraphQL Endpoint, using Apollo iOS, Contentful/ImageOptions
Swift
12
star
97

contentful-link-cleaner

Cleans up unresolved Entry links in Contentful spaces
JavaScript
11
star
98

tvful

Example for using the Contentful SDK for tvOS apps.
Swift
11
star
99

contentful-sdk-jsdoc

JSDoc template and config for the Contentful JS SDKs
JavaScript
10
star
100

generator.java

Code generator for Contentful models
Shell
10
star