Skip to content

Commit

Permalink
Merge 43d02ba into ea3e7db
Browse files Browse the repository at this point in the history
  • Loading branch information
liampauling committed Feb 2, 2019
2 parents ea3e7db + 43d02ba commit c5b94da
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ python:
- "3.4"
- "3.5"
- "3.6"
# Enable 3.7 without globally enabling sudo and dist: xenial for other build jobs
matrix:
include:
- python: "3.7"
dist: xenial

install:
- travis_retry python setup.py install
Expand Down
12 changes: 12 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
Release History
---------------

1.8.3 (2019-01-21)
+++++++++++++++++++

**Improvements**

- Cert endpoints updated.
- License update.

**Bug Fixes**

- Travis now builds py3.7!

1.8.2 (2018-11-23)
+++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018, Liam Pauling
Copyright (c) 2019, Liam Pauling

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# betfairlightweight

[![Build Status](https://travis-ci.org/liampauling/betfair.svg?branch=master)](https://travis-ci.org/liampauling/betfair) [![Coverage Status](https://coveralls.io/repos/github/liampauling/betfair/badge.svg?branch=master)](https://coveralls.io/github/liampauling/betfair?branch=master) [![PyPI version](https://badge.fury.io/py/betfairlightweight.svg)](https://pypi.python.org/pypi/betfairlightweight)
Expand All @@ -18,19 +19,22 @@ $ pip install betfairlightweight

# setup

Add your certificates to '/certs/' and app_key (optional) to environment variables with username as key before using.
In order to connect to the Betfair API you will need an App Key, SSL Certificates and a username/password.

.bash_profile
```
export username = "appkey"
```
### App Key
Follow [these](https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/Application+Keys) instructions to get your app key. You can either go for a delayed or a live key.

### SSL certificates
Follow [these](https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/Non-Interactive+%28bot%29+login) instructions to set up your SSL certificates. Save your .ctr and .key files to a local directory. The default directory where the library is looking for the keys if '/certs' but you can specify any other directory.

### Using the library

The library can then be used as follows:

```python
>>> import betfairlightweight

>>> trading = betfairlightweight.APIClient('username', 'password', app_key='app_key')
>>> trading = betfairlightweight.APIClient('username', 'password', app_key='app_key', certs='/certs')

>>> trading.login()
```
Expand Down
2 changes: 1 addition & 1 deletion betfairlightweight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from . import filters

__title__ = 'betfairlightweight'
__version__ = '1.8.2'
__version__ = '1.8.3b'
__author__ = 'Liam Pauling'

# Set default logging handler to avoid "No handler found" warnings.
Expand Down
23 changes: 11 additions & 12 deletions betfairlightweight/baseclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,30 @@ class BaseClient(object):
"""

IDENTITY_URLS = collections.defaultdict(
lambda: 'https://identitysso.betfair.com/api/',
spain='https://identitysso.betfair.es/api/',
italy='https://identitysso.betfair.it/api/',
romania='https://idenititysso.betfair.ro',
w_con='https://identitysso.w-con.betfair.com',
europe='https://identitysso.betfaironline.eu',
lambda: 'https://identitysso.betfair.com/api/',
spain='https://identitysso.betfair.es/api/',
italy='https://identitysso.betfair.it/api/',
romania='https://identitysso.betfair.ro/api/',
sweden='https://identitysso.betfair.se/api/',
australia='https://identitysso.betfair.au/api/',
)

IDENTITY_CERT_URLS = collections.defaultdict(
lambda: 'https://identitysso-cert.betfair.com/api/',
spain='https://identitysso-cert.betfair.es/api/',
italy='https://identitysso-cert.betfair.it/api/',
romania='https://identitysso-cert.betfair.ro/api/',
# w_con='https://identitysso.w-con.betfair.com',
# europe='https://identitysso.betfaironline.eu',
sweden='https://identitysso-cert.betfair.se/api/',
)

API_URLS = collections.defaultdict(
lambda: 'https://api.betfair.com/exchange/'
lambda: 'https://api.betfair.com/exchange/'
)

NAVIGATION_URLS = collections.defaultdict(
lambda: 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json',
spain='https://api.betfair.es/exchange/betting/rest/v1/en/navigation/menu.json',
italy='https://api.betfair.it/exchange/betting/rest/v1/en/navigation/menu.json'
lambda: 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json',
spain='https://api.betfair.es/exchange/betting/rest/v1/en/navigation/menu.json',
italy='https://api.betfair.it/exchange/betting/rest/v1/en/navigation/menu.json'
)

def __init__(self, username, password=None, app_key=None, certs=None, locale=None, cert_files=None,
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
setuptools==39.2.0
requests==2.20.1
requests==2.21.0
ciso8601==2.0.1
ujson==1.35
19 changes: 6 additions & 13 deletions tests/unit/test_baseclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_uri(self):

client = APIClient('bf_username', 'password', 'app_key', locale='australia')
assert client.locale == 'australia'
assert client.identity_uri == 'https://identitysso.betfair.com/api/'
assert client.identity_uri == 'https://identitysso.betfair.au/api/'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json'
assert client.identity_cert_uri == 'https://identitysso-cert.betfair.com/api/'
Expand All @@ -53,24 +53,17 @@ def test_uri(self):

client = APIClient('bf_username', 'password', 'app_key', locale='romania')
assert client.locale == 'romania'
assert client.identity_uri == 'https://idenititysso.betfair.ro'
assert client.identity_uri == 'https://identitysso.betfair.ro/api/'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json'
assert client.identity_cert_uri == 'https://identitysso-cert.betfair.ro/api/'

client = APIClient('bf_username', 'password', 'app_key', locale='w_con')
assert client.locale == 'w_con'
assert client.identity_uri == 'https://identitysso.w-con.betfair.com'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json'
# assert client.identity_cert_uri == 'https://identitysso-cert.betfair.com/api/'

client = APIClient('bf_username', 'password', 'app_key', locale='europe')
assert client.locale == 'europe'
assert client.identity_uri == 'https://identitysso.betfaironline.eu'
client = APIClient('bf_username', 'password', 'app_key', locale='sweden')
assert client.locale == 'sweden'
assert client.identity_uri == 'https://identitysso.betfair.se/api/'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json'
# assert client.identity_cert_uri == 'https://identitysso-cert.betfair.com/api/'
assert client.identity_cert_uri == 'https://identitysso-cert.betfair.se/api/'


class BaseClientTest(unittest.TestCase):
Expand Down

0 comments on commit c5b94da

Please sign in to comment.