diff options
author | Antony Kellermann | 2018-01-31 15:57:42 -0500 |
---|---|---|
committer | Antony Kellermann | 2018-01-31 15:57:42 -0500 |
commit | ae4dc32ef58d61a76a9591b47e0a4fe721d78fd7 (patch) | |
tree | cf2d7df6906b1d39853816d3152021e09eaaa740 /api.h | |
parent | 3fd8913733bbb57c38683fdb80aaf12d4719a734 (diff) | |
download | aur-ae4dc32ef58d61a76a9591b47e0a4fe721d78fd7.tar.gz |
Added support for news
Diffstat (limited to 'api.h')
-rw-r--r-- | api.h | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -1,8 +1,9 @@ /** - * API data is taken from IEX Trading, Alpha Vantage, and Coinmarketcap. + * API data is taken from IEX Trading, Alpha Vantage, Coinmarketcap, and News API. * https://iextrading.com/developer/docs/ * https://www.alphavantage.co/documentation/ * https://coinmarketcap.com/api/ + * https://newsapi.org/docs */ #ifndef IEX_H @@ -13,6 +14,7 @@ #include <string.h> #include <curl/curl.h> #include <stddef.h> +#include <json-c/json_tokener.h> struct string { char* data; @@ -21,6 +23,8 @@ struct string { typedef struct string String; +typedef struct json_object Json; + /** * Creates and returns a STRING * object with size 1 and no data @@ -31,9 +35,10 @@ String* api_string_init(void); /** * GETs data from API server and returns it in a String * @param url API url to GET + * @param post_field data needed for POST * @return NULL if no response from server. Otherwise, String containing data. */ -String* api_curl_data(char* url); +String* api_curl_data(char* url, char* post_field); /** * Returns current price of a stock or cryptocurrency. @@ -112,6 +117,25 @@ double alphavantage_get_1d_price(char* ticker_name_string); double coinmarketcap_get_1d_price(char* ticker_name_string); /** + * Prints top three news articles in the past week based on the given string + * @param ticker_name_string the string + */ +void news_print_top_three(char* ticker_name_string); + +/** + * Given a JSON formatted string, print title, source, author, and url of articles + * @param data the json formatted data + */ +void json_print_news(char* data); + +/** + * Given a url, returns a shorter link using goo.gl + * @param url_string the link to shorten + * @return the shortened link + */ +const char* google_shorten_link(char* url_string); + +/** * Destroys String object and frees memory * @param phString the String to destroy */ |