https://github.com/altabering/altadata-ruby
ALTADATA Ruby client provides convenient access to the ALTADATA API from applications written in the Ruby language.
https://github.com/altabering/altadata-ruby
altadata api-client ruby
Last synced: about 3 hours ago
JSON representation
ALTADATA Ruby client provides convenient access to the ALTADATA API from applications written in the Ruby language.
- Host: GitHub
- URL: https://github.com/altabering/altadata-ruby
- Owner: altabering
- License: mit
- Created: 2020-10-30T11:22:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-29T15:19:59.000Z (over 5 years ago)
- Last Synced: 2025-10-23T10:51:34.627Z (8 months ago)
- Topics: altadata, api-client, ruby
- Language: Ruby
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ALTADATA Ruby Client
[](https://github.com/altabering/altadata-ruby/actions)
[](https://rubygems.org/gems/altadata)
[ALTADATA](https://www.altadata.io) 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:
```ruby
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:
```ruby
require 'altadata'
client = Altadata::Client.new(api_key='YOUR_API_KEY')
```
## Retrieving Data
You can get the entire data with the code below.
```ruby
data = client.get_data(product_code = PRODUCT_CODE).load
```
## Retrieving Subscription Info
You can get your subscription info with the code below.
```ruby
product_list = client.list_subscription
```
## Retrieving Data Header Info
You can get your data header with the code below.
```ruby
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
```ruby
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
```ruby
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
```ruby
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
```ruby
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
```ruby
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
```ruby
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
```ruby
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.
```ruby
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](https://rubygems.org).
## License
The gem is available as open source under the terms of the [MIT License](https://github.com/altabering/altadata-ruby/blob/master/LICENSE).