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

Description

Karpet 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 metrics

  • Have a request? Open an issue ;)

Usage

  1. Install the library via pip.

pip install karpet

In case you don’t use uv you need to install the newerest cloudscraper manually

pip install git+https://github.com/VeNoMouS/cloudscraper.git@3.0.0
  1. Import the library class first.

from karpet import Karpet

fetch_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()

                 price   market_cap total_volume
2019-01-01  131.458725  1.36773e+10  1.36773e+10
2019-01-02  138.144802  1.43923e+10  1.43923e+10
2019-01-03  152.860453  1.59222e+10  1.59222e+10
2019-01-04  146.730599  1.52777e+10  1.52777e+10
2019-01-05  153.056567  1.59408e+10  1.59408e+10

fetch_crypto_exchanges()

Retrieves exchange list (based on coingecko.com tickers, first 100 tickers only, so it covers the major exchanges). Accepts a symbol or a coingecko slug.

k = Karpet()
k.fetch_crypto_exchanges("nrg")
['LBank', 'MEXC', 'Indodax', 'CoinEx', 'Uniswap V4 (Ethereum)']

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 editors

  • Hot stories - articles with most views

k = Karpet()
editors_choices, top_stories = k.fetch_top_news()
print(len(editors_choices))
5
print(len(top_stories))
5
print(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 as id param for method fetch_crypto_historical_data().

k = Karpet()
print(k.get_coin_ids("sta"))
['statera']

get_basic_info()

Fetches coin/token basic data (price, market cap, rank and yearly stats). Accepts a symbol or a coingecko slug.

k = Karpet()
print(k.get_basic_info(slug="ethereum"))
{
    'current_price': 3167.67,
    'market_cap': 371964284548,
    'name': 'Ethereum',
    'rank': 2,
    '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()

                        open     high      low    close
2023-01-16 20:00:00  1593.01  1595.05  1593.01  1594.28
2023-01-16 20:30:00  1593.37  1593.37  1589.03  1589.35
2023-01-16 21:00:00  1592.68  1593.66  1584.71  1587.87
2023-01-16 21:30:00  1587.28  1587.28  1583.13  1583.13
2023-01-16 22:00:00  1573.99  1580.11  1573.99  1579.97

Changelog

here

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.

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.6.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

karpet-0.6.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file karpet-0.6.1.tar.gz.

File metadata

  • Download URL: karpet-0.6.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":null,"id":"forky","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for karpet-0.6.1.tar.gz
Algorithm Hash digest
SHA256 94d78e41602b24d65f91022e6da70f4bcd1f0a1e9fecfc71558cbc5c802f1962
MD5 a179893607571ba1c38bed07ef82f885
BLAKE2b-256 3b01b738f317ee41ca70a109766436e4f740cf4d43c5dd8b90c9394366045ec5

See more details on using hashes here.

File details

Details for the file karpet-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: karpet-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":null,"id":"forky","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for karpet-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 964338d898859eb42f639f860d6e2dfbec450ab3c4e5caeb96436327cfe24590
MD5 c15ce339c03f6a942339c73cf279fc40
BLAKE2b-256 393954f9e428c9cfd66d817be7554bb14f6d6a04fa50eaf4d0451b670b67f5e5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 files

0.6

2 files

0.5.6

2 files

0.5.5

1 file

0.5.4

2 files

0.5.3.post1

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5

2 files

0.4.14

2 files

0.4.13

2 files

0.4.12

2 files

0.4.11

2 files

0.4.10

2 files

0.4.9

2 files

0.4.8

2 files

0.4.7

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3

2 files

0.2.5.1

2 files

0.2.5

2 files

0.2.4.1

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2.1

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page