CodingAnxiety
CodingAnxiety

Reputation: 206

Importing large amount of data from API into Contentful?

I have started building a movie review website with React as my frontend and Contentful to handle everything else. I have started writing a script with contentful-management package to get all the movies from the last decade into Contentful by using The movie database and IMDB, but I soon realized this is quite tedious and it will still take a very long time.

I have seen that the whole database of movies from IMDB or TMDB is available for download in multiple files, so maybe I could read the data from the files to avoid making so many GET requests (and get my IP banned ;-).

What would be the most efficient way of building a database of movies from the last decade in Contentful?

Perhaps it isn't even necessary for me to have my own database of movies, I'm not sure what the best course of action is in my case.

I appreciate any suggestions, thanks!

Upvotes: 1

Views: 2595

Answers (1)

stefan judis
stefan judis

Reputation: 3879

Heyooo, Contentful DevRel here. :)

The best approach here is to use Contentful import/export. We provide a CLI tool that accepts a JSON file and will handle all the content management API operations for you. The way I'd approach this is to:

  • create data structures in Contentful and export them using "contentful export"
  • have a look at the generated export.json
  • write a script that takes the data I want to get into contentful and brings it into the right format
  • use "contentful import" to import the data.

Hope that helps, and good luck!

Upvotes: 2

Related Questions