Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
JS to Python conversion question (REST API related)

Javascript from docs

const body = {
    name:       "<replace with your credentials>",
    password:   "<replace with your credentials>",
    appId:      "Sample App",
    appVersion: "1.0",
    cid:        8,
    sec:        "f03741b6-f634-48d6-9308-c8fb871150c2",
    deviceId:   "123e4567-e89b-12d3-a456-426614174000"
}

const response = await fetch('https://live.tradovateapi.com/v1/auth/accesstokenrequest', {
    method: 'POST',
    mode: 'cors',
    headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
    },
    body: JSON.stringify(body)
})

Sorry for the crudeness of this question. I understand Javascript like i understand Sumerian. What would the python equivalent of this be?

My attempt (in python):

@bot.command(pass_context=True)
async def tradoMarket(symbol, side):
    url = 'https://demo.tradovateapi.com/order/placeorder'
    #url = 'https://live.tradovateapi.com/order/placeorder'

    headers = {
        "Content-Type": 'application/json',
        "Accept": 'application/json'
    }
    data = {
        "name":       'xxxxxx',
        "password":   'xxxxxx',
        "appId":      'xxxxxx',
        "appVersion": '1.0',
        "cid":        xxxxxx,
        "sec":        'xxxxxx-xxxxxx-xxxxxx'
    }
    data_json = json.dumps(data)
    response = requests.post('https://demo.tradovateapi.com/v1/auth/accessTokenRequest', headers=headers, data=data_json)
    print(response.json())

I do get a response from their API. It was essentially wrong UN/PW, but Im 100% sending the correct information which is telling me my formatting is wrong.

Their docs for reference

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!