Skip to content

ALTADATA Java client provides convenient access to the ALTADATA API from applications written in the Java language.

License

Notifications You must be signed in to change notification settings

altabering/altadata-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ALTADATA Java Client

Build status Maven central javadoc

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

Installing with Maven

To include altadata-java in your Maven application, add a dependency on its artifacts to your project's pom.xml file. For example,

<dependency>
    <groupId>io.altadata</groupId>
    <artifactId>altadata-java</artifactId>
    <version>0.1.1</version>
</dependency>

Quickstart

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

import io.altadata.AltaData;

AltaData client = new AltaData("YOUR_API_KEY");

Retrieving Data

You can get the entire data with the code below.

ArrayList<JSONObject> data = client.get_data("PRODUCT_CODE").load();

Retrieving Subscription Info

You can get your subscription info with the code below.

ArrayList<JSONObject> subscription_info = client.list_subscription();

Retrieving Data Header Info

You can get your data header with the code below.

Set<String> header_info = client.get_header("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

String product_code = "co_10_jhucs_03";

ArrayList<JSONObject> data = client.get_data(product_code)
    .equal("province_state", "Alabama")
    .load();

not equal condition

String product_code = "co_10_jhucs_03";

ArrayList<JSONObject> data = client.get_data(product_code)
    .not_equal("province_state", "Montana")
    .load();

in condition

String product_code = "co_10_jhucs_03";

ArrayList<JSONObject> data = client.get_data(product_code)
    .condition_in("province_state", new String[]{"Montana", "Utah"})
    .load();

condition_value parameter of condition_in method must be Array

not in condition

String product_code = "co_10_jhucs_03";

ArrayList<JSONObject> data = client.get_data(product_code)
    .condition_not_in("province_state", new String[]{"Montana", "Utah", "Alabama"})
    .load();

condition_value parameter of condition_not_in method must be Array

sort operation

String product_code = "co_10_jhucs_03";
String order_method = "desc";

ArrayList<JSONObject> data = client.get_data(product_code)
    .sort("reported_date", order_method)
    .load();

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

select specific columns

String product_code = "co_10_jhucs_03";
String[]selected_column = {"reported_date", "province_state", "mortality_rate"};

ArrayList<JSONObject> data = client.get_data(product_code)
    .select(selected_column)
    .load();

selected_column parameter of select method must be Array

get the specified amount of data

String product_code = "co_10_jhucs_03";
int data_limit = 20;

ArrayList<JSONObject> data = client.get_data(product_code, data_limit).load();

Retrieving Data with Multiple Conditions

You can use multiple condition at same time.

String product_code = "co_10_jhucs_03";
int data_limit = 100;
String order_method = "desc";
String[] selected_column = {"reported_date", "province_state", "mortality_rate"};

ArrayList<JSONObject> data = client.get_data(product_code, data_limit)
    .condition_in("province_state", new String[]{"Montana", "Utah"})
    .sort("mortality_rate", order_method)
    .select(selected_column)
    .load();

License

altadata-java is under MIT license. See the LICENSE file for more info.

About

ALTADATA Java client provides convenient access to the ALTADATA API from applications written in the Java language.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages