Help for a beginner please?

Hi, I started to learn Python 6 months ago, with a goal to get on to the API with Smarkets, to allow me to develop my football skills :slight_smile:

I have now figured out how to use the requests lib in Python 3*

But I can’t figure out what the structure of the Header is to make an API call. I know I need a session token, after login. But other API formats don’t seem to work.

I would be hugely grateful for any help.

Best wishes, Stay safe,

From Scotland


Are you able to generate a session token? I’m not quite sure which part of your code is not working - do you mind copy/pasting it here?

This might be useful:

import requests 

headers = {"Content-Type": "application/json"}
data = {"username": "<username>", "password": "<password>"}                                        
response ="", headers=headers, json=data)                                    

You can then send your session token with the authentication header in all other requests:

headers = {"Authorization": f"Session-Token {response.json()['token']}"}                     
response = requests.get("", headers=headers)
response = requests.get("", headers=headers)