Closed xgshark closed 5 years ago
have you got access to the api from matchbook? are you using you actual username and pw when creating the api instance? after the code above you may need to do api.login() in order to access any açcount specific information.
Yeah I emailed matchbook support asking if I need special authorization before asking here. The reference and market data endpoints work without any user name and password - which I didn't know.
I've been trying loads of workarounds but don't get anything to work using the wrapper. api.session_token is None after making an instance so I assume login() needs to be called. I do however get an error when doing that.
user = "X" password = "X"
api = APIClient(user, password) api.login()
File ....py", line 22, in
This piece of code works so it shouldn't have anything to do with my account or credentials:
import json import requests
url = "https://www.matchbook.com/bpapi/rest/security/session" user = "X" password = "X"
payload = "{\n \"username\":\"" + user + "\",\n \"password\":\"" + password + "\"\n}" headers = {'content-type': "application/json"}
response = requests.request("POST", url, data=payload, headers=headers) json_data = json.loads(response.text) session_token = json_data["session-token"]
url = "https://api.matchbook.com/edge/rest/account"
payload = {} headers = {'content-type': "application/json", 'session-token': session_token}
response = requests.request("GET", url, data=payload, headers=headers)
print("Account", response.text)
Thanks again for any help.
I got a chance to try this on my laptop now. I get the following status 500 response from the login endpoint:
'{"errors":[{"messages":["Unexpected server error accessing /bpapi/rest/security/session."]}]}'
I'm not sure what is causing this but have emailed to see if its on their side that the issue is occuring.
Will let you know when they get back to me.
Hi,
So it looks like it was just an issue with not having www. in the base url for login. I have fixed this and pushed version 0.0.5 to pypi so if you pip install -U matchbook to get this version it should be working now.
Let me know if this works for you and I will close the issue
Fixed it, thanks!
"api.market_data" and "api.reference_data" work fine like this.
I get "matchbook.exceptions.ApiError: ['You are not authorised to access this resource. Login to continue.']" for these endpoints: reporting, account, betting.
Why is that?