Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26
  1. #21

    AW: Re: Battlefield 1 API


    I tried the Postman as a last resort and it worked. Thank you!
    Only issue is, that I don't know how can I get the X-Gatewaysession automatically.
    Do you have any advice for that?

    Thank you

  2. #22

    Re: Battlefield 1 API

    you only need to request Gatewaysession one time. e.g. via browser

  3. #23

    AW: Battlefield 1 API


    I finally got this working with Python! Thanks to sbauer318 JS and H3iMDAII87 curl command.

    Here is the complete script I used:

    import requests
    import json

    s = requests.Session()
    personaid = personal id from companion site in url
    rnd_id = 'c63929d3-3501-4113-a9d9-4bd416d4bedc' (random id)

    init_url = ''
    companion_url = ''
    ea_token = ' cleus:rest'
    auth_code = ''

    email = your_email
    password = your_password

    init = s.get(init_url)

    login_payload = {
    '_eventId': 'submit',
    'password': password,
    'email': email

    ea_login =, data=login_payload)
    ea_code = (json.loads((s.get(ea_token)).text))['code']

    session_data = {"jsonrpc":"2.0",
    "params":{"code": ea_code,"redirectUri":"nucleus:rest"},

    session_id = (json.loads((, data=json.dumps(session_data))).text))['result']['id']

    headers = {
    'Content-Type': 'application/json',
    'Accept': '*/*',
    'X-GatewaySession': session_id
    data = {"jsonrpc":"2.0","method":"Stats.getCareerForOwned GamesByPersonaId","params":{"personaId"ersonaid},"id":rnd_id}

    companion_data =, headers=headers, data=json.dumps(data))



  4. #24

    Re: AW: Battlefield 1 API

    Quote Originally Posted by theManag3R View Post

    I finally got this working with Python! Thanks to sbauer318 JS and H3iMDAII87 curl command.
    Awesome! Thanks a million for sharing

    I just finished creating a script for node.js!

    Also, I still used some of the python script you shared, however I made some revisions based on best practices via pylint.

    Here is a python script for just getting the paramater needed for X-GatewaySession:

    """Get Auth Token for battlefield1 companion"""
    import json
    import sys
    import uuid
    # Non standard libraries
    import requests
    SESSION = requests.Session()
    INIT_URL = ''
    EA_AUTH_URL = (''
    API_CODE_URL = ''
    AUTH_EMAIL = str(sys.argv[1])
    AUTH_PASSWORD = str(sys.argv[2])
        '_eventId': 'submit',
        'password': AUTH_PASSWORD,
        'email': AUTH_EMAIL
    EA_AUTH_CODE = json.loads(SESSION.get(EA_AUTH_URL).text)['code']
        "jsonrpc": "2.0",
        "method": "Companion.loginFromAuthCode",
                "code": EA_AUTH_CODE,
        "id": str(uuid.uuid4)
    SESSION_ID = json.loads(
    print SESSION_ID
    You can see the code as written here:

  5. #25

    Re: Battlefield 1 API

    For those interested, I've finished up a stats library that proxies to battlefieldtracker - You can see it here:

    You can also use an express middleware if you want to serve up your own JSON api in a flash, you can see that here:

    Now if you want to use the companion API directly, I've got one working too, but it doesn't have as many features and I don't recommend it, however you can find it here:

    I'm super excited and spent alot of work on these, so I hope some of you find it useful

  6. #26

    Re: Battlefield 1 API

    How are you able to determine the personaId for someone else based on their platform's id. For example if I had a friend on xbox with the username = "player123", is there an api call like getPersonaIdByUsername("player123") ?

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts