Skip to main content

A wrapper for the Con Market Cap API

Project description

Introduction

python Coin Market Cap

CMC_API is a Python-client for the Coin Market Cap API.

This client provides support for the basic or free tier at the moment. However, it is open for extension to anyone who has access to paid packages.

It provides access to all the available endpoint on the API and produce a result similar to the original API with some minor difference. The most relevant difference is the addition of a list of keys available in each answer, as shown in the bellow example.

{
      "metadata": {
            "timestamp": "2022-06-04T04:26:55.117Z",
            "credit_count": 0,
            "error_message": null,
            "list_keys": [
                  "plan",
                  "usage"
            ]
      },
...

Index


About

The CoinMarketCap API is an API provided by the company with the same name. This API provides cryptocurrency data such as price, volume, market cap, and exchange data.

This project is a wrapper around this API that facilitates its usage for python projects.

Why use the Client:

  1. It will reduce the coding time since the code for request and parsing of the data is already done, and the user only needs to call a function.
  2. It provides the option to save the response data to save in credit calls for data that is not updated constantly.
  3. It provides metadata information in the response. This metadata contains the "cost" per request in credits and a list of the keys in the data part of the response so users can retrieve information with ease.

Usage

  1. Decided with URL you will use:
    1. BASE:base is the real API and provide the real data. cmc_helper.Urls.BASE.value
    2. SANDBOX: sandbox is for testing, and returns dummy data. cmc_helper.Urls.SANDBOX.value
  2. Create an Object of class Cmc(), passing the URL to be use cmc = Cmc(url=cmc_helper.Urls.BASE.value)
  3. use the object of type Cmc() to call a function. cmc.get_cmc_id_map()
from cmc_api import cmc, cmc_helper

base_url = cmc_helper.Urls.BASE.value
cmc = cmc.Cmc(url=base_url, api_key="YOU_LICENSE_KEY", save_to_json=True)
cmc.get_cmc_id_map(listing_status="active", start=1, limit=1000)

The response will be similar to:

{
  "metadata": {
    "timestamp": "2022-06-04T13:14:05.108Z",
    "credit_count": 1,
    "error_message": null,
    "list_keys": [
      "id",
      "name",
      "symbol",
      "slug",
      "rank",
      "is_active",
      "first_historical_data",
      "last_historical_data",
      "platform"
    ]
  },
  "data": [
    {
      "id": 1,
      "name": "Bitcoin",
      "symbol": "BTC",
      "slug": "bitcoin",
      "rank": 1,
      "is_active": 1,
      "first_historical_data": "2013-04-28T18:47:21.000Z",
      "last_historical_data": "2022-06-04T13:09:00.000Z",
      "platform": null
    },
    ...
  ]
}

Development

Still working in this part but any contribution or suggestion is more than welcome

Pre-Requisites

  • python=>3.10
  • request

File Structure

This is the structure of this repository not of a project using this python-client.

.
├── coinmarketcapAPI
│   ├── json_files
│   │   ├── API_info.json
│   │   └── ...
│   └── src
│       ├── cmc_api
│       │   ├── cmc.py              # definition of the wrapper and function available
│       │   └── cmc_dataHandler.py  # Helper to parse the information on the API response
│       │   └── cmc_helper.py       # Emuns that hold the endpoinrs URI and args need it
│       │   └── cmc_utils.py        # Extra utility functions.
│       └── logs
│           └── *.logs
│           └── ....
├── LICENSE
├── MANIFEST.in
├── pyproject.toml
├── setup.cfg
└── README.md

Community

As mentioned before the contribution guidelines are not done yet, but any report or suggestion will be appreciated

Contribution

Your contributions are always welcome and appreciated. Following are the things you can do to contribute to this project.

  • Report a bug
    If you think you have encountered a bug, and I should know about it, feel free to report it here, and I will take care of it.

Branches

  1. master is the main development branch.

  2. main is the production branch.

  3. Development is the experimental development branch.

Resources

If you want more information about the Coin market cap API you can visit their side coinmarketcapAPI

License

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

cmc_api_wrapper-0.1.18.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

cmc_api_wrapper-0.1.18-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file cmc_api_wrapper-0.1.18.tar.gz.

File metadata

  • Download URL: cmc_api_wrapper-0.1.18.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for cmc_api_wrapper-0.1.18.tar.gz
Algorithm Hash digest
SHA256 a45550b0f91bd5bd2d8ac9e7d6e7bbf9f55abc3112a5ec3e3964726aab878691
MD5 9059d4a832a44d3be7f565567375851b
BLAKE2b-256 566b7db08a5c043dcbb90bebeb72c50d659bcb518e650a354c689f526f4e262f

See more details on using hashes here.

File details

Details for the file cmc_api_wrapper-0.1.18-py3-none-any.whl.

File metadata

File hashes

Hashes for cmc_api_wrapper-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 76c8650e05d4bf2c17fa6b1bcf873e9acd7ff2789a3483395a89b97c6106ffc0
MD5 8d30da3cf499cbdab9888b5c2c5ec087
BLAKE2b-256 5495befa2f3e158a5e5bd65d7b7c86c8e428ca1f99890697035b4e1ce9e37566

See more details on using hashes here.

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