Blog

- November 17, 2015

Last week, we imported in bulk a listing of meteorite landings from a NASA open data set into our API, by using the CSV file import support. CSV import simplifies the filling of your API with data, without manually making tons of POST calls to add individual datum points. Exposing an API from data sets is convenient, but sometimes, you also need to do some further analysis of your data to derive some interesting graphs within an Excel spreadsheet, or you might need to feed some third-party system that only grok CSV files with the data of your API. So it’s natural to also take care of exporting your API’s data as CSV files.

We’re going to reuse our meteorites example from the previous article, and see how we can export a CSV file. This is actually pretty easy to do! Let’s go to the entity store associated with your API, click on the entity you want to export (here, my “meteorites”), then click on the “browser” tab. You’ll then be able to call the “export” feature in the menu behind the little cog button, on top of the data table:

export-csv

A dialog box will appear, asking you which separator you want to use for the CSV file (comma, semicolon or tab:

export-csv-dialog

Once you’ve clicked the “download” button, the preparation of your data will be done asynchronously, and the download will start on your computer automatically:

export-csv-async

Now what to do with that CSV file? Well, it’s up to you! As suggested in introduction, you might need to feed that data to a third-party system that ingests such flat data files, or your might need to do some nice reporting in Excel.

In my case, I wanted to know which classes of meteorites were most frequently impacting Earth. Excel to the rescue! After having imported the CSV file in a brand new Excel spreadsheet, I created a pivot table, with the class and mass of the meteorites. I grouped them by class, to count how many occurrences of each class there were, and then selected the top 20, to eventually display that information as an bar chart:

export-pivot-table

It seems the most frequent classes of meteorites are H4, H5, H6, as well as L5 and L6. Now, I’ll let the astrophysicist or cosmologist in you figure out what this actually means! Whatever conclusion you might come up with, you’ll understand that your raw API can not give you such analysis of the data, and only third-party tools can extract meaningful information. That’s when CSV exports of your data come in handy thanks to APISpark!