From 0dc7fb93f5abd35d751d7c35af4e1322c513ea6e Mon Sep 17 00:00:00 2001 From: crazzyghost Date: Mon, 11 Jan 2021 19:35:25 +0000 Subject: [PATCH] update readme --- CHANGELOG.md | 27 +++++++++++++++++---------- README.md | 35 ++++++++++++++++++++++++++--------- docs/changelog.md | 4 ++++ docs/index.md | 40 +++++++++++++++++++++++++++++++++------- 4 files changed, 80 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af0f4e..3398a49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.5.0] - 11-01-2021 +### Added +- Support for synchronous requests + ## [v1.4.2] - 20-10-2020 ### Fixed - [Missing crypto unit date](https://github.com/crazzyghost/alphavantage-java/pull/13) @@ -80,15 +84,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Tests for Time Series - README -[1.4.0]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.4.0 -[1.3.1]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.3.1 -[1.3.2]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.3.2 -[1.3.0]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.3.0 -[1.2.1]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.2.1 -[1.2.0]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.2.0 -[1.1.1]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.1.1 -[1.1.0]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.1.0 -[1.0.2]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.0.2 -[1.0.1]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.0.1 +[v1.5.0]: https://github.com/crazzyghost/alphavantage-java/compare/1.4.2...1.5.0 +[v1.4.2]: https://github.com/crazzyghost/alphavantage-java/compare/1.4.1...1.4.2 +[v1.4.1]: https://github.com/crazzyghost/alphavantage-java/compare/1.4.0...1.4.1 +[v1.4.0]: https://github.com/crazzyghost/alphavantage-java/compare/1.3.2...1.4.0 +[v1.3.2]: https://github.com/crazzyghost/alphavantage-java/compare/1.3.1...1.3.2 +[v1.3.1]: https://github.com/crazzyghost/alphavantage-java/compare/1.3.0...1.3.1 +[v1.3.0]: https://github.com/crazzyghost/alphavantage-java/compare/1.2.1...1.3.0 +[v1.2.1]: https://github.com/crazzyghost/alphavantage-java/compare/1.2.0...1.2.1 +[v1.2.0]: https://github.com/crazzyghost/alphavantage-java/compare/1.1.1...1.2.0 +[v1.1.1]: https://github.com/crazzyghost/alphavantage-java/compare/1.1.0...1.1.1 +[v1.1.0]: https://github.com/crazzyghost/alphavantage-java/compare/1.0.2...1.1.0 +[v1.0.2]: https://github.com/crazzyghost/alphavantage-java/compare/1.0.1...1.0.2 +[v1.0.1]: https://github.com/crazzyghost/alphavantage-java/releases/tag/1.0.1 [1.0.0]: https://github.com/crazzyghost/alphavantage-java/tree/9d1cbca8a48899398513494ae6717bec0fa93cfb [ajt001]: https://github.com/ajt001 \ No newline at end of file diff --git a/README.md b/README.md index f4af864..b663220 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![codecov](https://codecov.io/gh/crazzyghost/alphavantage-java/branch/master/graph/badge.svg)](https://codecov.io/gh/crazzyghost/alphavantage-java) [![](https://jitpack.io/v/crazzyghost/alphavantage-java.svg)](https://jitpack.io/#crazzyghost/alphavantage-java) -I created this wrapper to make accessing the [AlphaVantage API](https://www.alphavantage.co/) fairly simple and fun by providing a fluent interface with Java. +An easy to use, fluent Java wrapper for accessing the [AlphaVantage API](https://www.alphavantage.co/). ## Getting Started @@ -49,15 +49,19 @@ dependencies { These five steps summarize how to access data using this library -1. `config`ure the wrapper -2. Select a `category` -3. Set the `parameters` for the selected category -4. Add `response callbacks` -5. `fetch` results +Step 1. `config`ure the wrapper + +Step 2. Select a `category` + +Step 3. Set the `parameters` for the selected category + +Step 4. (Optional) Add `response callbacks` + +Step 5. `fetch` results #### 1. `Config`uring the wrapper -Access to the API is through the AlphaVantage Singleton which is accessed using the `static` `api()` method of the class. Initialize the singleton with a `Config` instance once through out your apps lifetime. +Access to the API is through the AlphaVantage Singleton which is accessed using the `static` `api()` method of the class. Initialize the singleton with a `Config` instance once throughout your app's lifetime. ```java Config cfg = Config.builder() @@ -66,7 +70,7 @@ Config cfg = Config.builder() .build(); ``` -The config object is then used to initialize the instance. You will use this object to set your api key and configure the http client. Using the wrapper without setting a config or a config key will throw an exception. +Initialize the instance with the config. You will use this object to set your api key and configure the http client. Using the wrapper without setting a config or a config key will throw an exception. ```java AlphaVantage.api().init(cfg); @@ -111,7 +115,7 @@ Start setting parameters by calling an appropriate function method in the select #### 4. Adding `response callbacks` -To handle responses add the `onSuccess()` or `onFailure()` callbacks. +To handle responses add the `onSuccess()` or `onFailure()` async callbacks. Starting from version 1.5.0, this is an optional step. ```java public void handleSuccess(TimeSeriesResponse response) { @@ -148,4 +152,17 @@ AlphaVantage.api() .fetch(); ``` +If you want a synchronous response, call the `fetchSync()` method. + +```java +TimeSeriesResponse response = AlphaVantage.api() + .timeSeries() + .intraday() + .forSymbol("IBM") + .interval(Interval.FIVE_MIN) + .outputSize(OutputSize.FULL) + .fetchSync(); +``` + + That's it! :tada: See [site](https://crazzyghost.github.io/alphavantage-java/) and [demo project](https://github.com/crazzyghost/stockmonitor) for more examples & documentation diff --git a/docs/changelog.md b/docs/changelog.md index 9987190..3215dc8 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,9 @@ # Changelog +## [v1.5.0] - 11-01-2021 + +- New: Support for synchronous requests + ## v1.4.2 - 20-10-2020 - [Missing crypto unit date](https://github.com/crazzyghost/alphavantage-java/pull/13) diff --git a/docs/index.md b/docs/index.md index 6d33ac7..200eda2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -47,11 +47,15 @@ dependencies { These five steps summarize how to access data using this library -1. `config`ure the wrapper -2. Select a `category` -3. Set the `parameters` for the selected category -4. Add `response callbacks` -5. `fetch` results +Step 1. `config`ure the wrapper + +Step 2. Select a `category` + +Step 3. Set the `parameters` for the selected category + +Step 4. (Optional) Add `response callbacks` + +Step 5. `fetch` results #### 1. `Config`uring the wrapper @@ -74,7 +78,7 @@ Access to the API is through the AlphaVantage Singleton which is accessed using .timeOut(10) .build() -The config object is then used to initialize the instance. You will use this object to set your api key and configure the http client. +Use the config object to initialize the api instance. You will use this object to set your api key and configure the http client. !!! warning Using the wrapper without setting a config or a config key will throw an exception. @@ -142,7 +146,7 @@ Let's select the `TIME_SERIES_INTRADAY` function #### 4. Adding `response callbacks` -To handle responses add the `onSuccess()` or `onFailure()` callbacks. +To handle responses add the `onSuccess()` or `onFailure()` async callbacks. Starting from version 1.5.0, this is an optional step. === "Java" :::java @@ -214,6 +218,28 @@ When you are okay with setting the parameters call the `fetch()` method. Simple! .onFailure({ e-> hanldeFailure(e) }) .fetch() +You can also use the sychronous fetch method by calling the `fetchSync()` method without callback handlers. + +=== "Java" + :::java + TimeSeriesResponse response = AlphaVantage.api() + .timeSeries() + .intraday() + .forSymbol("IBM") + .interval(Interval.FIVE_MIN) + .outputSize(OutputSize.FULL) + .fetch(); + +=== "Kotlin" + :::java + TimeSeriesResponse response = AlphaVantage.api() + .timeSeries() + .intraday() + .forSymbol("IBM") + .interval(Interval.FIVE_MIN) + .outputSize(OutputSize.FULL) + .fetch() + ## Releases Release history can be found in the [change log](changelog.md).