Skip to content

Commit

Permalink
Merge pull request #294 from liampauling/task/docs-nemid
Browse files Browse the repository at this point in the history
NemID login example added
  • Loading branch information
liampauling committed May 8, 2020
2 parents 33450de + 2253804 commit 3b63d5c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,35 @@ Betfair uses slightly different endpoints depending on your country of residence
- sweden
- australia

### NEMID Login

Danish residents are restricted in how they login due to NemID requirements, this can be handled by replicating the login flow:

```python
import re
import betfairlightweight

trading = betfairlightweight.APIClient("username", "password", app_key="app_key")

resp = trading.session.post(
url=trading.login_interactive.url,
data={
"username": trading.username,
"password": trading.password,
"redirectMethod": "POST",
"product": trading.app_key,
"url": "https://www.betfair.com",
"submitForm": True,
}
)
session_token = re.findall(
"ssoid=(.*?);", resp.headers["Set-Cookie"]
)
trading.set_session_token(session_token[0])

print(trading.betting.list_event_types())
```

### Session

The client assumes requests is used for the http requests but other clients can be used if required, a session object can be passed to the client:
Expand Down Expand Up @@ -83,6 +112,13 @@ Elapsed, created and updated time:
2020-01-27 09:56:32.984387
```

Raw requests response object:

```python
>>> response[0]._response
<Response [200]>
```

### Lightweight

In order to return the raw json you can select lightweight on client initialization:
Expand Down

0 comments on commit 3b63d5c

Please sign in to comment.