Exemplo n.º 1
0
class cryptonews():
    def __init__(self, key):
        self.key = key
        self.api = CryptoControlAPI(key)
        self.proxyApi = CryptoControlAPI(
            key, "http://cryptocontrol_proxy/api/v1/public")

    def enableSentiment(self):
        self.sentiment = True

    def top_news(self, lang=None):
        return self.api.getTopNews(language=lang)

    def news_by_coin(self, coin, lang=None):
        return self.api.getTopNewsByCoin(coin=coin, language=lang)

    def get_top_tweets(self, coin, lang=None):
        return self.api.getTopTweetsByCoin(coin=coin, language=lang)

    def get_reddit(self, coin, lang=None):
        return self.api.getLatestRedditPostsByCoin(coin=coin, language=lang)

    def get_top_feed(self, coin, lang):
        return self.api.getTopFeedByCoin(coin=coin, language=lang)

    def get_latest(self, coin, lang):
        return self.api.getLatestItemsByCoin(coin=coin, language=lang)

    def get_coinDetails(self, coin, lang):
        return self.api.getCoinDetails(coin=coin, language=lang)
Exemplo n.º 2
0
# Connect to a self-hosted proxy server (to improve performance) that points to cryptocontrol.io
proxyApi = CryptoControlAPI(key2, "http://cryptocontrol_proxy/api/v1/public")

# Get top news
print(pd.DataFrame(api.getTopNews()))\
# returned dataframe can be viewed fully in the csv file, same for the other dataframes
pd.DataFrame(api.getTopNews()).to_csv('section1/task3/topnews.csv', index=False)

# get latest russian news
print(pd.DataFrame(api.getLatestNews("ru")))

# # get top bitcoin news
print(pd.DataFrame(api.getTopNewsByCoin("bitcoin")))

# get top EOS tweets
print(pd.DataFrame(api.getTopTweetsByCoin("eos")))

# get top Ripple reddit posts
print(pd.DataFrame(api.getLatestRedditPostsByCoin("ripple")))

# get reddit/tweets/articles in a single combined feed for NEO
feed = pd.DataFrame(api.getTopFeedByCoin("neo"))
print(feed)

# get latest reddit/tweets/articles (seperated) for Litecoin
print(pd.DataFrame(api.getLatestItemsByCoin("litecoin")))

# get details (subreddits, twitter handles, description, links) for ethereum
links = api.getCoinDetails("ethereum")['links']
print(pd.DataFrame(links))
Exemplo n.º 3
0
df1 = pd.DataFrame(df[df['type'] == 'article'].article.tolist())
df2 = pd.DataFrame(df[df['type'] == 'reddit'].reddit.tolist())
df3 = pd.DataFrame(df[df['type'] == 'tweet'].tweet.tolist())
df1 = df1.drop([
    'similarArticles', 'coins', 'source', 'description', 'originalImageUrl',
    'url', 'thumbnail'
],
               axis=1)
df2 = df2.drop(['description', 'url'], axis=1)
df3 = df3.drop(['text', 'url'], axis=1)
df1.to_csv('neo_article_data.csv', index=False)
df2.to_csv('neo_reddit_data.csv', index=False)
df3.to_csv('neo_tweet_data.csv', index=False)

# get latest reddit/tweets/articles (seperated) for Litecoin
litecoin = api.getLatestItemsByCoin("litecoin")
df = pd.DataFrame(litecoin)
df1 = pd.DataFrame(df[df['type'] == 'article'].article.tolist())
df2 = pd.DataFrame(df[df['type'] == 'reddit'].reddit.tolist())
df3 = pd.DataFrame(df[df['type'] == 'tweet'].tweet.tolist())
df1 = df1.drop([
    'similarArticles', 'coins', 'source', 'description', 'originalImageUrl',
    'url', 'thumbnail'
],
               axis=1)
df2 = df2.drop(['description', 'url'], axis=1)
df3 = df3.drop(['text', 'url'], axis=1)
df1.to_csv('litecoin_article_data.csv', index=False)
df2.to_csv('litecoin_reddit_data.csv', index=False)
df3.to_csv('litecoin_tweet_data.csv', index=False)
# get reddit/tweets/articles in a single combined feed for NEO(sorted by time)
top_coin_feed = api.getTopFeedByCoin("bitcoin")
tcf = format_df(top_coin_feed)
save_j(top_coin_feed, 'top_coin_feed.json')
save_csv(tcf, 'top_coin_feed.csv')

# get a combined feed (reddit/tweets/articles) for a particular coin
# (sorted by relevance)
latest_coin_feed = api.getLatestFeedByCoin('bitcoin')
lcf = format_df(latest_coin_feed)
save_j(latest_coin_feed, 'latest_coin_feed.json')
save_csv(lcf, 'latest_coin_feed.csv')

# get reddit/tweets/articles (seperated) for a particular coin (sorted by time)
top_coin_items = api.getTopItemsByCoin("bitcoin")
tci = format_df(top_coin_items)
save_j(top_coin_items, 'top_coin_items.json')
save_csv(lcf, 'top_coin_items.csv')

# get latest reddit/tweets/articles (seperated) for Litecoin(sorted by
# relevance)
latest_coin_items = api.getLatestItemsByCoin("litecoin")
lci = format_df(latest_coin_items)
save_j(latest_coin_items, 'latest_coin_items.json')
save_csv(lci, 'latest_coin_items.csv')

# get details (subreddits, twitter handles, description, links) for ethereum
coin_details = api.getCoinDetails("ethereum")
save_j(coin_details, 'coin_details.json')
top_btc_news = api.getTopNewsByCoin("bitcoin")
top_btc_news_filename = f'top-btc-news.json'
save_json(top_btc_news, top_btc_news_filename, save=True)

# get top EOS tweets
eos_tweets = api.getTopTweetsByCoin("eos")
eos_tweets_filename = f'eos-tweets.json'
save_json(eos_tweets, eos_tweets_filename, save=True)

# get top Ripple reddit posts
reddit = api.getLatestRedditPostsByCoin("ripple")
reddit_filename = f'ripple-reddit.json'
save_json(reddit, reddit_filename, save=True)

# get reddit/tweets/articles in a single combined feed for NEO
neo_feed = api.getTopFeedByCoin("neo")
neo_feed_filename = 'neo-feed.json'
save_json(neo_feed, neo_feed_filename, save=True)

# get latest reddit/tweets/articles (seperated) for Litecoin
ltc_latest_feed = api.getLatestItemsByCoin("litecoin")
ltc_file = 'ltc-latest-feed.json'
save_json(ltc_latest_feed, ltc_file, save=True)

# get details (subreddits, twitter handles, description, links) for ethereum
eth_detial = api.getCoinDetails("ethereum")
eth_detial_file = 'eth-detial.json'
save_json(eth_detial, eth_detial_file, save=True)

# Enable the sentiment datapoints
# api.enableSentiment()
# Connect to the CryptoControl API
api = CryptoControlAPI("c570bf2c119d13e0cc9eb0b3d69d414d")

# Connect to a self-hosted proxy server (to improve performance) that points to cryptocontrol.io
proxyApi = CryptoControlAPI("c570bf2c119d13e0cc9eb0b3d69d414d",
                            "http://cryptocontrol_proxy/api/v1/public")

# Get top news
print(pd.DataFrame(api.getTopNews()))

# get latest russian news
print(pd.DataFrame(api.getLatestNews("ru")))

# get top bitcoin news
print(pd.DataFrame(api.getTopNewsByCoin("bitcoin")))

# get top EOS tweets
print(pd.DataFrame(api.getTopTweetsByCoin("eos")))

# get top Ripple reddit posts
print(pd.DataFrame(api.getLatestRedditPostsByCoin("ripple")))

# get reddit/tweets/articles in a single combined feed for NEO
print(api.getTopFeedByCoin("neo"))

# get latest reddit/tweets/articles (seperated) for Litecoin
print(api.getLatestItemsByCoin("litecoin"))

# get details (subreddits, twitter handles, description, links) for ethereum
print(api.getCoinDetails("ethereum"))