cryptocompsdk.news package

Submodules

cryptocompsdk.news.api module

class cryptocompsdk.news.api.NewsAPI(api_key, throttle=None)[source]

Bases: cryptocompsdk.request.APIBase

get(feeds=None, categories=None, exclude_categories=None, lang='EN', sort_order='latest', end_time=None, requests_limit=1)[source]
Return type

NewsData

cryptocompsdk.news.parse module

exception cryptocompsdk.news.parse.CouldNotGetNewsException[source]

Bases: cryptocompsdk.response.ResponseException

exception cryptocompsdk.news.parse.InvalidNewsResponseException[source]

Bases: cryptocompsdk.response.ResponseException

class cryptocompsdk.news.parse.NewsData(type, message, promoted, data, rate_limit, has_warning)[source]

Bases: cryptocompsdk.response.ResponseAPIBase

__init__(type, message, promoted, data, rate_limit, has_warning)[source]

Initialize self. See help(type(self)) for accurate signature.

data: Optional[List[cryptocompsdk.news.parse.NewsRecord]]
delete_record_matching_time(time)[source]
download_articles(out_folder='articles', num_threads=20, restart=False)[source]

Download the HTML of all news articles in this collection and save to files in a folder

Parameters
  • out_folder (Union[str, Path]) – Where to save the articles

  • num_threads (int) – How many concurrent requests to execute

  • restart (bool) – False to not download where an article already exists, True to re-download in that case

Returns

static from_dict(obj)[source]
Return type

NewsData

property has_error
Return type

bool

has_warning: Optional[bool]
property is_empty
Return type

bool

message: Optional[str]
promoted: Optional[List[Any]]
rate_limit: Optional[cryptocompsdk.news.parse.RateLimit]
property time_from
Return type

int

to_df()[source]
Return type

DataFrame

to_dict()[source]
Return type

dict

trim_empty_records_at_beginning()[source]
type: Optional[int]
class cryptocompsdk.news.parse.NewsRecord(id, guid, published_on, imageurl, title, url, source, body, tags, categories, upvotes, downvotes, lang, source_info)[source]

Bases: object

__init__(id, guid, published_on, imageurl, title, url, source, body, tags, categories, upvotes, downvotes, lang, source_info)[source]

Initialize self. See help(type(self)) for accurate signature.

body: Optional[str]
categories: Optional[str]
download_article(use_alt_url=False)[source]

Download and return the HTML of this news article

Parameters

use_alt_url (bool) – The default is to use the url given in the guid attribute, if True then use url attribute instead of guid

Return type

str

Returns

downvotes: Optional[int]
static from_dict(obj)[source]
Return type

NewsRecord

guid: Optional[str]
id: Optional[int]
imageurl: Optional[str]
property is_empty
Return type

bool

lang: Optional[str]
published_on: Optional[int]
source: Optional[str]
source_info: Optional[cryptocompsdk.news.parse.SourceInfo]
tags: Optional[str]
title: Optional[str]
to_dict()[source]
Return type

dict

upvotes: Optional[int]
url: Optional[str]
exception cryptocompsdk.news.parse.NoValidNewsURLException[source]

Bases: Exception

class cryptocompsdk.news.parse.RateLimit[source]

Bases: object

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

static from_dict(obj)[source]
Return type

RateLimit

to_dict()[source]
Return type

dict

class cryptocompsdk.news.parse.SourceInfo(name, lang, img)[source]

Bases: object

__init__(name, lang, img)[source]

Initialize self. See help(type(self)) for accurate signature.

static from_dict(obj)[source]
Return type

SourceInfo

img: Optional[str]
lang: Optional[str]
name: Optional[str]
to_dict()[source]
Return type

dict

cryptocompsdk.news.parse.news_from_dict(s)[source]
Return type

NewsData

cryptocompsdk.news.parse.news_to_dict(x)[source]
Return type

Any