# dexie.py
Simple dexie client


## Installation

```
pip install dexie.py
```

## Overview

Refer to the main [dexie.space API docs](https://dexie.space/api) for information on the endpoints and their parameters.

Basically you need to

1. Instantiate the client
2. Call a method on the client, that's related to it's endpoint
3. Use data that's returned by dexie

## Quick Start

```pycon
>>> import dexie

# initialize the api client
# the base_url can be either for mainnet or testnet
# use https://api.dexie.space for mainnet
# use https://api-testnet.dexie.space for testnet
>>> dc = dexie.Dexie(base_url="https://api.dexie.space")

# query for an offer file that we have the bytes of,
# by first converting it to Dexie's id format
>>> dexie.offer_file_to_dexie_id(b""" """)
'HR7aHbCXsJto7iS9uBkiiGJx6iGySxoNqUGQvrZfnj6B'
>>> dexie_offer_id = _
>>> dc.get_offer(dexie_offer_id)
{'success': True, 'offer': {'id': 'HR7aHbCXsJto7iS9uBkiiGJx6iGySxoNqUGQvrZfnj6B', 'status': 4, 'offer': ' ', 'offered_coins': ['0xac057183bb929bf7f1a585f38ecafab6f22c0339c02ba08b50ceae1ae5b95b11'], 'date_found': '2022-08-06T08:28:49.121Z', 'date_completed': '2022-08-07T13:55:19.000Z', 'date_pending': '2022-08-07T13:55:11.373Z', 'spent_block_index': 2366671, 'price': 99009.900990099, 'offered': [{'id': 'xch', 'code': 'XCH', 'name': 'Chia', 'amount': 1.01}], 'requested': [{'id': 'a628c1c2c6fcb74d53746157e438e108eab5c0bb3e5c80ff9b1910b3e4832913', 'code': 'SBX', 'name': 'Spacebucks', 'amount': 100000}], 'fees': 0, 'mempool': None, 'related_offers': [], 'coins': [{'amount': 1.5, 'puzzle_hash': '0x0150a84dd60158297ef5b8096390fc20de1239239a29acd362675abc239b92b8', 'parent_coin_info': '0xba54d2f17b1a7c31d9dab5da0b800175ad662eb352c11849c5ebb6984941bdc7', 'name': '0xac057183bb929bf7f1a585f38ecafab6f22c0339c02ba08b50ceae1ae5b95b11', 'code': 'XCH'}]}}
```
Price API also included
```pycon
# get all pairs
>>> dc.get_pairs()
# get all tickers
>>> dc.get_tickers()
{...}
# calculate the current price from ticker data
>>> ticker = dc.get_tickers("XCH_USDS)["tickers"][0]
>>> base_vol, target_vol = ticker["base_volume"], ticker["target_volume"]
>>> from decimal import Decimal
>>> Decimal(target_vol) / Decimal(base_vol)
Decimal('30.43791071338040603262456230')
```



## TODO

- [ ] Streaming API
