Create simple APIs from CSV files
Mira is a Ruby on Rails application which gives you a simple HTTP API for CSV files.
You create a Mira project. A project is simply a home for one or more CSV files, along with a datapackage.json file. More on that now...
You provide Mira with information about your CSV files by uploading a datapackage.json file to the project. This file provides metadata for the CSV files you plan to upload to the project. i.e. file names, columns names and types, delimiters etc. See here and here for more information about datapackage.json files and tabular data packages.
With the datapackage.json file Mira then does the following:
You write data to the database tables by uploading CSV files, or by using a JSON API.
You can query the data using simple API requests. Consider a table
mytablein a project, with columns
col3. To get rows where
col2equals "YYY" and
col3equals "ZZZ", you could make the following
See the demo for more details on how the data can be queried.
Clone the repository
Update the config/database.yml file with your database credentials. Assuming you've created a user "mira" with full access to a database of the same name:
default: &default adapter: postgresql encoding: unicode pool: 5 host: localhost port: 5432 username: mira password: **your_password_here**
development: <<: database: mira_dev test: mira_test></:>
Create and migrate database, and seed database with a single admin user (email = [email protected] and password = topsecret):
rake db:create rake db:migrate rake db:seed
Start your local development server
In a separate terminal start a background job to process uploaded files
Open up the Mira homepage:
Download sample csv files + their datapackage.json file:
Log in, create a new project, first upload the datapackage.json file, then the sample csv files
Navigate to the following address for the project's API details:
Assuming a write API key has been generated, here's how you can write data:
curl -d "data[col1]=value1&data[col2]=val2" -H "X-Api-Key: 6041fa394bc84abe46ffdb71" http://localhost:3000/api/projects/1/tables/mytable/data