Content Api

Export Data

To export the data from the builder, we can fetch the entries from the builder API & then export the data to some file.

Export Data

To export the data from the builder, we can fetch the entries from the builder API & then export the data to some file.

To fetch the entries from the builder API, we can use the GET API.

Assuming that we are using a nodejs script, we can use the fetch method to fetch the entries from the builder API.

const response = await fetch('https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
  },
});

where my-model-name is the model name of the entry & YOUR_API_KEY is the public API key of the builder.

Once we get the response, we can use the json() method to convert the response to JSON. & then we can write the data to the file.

but before writing the data to the file, we need to convert the data to JSON or CSV.

Convert to JSON

const toJson = data => JSON.stringify(data, null, 2);

Convert to CSV

const toCsv = data => {
    const headers = Object.keys(data[0]);
    const rows = data.map(row => headers.map(field => JSON.stringify(row[field] ?? '')).join(','));
    return [headers.join(','), ...rows].join('\n');
};

we can call one of the above methods to convert the data to JSON or CSV. & then we can write the data to the file.

for example, if we want to convert the data to CSV, we can use the below code.

fs.writeFileSync('filename.csv', toCsv(data));
console.log(`filename.csv has been saved!`);

or if we want to convert the data to JSON, we can use the below code.

fs.writeFileSync('filename.json', toJson(data));
console.log(`filename.json has been saved!`);

once the code is executed, the data will be saved to the file on current directory.

Note: here fs is the node built-in module to read and write files & it needs to be imported at the top of the script.


Copyright © 2026