Package: karpet
ContentsKarpetDependenciesUsagefetch_crypto_historical_data()fetch_crypto_exchanges()fetch_google_trends()fetch_news()fetch_top_news()get_coin_ids()get_basic_data()get_quick_search_data()fetch_crypto_live_data()ChangelogCreditsKarpetKarpet is a tiny library with just a few dependencies
for fetching coins/tokens metrics data from the internet.It can provide following data:coin/token historical price data (no limits)google trends for the given list of keywords (longer period than official API)twitter scraping for the given keywords (no limits)much more info about crypto coins/tokens (no rate limits)What is upcoming?Reddit metricsHave a request? Open an issue ;)DependenciesLibrary uses a few nifty dependencies and is Python 3.6+ only. There is no
need to install dependencies you don’t need. Therefore this library utilizes
extras which install optional dependencies:for Google trends - googleUsageInstall the library via pip.pipinstallkarpet# Basics onlypipinstallkarpet[google]# With Google trendsImport the library class first.fromkarpetimportKarpetfetch_crypto_historical_data()Retrieves historical data.k=Karpet(date(2019,1,1),date(2019,5,1))df=k.fetch_crypto_historical_data(id="ethereum")# Dataframe with historical data.df.head()pricemarket_captotal_volume2019-01-01131.4587251.36773e+101.36773e+102019-01-02138.1448021.43923e+101.43923e+102019-01-03152.8604531.59222e+101.59222e+102019-01-04146.7305991.52777e+101.52777e+102019-01-05153.0565671.59408e+101.59408e+10fetch_crypto_exchanges()Retrieves exchange list.k=Karpet()k.fetch_crypto_exchanges("nrg")['DigiFinex','KuCoin','CryptoBridge','Bitbns','CoinExchange']fetch_google_trends()Retrieves Google Trends - in percents for the given date range.k=Karpet(date(2019,1,1),date(2019,5,1))df=k.fetch_google_trends(kw_list=["bitcoin"])# Dataframe with trends.df.head()And with a few lines of code you can get a chartdf=df.set_index("date")df.plot()fetch_news()Retrieves crypto news.k=Karpet()news=k.fetch_news("btc")# Gets 10 news.print(news[0]){'url':'https://cointelegraph.com/ ....',# Truncated.'title':'Shell Invests in Blockchain-Based Energy Startup','description':'The world’s fifth top oil and gas firm, Shell, has...',# Truncated.'date':datetime.datetime(2019,7,28,9,24,tzinfo=datetime.timezone(datetime.timedelta(seconds=3600)))'image':'https://images.cointelegraph.com/....jpg'# Truncated.}news=k.fetch_news("btc",limit=30)# Gets 30 news.fetch_top_news()Retrieves top crypto news in 2 categories:Editor’s choices - articles picked by editorsHot stories - articles with most viewsk=Karpet()editors_choices,top_stories=k.fetch_top_news()print(len(editors_choices))5print(len(top_stories))5print(editors_choices[0]){'url':'https://cointelegraph.com/...',# Truncated.'title':'Bank of China’s New Infographic Shows Why Bitcoin Price Is Going Up','date':datetime.datetime(2019,7,27,10,7,tzinfo=datetime.timezone(datetime.timedelta(seconds=3600))),'image':'https://images.cointelegraph.com/images/740_aHR...',# Truncated.'description':'The Chinese central bank released on its website an ...'# Truncated.}print(top_stories[0]){'url':'https://cointelegraph.com/...',# Truncated.'title':'Bitcoin Price Shuns Volatility as Analysts Warn of Potential Drop to $7,000','date':datetime.datetime(2019,7,27,10,7,tzinfo=datetime.timezone(datetime.timedelta(seconds=3600))),'image':'https://images.cointelegraph.com/images/740_aHR0c...'# Truncated.'description':'Stability around $10,600 for Bitcoin price is ...'# Truncated.}get_coin_ids()Resolves coin ID’s based on the given symbol (there are coins out there with identical symbol).Use this to get distinctive coin ID which can be used asidparam for
methodfetch_crypto_historical_data().k=Karpet()print(k.get_coin_ids("sta"))['statera']get_basic_data()Fetches coin/token basic data like:open_issuesis only provided iftotal_issuesandclosed_issuesare
available.k=Karpet()print(k.get_basic_data(id="ethereum")){'closed_issues':5530,'commit_count_4_weeks':40,'current_price':3167.67,'forks':11635,'market_cap':371964284548,'name':'Ethereum','open_issues':230,'pull_request_contributors':552,'rank':2,'reddit_accounts_active_48h':2881.0,'reddit_average_comments_48h':417.083,'reddit_average_posts_48h':417.083,'reddit_subscribers':1057875,'stars':31680,'total_issues':5760,'year_high':4182.790285752286,'year_low':321.0774351739628,'yoy_change':695.9225871929757,# growth/drop in percents'price_change_24':120.1,'price_change_24_percents':1.23}get_quick_search_data()Lists all coins/tokes with some basic info.k=Karpet()print(k.get_quick_search_data()[0]){"name":"Bitcoin","symbol":"BTC","rank":1,"slug":"bitcoin","tokens":["Bitcoin","bitcoin","BTC"],"id":1,}fetch_crypto_live_data()Retrieves live market data.k=Karpet()df=k.fetch_crypto_live_data(id="ethereum")# Dataframe with live data.df.head()openhighlowclose2023-01-1620:00:001593.011595.051593.011594.282023-01-1620:30:001593.371593.371589.031589.352023-01-1621:00:001592.681593.661584.711587.872023-01-1621:30:001587.281587.281583.131583.132023-01-1622:00:001573.991580.111573.991579.97Changelog[here](./CHANGELOG.md)CreditsThis is my personal library I use in my long-term project. I can pretty much guarantee it will
live for a long time then. I will add new features over time and I more than welcome any
help or bug reports. Feel free to open an issue or merge request.The code is is licensed under MIT license.