https://github.com/devansh3712/cmc-py
Unofficial CoinMarketCap API and Python wrapper
https://github.com/devansh3712/cmc-py
fastapi python redis selenium
Last synced: about 1 year ago
JSON representation
Unofficial CoinMarketCap API and Python wrapper
- Host: GitHub
- URL: https://github.com/devansh3712/cmc-py
- Owner: Devansh3712
- License: mit
- Created: 2022-02-14T06:48:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-15T12:18:06.000Z (over 4 years ago)
- Last Synced: 2025-03-20T18:07:07.602Z (over 1 year ago)
- Topics: fastapi, python, redis, selenium
- Language: Python
- Homepage: https://devansh3712.github.io/cmc-py/
- Size: 828 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmc-py
Unofficial [CoinMarketCap](https://coinmarketcap.com/) API and Python wrapper. `cmc-py` uses `Selenium` and `BeautifulSoup` to scrape the website and return desired data.
[](https://github.com/Devansh3712/cmc-py/actions/workflows/test.yml) [](https://github.com/Devansh3712/cmc-py/actions/workflows/codecov-coverage.yml) [](https://github.com/Devansh3712/cmc-py/actions/workflows/python-publish.yml) [](https://github.com/Devansh3712/cmc-py/actions/workflows/docker-image.yml) [](https://github.com/Devansh3712/cmc-py/actions/workflows/docker-publish.yml) [](https://github.com/psf/black) [](https://codecov.io/gh/Devansh3712/cmc-py)
### Installation
- Using `setup.py`
```shell
python setup.py install
```
- Using `Python Package Index`
```shell
pip install cmc-py-wrapper
```
- Using `poetry`
```
poetry install
```
### Wrapper
`cmc-py` library can be used to fetch data for the following:
- `CryptoCurrencies`
```python
from cmc import Trending, format_data
top_30_trending = Trending().get_data
print(format_data(top_30_trending))
```
- `Exchanges`
```python
from cmc import Spot, format_data
spot_exchanges = Spot().get_data
print(format_data(spot_exchanges))
```
- `Non Fungible Tokens (NFTs)`
```python
from cmc import UpcomingSale, format_data
upcoming_nft_sales = UpcomingSale(pages=[1, 2]).get_data
print(format_data(upcoming_nft_sales))
```
### API
An API is also built using the `cmc-py` modules using `FastAPI` and `Redis`. Redis configurations can be set using the `config.yml` file, and it is used to cache the scraped data fetched through `cmc-py`. `Redis` server should be running in the background in order to cache API calls. An instance of the API is hosted on [Heroku](https://cmc-api.herokuapp.com/docs#/).
- Running the API locally
```shell
uvicorn api.main:app
```
- Building the API using `Dockerfile`
```shell
docker build -t cmc .
docker compose up -d
```
- Running the API using [`Docker Image`](https://hub.docker.com/r/devansh3712/cmc-api)
```shell
docker pull devansh3712/cmc-api
docker run devansh3712/cmc-api
```