1

I am trying to access a dataset from python available here

enter image description here

In the API documentation, there is no information on how to sign in using username and password via script. Upon manually entering the API URL into a browser

https://ev.caltech.edu/api/v1/sessions/caltech/ts

I have to manually enter the username: DEMO_TOKEN and password: <blank> and click on sign in to get the JSON response from the server. enter image description here

How do I programmatically do that in python?

Below is my snippet which doesn't work

import requests
api_url = "https://ev.caltech.edu/api/v1/sessions/caltech/ts"
response = requests.get(api_url)

response.json()

1 Answer 1

1

Works for me, when I do this:

import requests
user = "DEMO_TOKEN"
passwd = ""
api_url = "https://ev.caltech.edu/api/v1/sessions/caltech/ts"
response = requests.get(api_url, auth=(user,passwd))
if response.status_code == 200:
    print(response.json())

Please be warned, the json is HUGE.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.