create account

Pymarketcap - Coinmarketcap Python API and web parser by mondeja

View this thread on: hive.blogpeakd.comecency.com
· @mondeja · (edited)
$0.03
Pymarketcap - Coinmarketcap Python API and web parser
## <center>[Download from here](https://github.com/mondeja/pymarketcap)</center>

https://s29.postimg.org/qo08bvkjb/coinmarketcap_markets.jpg

<center>[PyPi Version](https://pypi.python.org/pypi/pymarketcap/)</center>

**Pymarketcap** is an APACHE licensed library for retrieve information from [coinmarketcap](http://coinmarketcap.com/) API and web. Consist of a parser built on BeautifulSoup and a API wrapper. 
It works for Python 2 and 3.

 If you only want the API wrapper, go to [here](https://github.com/mondeja/coinmarketcap-api).

## Installation:

You need to install BeautifulSoup before:

    $ pip install bs4

From source use:

    $ python setup.py install

or install from PyPi

    $ pip install pymarketcap

## Documentation:

### API methods

- **`GET /v1/ticker/`**
- **`GET /v1/ticker/currency`**

```python
>>> from pymarketcap import *       # Only contains the class Pymarketcap
>>> coinmarketcap = Pymarketcap()
>>> coinmarketcap.ticker(<currency>)
# <currency> can be passed through 'ethereum' or 'ETH' and returns in json

>>> coinmarketcap.ticker('ETH')
>>> coinmarketcap.ticker('ethereum')

# Add VERBOSE=True or V=True for a string response, like this:
>>> coinmarketcap.ticker('STEEM', V=True)

# This is for receive all the currencies in a string
>>> coinmarketcap.ticker(VERBOSE=True)
[
  {
    id: "bitcoin",
    name: "Bitcoin",
    symbol: "BTC",
    rank: 1,
    price_usd: 448.66,
    24h_volume_usd: 84396000,
    market_cap_usd: 6946212888,
    available_supply: 15482200,
    total_supply: 15482200,
    percent_change_1h: 0.47,
    percent_change_24h: -1.61,
    percent_change_7d: 1.25
  },
  {
    id: "ethereum",
    name: "Ethereum",
    symbol: "ETH",
    rank: 2,
    price_usd: 7.28,
    24h_volume_usd: 13419600,
    market_cap_usd: 578917949,
    available_supply: 79512085,
    total_supply: 79512085,
    percent_change_1h: 0.21,
    percent_change_24h: -6.51,
    percent_change_7d: -14.64
  },

  ...
]		
```
<center></center>
- **`GET /v1/global/`**

```python
>>> coinmarketcap.stats(VERBOSE=True)
{
  total_market_cap_usd: 8280726727,
  total_24h_volume_usd: 108644044,
  bitcoin_percentage_of_market_cap: 81.77,
  active_currencies: 690,
  active_assets: 57,
  active_markets: 1902
}		
```


### Web Parser methods

#### [Currency markets](http://coinmarketcap.com/currencies/<currency>/#markets)

- **`GET http://coinmarketcap.com/currencies/<currency>/#markets`**


```python
>>> coinmarketcap.markets('ETH', V=True)
[
  {
    "pair": "ETH/BTC", 
    "source": "Poloniex", 
    "percent_volume": 29.72, 
    "price_usd": 49.07, 
    "24h_volume_usd": 35779900
  }, 
  {
    "pair": "ETH/USD", 
    "source": "GDAX", 
    "percent_volume": 8.22, 
    "price_usd": 49.99, 
    "24h_volume_usd": 9897980
  }, 
  {
    "pair": "ETH/USD", 
    "source": "Bitfinex", 
    "percent_volume": 7.98, 
    "price_usd": 49.45, 
    "24h_volume_usd": 9606490
  }, 

 ...
]
```


#### [Global ranks](http://www.coinmarketcap.com/gainers-losers/)

- **`GET http://www.coinmarketcap.com/gainers-losers/`**

```python
>>> coinmarketcap.ranks(V=True)
{
  "losers": {
    "1h": [
      {
        "24h_volume_usd": 15219, 
        "symbol": "XEN", 
        "price_usd": 0.327427, 
        "percent_change": -24.28, 
        "name": "Xenixcoin"
      }, 
      {
        "24h_volume_usd": 818024, 
        "symbol": "PINK", 
        "price_usd": 0.002168, 
        "percent_change": -18.3, 
        "name": "PinkCoin"
      },
      ...

# You can pass '7d', '24h', '1h', 'gainers' and 'losers' for filter responses:
coinmarketcap.ranks('gainers', '1h', V=True)
{
  "1h": [
    {
      "24h_volume_usd": 62719, 
      "symbol": "NOBL", 
      "price_usd": 0.00024, 
      "percent_change": 18.99, 
      "name": "NobleCoin"
    }, 
    {
      "24h_volume_usd": 22355, 
      "symbol": "RDD", 
      "price_usd": 5.5e-05, 
      "percent_change": 17.72, 
      "name": "ReddCoin"
    }, 
    {
      "24h_volume_usd": 12723, 
      "symbol": "BOLI", 
      "price_usd": 0.003156, 
      "percent_change": 15.83, 
      "name": "Bolivarcoin"
    }, 
...
```
👍  , , , , , , , , , , , , , , , ,
properties (23)
authormondeja
permlinkpymarketcap-coinmarketcap-python-api-and-web-parser
categorycryptocurrency
json_metadata{"tags":["cryptocurrency","programming","howto","coinmarketcap","api"],"links":["https://github.com/mondeja/pymarketcap","https://pypi.python.org/pypi/pymarketcap/","http://coinmarketcap.com/","https://github.com/mondeja/coinmarketcap-api","http://coinmarketcap.com/currencies/<currency>/#markets","http://www.coinmarketcap.com/gainers-losers/"],"app":"steemit/0.1","format":"markdown","image":["https://s29.postimg.org/qo08bvkjb/coinmarketcap_markets.jpg"]}
created2017-04-01 12:07:00
last_update2017-04-01 13:28:45
depth0
children3
last_payout2017-04-08 12:07:00
cashout_time1969-12-31 23:59:59
total_payout_value0.030 HBD
curator_payout_value0.005 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,096
author_reputation9,894,814,339,118
root_title"Pymarketcap - Coinmarketcap Python API and web parser"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,915,775
net_rshares996,958,273,550
author_curate_reward""
vote details (17)
@aguazul ·
pip install bs4 
Worked fine.

pip install pymarketcap
Error = " Could not find a version that satisfies the requirement pymarketcap (from versions: )
No matching distribution found for pymarketcap".

I use Python 3.5.2
properties (22)
authoraguazul
permlinkre-mondeja-pymarketcap-coinmarketcap-python-api-and-web-parser-20170611t042335429z
categorycryptocurrency
json_metadata{"tags":["cryptocurrency"],"app":"steemit/0.1"}
created2017-06-11 04:23:33
last_update2017-06-11 04:23:33
depth1
children1
last_payout2017-06-18 04:23:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length219
author_reputation44,356,920,781
root_title"Pymarketcap - Coinmarketcap Python API and web parser"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id4,571,591
net_rshares0
@mondeja · (edited)
If you use Linux:
git clone https://github.com/mondeja/pymarketcap.git
cd pymarketcap
python3 setup.py install

In windows, you can download it in [github](https://github.com/mondeja/pymarketcap) and instal from source.
👍  
properties (23)
authormondeja
permlinkre-aguazul-re-mondeja-pymarketcap-coinmarketcap-python-api-and-web-parser-20170612t141926340z
categorycryptocurrency
json_metadata{"tags":["cryptocurrency"],"links":["https://github.com/mondeja/pymarketcap.git","https://github.com/mondeja/pymarketcap"],"app":"steemit/0.1"}
created2017-06-12 14:19:36
last_update2017-06-12 14:20:48
depth2
children0
last_payout2017-06-19 14:19:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length219
author_reputation9,894,814,339,118
root_title"Pymarketcap - Coinmarketcap Python API and web parser"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id4,660,175
net_rshares155,335,000
author_curate_reward""
vote details (1)
@selfmadeinvestor ·
great project! that's exactly the thing i'm working on, but i wanted to write the infos gathered from the api to a csv or excel file sorted by columns (fields = id, name ect...) with the data under, do you know how to do so?
properties (22)
authorselfmadeinvestor
permlinkre-mondeja-pymarketcap-coinmarketcap-python-api-and-web-parser-20180315t152119817z
categorycryptocurrency
json_metadata{"tags":["cryptocurrency"],"app":"steemit/0.1"}
created2018-03-15 15:21:48
last_update2018-03-15 15:21:48
depth1
children0
last_payout2018-03-22 15:21:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length224
author_reputation9,540,267,776
root_title"Pymarketcap - Coinmarketcap Python API and web parser"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id44,615,284
net_rshares0