Skip to main content

Library for fetching coin/token metrics data from the internet.

Project description

https://raw.githubusercontent.com/im-n1/karpet/master/assets/logo.png PyPI PyPI - License PyPI - Downloads

Karpet

Karpet is a tiny library with just a few dependencies for fetching coins/tokens metrics data 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 metrics

  • Have a request? Open an issue ;)

Dependencies

Library 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 - google

  • for Twitter scraping - twitter

Usage

  1. Install the library via pip.

pip install karpet  # Basics only
pip install karpet[twitter]  # For Twitter scraping
pip install karpet[google]  # For Google trends
pip install karpet[twitter,google]  # All features
  1. Import the library class first.

from karpet import Karpet

get_coin_slug()

Symbol (ticker) -> coninmarketcap.com URL slug conversion.

c = Karpet()
c.get_coin_slug("BTC")  # bitcoin

fetch_historical_data()

Retrieves historical data.

c = Karpet(date(2019, 1, 1), date(2019, 5, 1))
df = c.fetch_crypto_historical_data(coin="bitcoin")  # Dataframe with historical data
df.head()
https://raw.githubusercontent.com/im-n1/karpet/master/assets/historical_data.png

fetch_exchanges()

Retrieves exchange list.

c = Karpet()
c.fetch_exchanges("nrg")
['DigiFinex', 'KuCoin', 'CryptoBridge', 'Bitbns', 'CoinExchange']

fetch_tweets()

Retrieves twitter tweets.

c = Karpet(date(2019, 1, 1), date(2019, 5, 1))
df = c.fetch_tweets(kw_list=["bitcoin"], lang="en")  # Dataframe with tweets.
df.head()
https://raw.githubusercontent.com/im-n1/karpet/master/assets/tweets.png

fetch_news()

Retrieves crypto news.

c = Karpet()
news = c.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, 10, 19, 0, 13),
   'image': 'https://images.cointelegraph.com/....jpg'  # Truncated.
}
news = c.fetch_news("btc", limit=30)  # Gets 30 news.

Changelog

0.2.4

  • fetch_news() adds new “description” item and renames “image_url” to “image”.

  • All fetch_news() item properties are now presented even if they are None.

0.2.3

  • Simplified import from from karpet.karpet import Karpet to from karpet import Karpet.

0.2.2

  • Added fetch_news() method for retrieving crypto news.

0.2.1

  • Added fetch_exchanges() method for retrieving symbol exchange list.

  • Removed obsolete library dependency.

0.2

  • Twitter scraping added.

0.1

  • Initial release.

Credits

This 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

karpet-0.2.4.1.tar.gz (7.8 kB view hashes)

Uploaded Source

Built Distribution

karpet-0.2.4.1-py3-none-any.whl (13.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page