Project

altadata

0.0
No commit activity in last 3 years
No release in over 3 years
ALTADATA Ruby gem provides convenient access to the ALTADATA API from applications written in the Ruby language.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13.0
~> 3.6
~> 1.1

Runtime

~> 1.0
>= 1.8.0
 Project Readme

ALTADATA Ruby Client

Build status Gem Version

ALTADATA is a Curated Data Marketplace. This Ruby gem provides convenient access to the ALTADATA API from applications written in the Ruby language. With this Ruby gem, developers can build applications around the ALTADATA API without having to deal with accessing and managing requests and responses.

Installation

Add this line to your application's Gemfile:

gem 'altadata'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install altadata

Quickstart

Obtain an API key in your dashboard and initialize the client:

require 'altadata'

client = Altadata::Client.new(api_key='YOUR_API_KEY')

Retrieving Data

You can get the entire data with the code below.

data = client.get_data(product_code = PRODUCT_CODE).load

Retrieving Subscription Info

You can get your subscription info with the code below.

product_list = client.list_subscription

Retrieving Data Header Info

You can get your data header with the code below.

client.get_header(product_code = PRODUCT_CODE)

Retrieving Data with Conditions

You can get data with using various conditions.

The columns you can apply these filter operations to are limited to the filtered columns.

You can find the filtered columns in the data section of the data product page.

equal condition

PRODUCT_CODE = 'co_10_jhucs_03'

data =
    client.get_data(product_code = PRODUCT_CODE)
        .equal(condition_column = 'province_state', condition_value = 'Alabama')
        .load

not equal condition

PRODUCT_CODE = 'co_10_jhucs_03'

data =
    client.get_data(product_code = PRODUCT_CODE)
        .not_equal(condition_column = 'province_state', condition_value = 'Montana')
        .load

in condition

PRODUCT_CODE = 'co_10_jhucs_03'

data =
    client.get_data(product_code = PRODUCT_CODE)
        .condition_in(condition_column = 'province_state', condition_value = %w[Montana Utah])
        .load

condition_value parameter of condition_in method must be Array

not in condition

PRODUCT_CODE = 'co_10_jhucs_03'

data =
    client.get_data(product_code = PRODUCT_CODE)
        .condition_not_in(condition_column = 'province_state', condition_value = %w[Montana Utah Alabama])
        .load

condition_value parameter of condition_not_in method must be Array

sort operation

PRODUCT_CODE = 'co_10_jhucs_03'

data =
    client.get_data(product_code = PRODUCT_CODE)
        .sort(order_column = 'reported_date', order_method = 'desc')
        .load

Default value of order_method parameter is 'asc' and order_method parameter must be 'asc' or 'desc'

select specific columns

PRODUCT_CODE = 'co_10_jhucs_03'

data =
    client.get_data(product_code = PRODUCT_CODE)
        .select(selected_column = %w[reported_date province_state mortality_rate])
        .load

selected_column parameter of select method must be Array

get the specified amount of data

PRODUCT_CODE = 'co_10_jhucs_03'

data =
    client.get_data(product_code = PRODUCT_CODE, limit = 20)
        .load

Retrieving Data with Multiple Conditions

You can use multiple condition at same time.

PRODUCT_CODE = 'co_10_jhucs_03'

data =
    client.get_data(product_code = PRODUCT_CODE, limit = 100)
        .condition_in(condition_column = "province_state", condition_value = %w[Montana Utah])
        .sort(order_column = 'mortality_rate', order_method = 'desc')
        .select(selected_column = %w[reported_date province_state mortality_rate])
        .load

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

License

The gem is available as open source under the terms of the MIT License.