Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Switch to default SSL context
Browse files Browse the repository at this point in the history
  • Loading branch information
nardew committed Feb 20, 2020
1 parent 896de8f commit e3994f9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html

## [Pending release]

## [2.0.0] - 2020-02-20

### Changed

- Server hostname and certificate verification enabled (thanks @pyranja)

## [1.1.0] - 2020-02-12

### Added
Expand Down Expand Up @@ -42,7 +48,8 @@ The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html

- __Important!!!__ REST response body is not returned as a string anymore but as a dictionary instead. If you did `json.loads(response['response'])` before, now use only `response['response']`.

[Pending release]: https://github.com/nardew/bitpanda-aio/compare/1.1.0...HEAD
[Pending release]: https://github.com/nardew/bitpanda-aio/compare/2.0.0...HEAD
[2.0.0]: https://github.com/nardew/bitpanda-aio/compare/1.1.0...2.0.0
[1.1.0]: https://github.com/nardew/bitpanda-aio/compare/1.0.2...1.1.0
[1.0.2]: https://github.com/nardew/bitpanda-aio/compare/1.0.1...1.0.2
[1.0.1]: https://github.com/nardew/bitpanda-aio/compare/1.0.0...1.0.1
Expand Down
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,12 @@ pip install bitpanda-aio

Due to dependencies and Python features used by the library please make sure you use Python `3.6` or `3.7`.

Before starting using `bitpanda-aio`, it is necessary to take care of:
1. downloading your Bitpanda API key from your Bitpanda Global Exchange account
1. generating your certificate that will be used to secure SSL connections. Certificate `certificate.pem` can be generated easily by
```bash
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out certificate.pem
```
Before starting using `bitpanda-aio`, it is necessary to take care of downloading your Bitpanda API key from your Bitpanda Global Exchange account

### Examples
#### REST API
```python
import asyncio
import pathlib
import logging
import datetime

Expand All @@ -48,10 +42,9 @@ logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())

async def run():
certificate_path = pathlib.Path(__file__).with_name("certificate.pem")
api_key = "<YOUR_API_KEY>"

client = BitpandaClient(certificate_path, api_key)
client = BitpandaClient(api_key)

print("Account balance:")
await client.get_account_balances()
Expand Down Expand Up @@ -119,7 +112,6 @@ if __name__ == "__main__":
#### WEBSOCKETS
```python
import asyncio
import pathlib
import logging

from bitpanda.BitpandaClient import BitpandaClient
Expand All @@ -136,10 +128,9 @@ async def order_book_update(response : dict) -> None:
print(f"Callback {order_book_update.__name__}: [{response}]")

async def run():
certificate_path = pathlib.Path(__file__).with_name("certificate.pem")
api_key = "<YOUR_API_KEY>"

client = BitpandaClient(certificate_path, api_key)
client = BitpandaClient(api_key)

# Bundle several subscriptions into a single websocket
client.compose_subscriptions([
Expand Down
2 changes: 1 addition & 1 deletion bitpanda/BitpandaClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, api_key : str = None, api_trace_log : bool = False, ssl_conte
if ssl_context is not None:
self.ssl_context = ssl_context
else:
self.context = ssl.create_default_context()
self.ssl_context = ssl.create_default_context()

self.subscription_sets = []

Expand Down
4 changes: 2 additions & 2 deletions client-example/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
print(f"Available loggers: {[name for name in logging.root.manager.loggerDict]}\n")

async def order_book_update(response : dict) -> None:
print(f"Callback {order_book_update.__name__}: [{response}]")
print(f"Callback order_book_update: [{response}]")

async def run():
print("STARTING BITPANDA CLIENT\n")

# to retrieve your API key go to your bitpanda global exchange account and store it in BITPANDA_API_KEY environment
# to retrieve your API key go to your bitpanda global exchange account and store it in BITPANDAAPIKEY environment
# variable
api_key = os.environ['BITPANDAAPIKEY']

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setuptools.setup(
name="bitpanda-aio",
version="1.1.0",
version="2.0.0",
author="nardew",
author_email="[email protected]",
description="Bitpanda Global Exchange API asynchronous python client",
Expand Down

0 comments on commit e3994f9

Please sign in to comment.