Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to pass basic auth to python Pandas get json data (pd.read_json)

Tags:

pandas

I am trying to read JSON data from the web, which requires authentication, is that possible to pass authentication details to pd.read_json or I must use requests for this?

df = pd.read_json("https://myurl.com/data.json", lines=False, auth=('username', 'password'))

like image 526
Jijo John Avatar asked Feb 20 '26 19:02

Jijo John


1 Answers

import requests    

r = requests.get('https://intranet.jsondata.com/xy.json', auth=('user', 'pass'))
json_content = r.json()

will get you the json

pd.read_json(json_content)

will read it.

like image 108
Paul Brennan Avatar answered Feb 23 '26 16:02

Paul Brennan