Need help with mira?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

davbre
193 Stars 14 Forks MIT License 107 Commits 8 Opened issues

Description

Create simple APIs from CSV files

Services available

!
?

Need anything else?

Contributors list

# 416,288
HTML
cryptoc...
cryptoc...
TypeScr...
103 commits

Mira

Mira is a Ruby on Rails application which gives you a simple HTTP API for CSV files.

Summary

  1. 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...

  2. 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.

  3. With the datapackage.json file Mira then does the following:

    • it creates an empty database table for each CSV file specified in the datapackage.json file.
    • it creates an API to these database tables which you can use to read and write data.
  4. You write data to the database tables by uploading CSV files, or by using a JSON API.

  5. You can query the data using simple API requests. Consider a table

    mytable
    in a project, with columns
    col1
    ,
    col2
    and
    col3
    . To get rows where
    col1
    equals "XXX",
    col2
    equals "YYY" and
    col3
    equals "ZZZ", you could make the following
    GET
    request:

  http://localhost:3000/api/projects/1/tables/mytable/data?col1eq=XXX&col2eq=YYY&col3_eq=ZZZ
  

See the demo for more details on how the data can be queried.

  1. You can generate API keys to control the reading and writing data.

Quick Start

Pre-requisites

https://www.digitalocean.com/community/tutorials/how-to-use-postgresql-with-your-ruby-on-rails-application-on-ubuntu-14-04


  1. Clone the repository

  2. Run bundle

    bundle install
    
  3. 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></:>

  4. 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
    
  5. Start your local development server

    rails s
    
  6. In a separate terminal start a background job to process uploaded files

    rake jobs:work
    
  7. Open up the Mira homepage:

    http://localhost:3000

  8. Download sample csv files + their datapackage.json file:

    mirasampledata.tar.gz or mirasampledata.zip

  9. Log in, create a new project, first upload the datapackage.json file, then the sample csv files

  10. Navigate to the following address for the project's API details:

    http://localhost:3000/projects/1/api-details

Extra Notes

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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.