Session token

Hi,

I’m using Python to access the API, I’m not sure if this has already been asked anywhere and I don’t think I can see it anywhere in the documentation (please correct me if I’m wrong) .

Wondering how I would pass my session token for subsequent requests after I’ve logged in.

i.e.
from requests import get

header = {‘Content-Type’:‘application/json’, ‘session-token’:session_token}

resp = get(smarkets_events, data=filter, headers=header)

Would this work (given everything else is correct)?

Thanks,

Michael

Hi Michael,

Please, find below an example in Python:

import requests 

headers = {"Content-Type": "application/json"}
data = {"username": "<username>", "password": "<password>"}                                        
response = requests.post("https://api.smarkets.com/v3/sessions/", headers=headers, data=data)                                    

headers = {"Authorization": f"Session-Token {response.json()['token']}"}                     
response = requests.get("https://api.smarkets.com/v3/accounts/", headers=headers)    

Kind regards,
Isabel