0

NASDAQ API is not working in python. I don't get any error but it just stuck in process.

import requests
import json
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

url = 'https://api.nasdaq.com/api/ipo/calendar?date=2020-11'
response = requests.get(url, verify=False)
result = json.loads(response.text)
companies = result['data']['priced']['rows']

for company in companies:
    ticker = company['proposedTickerSymbol']
    print(ticker)

Thanks for reading!!

yf879
  • 168
  • 1
  • 7

1 Answers1

0

This is a website that has a check for user agent. you need to add user agent here as header to get the data:

import requests
import json
url = 'https://api.nasdaq.com/api/ipo/calendar?date=2020-11'
headers={
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36"
}
r = requests.get(url, headers=headers)
result=r.json()
companies = result['data']['priced']['rows']

for company in companies:
    ticker = company['proposedTickerSymbol']
    print(ticker)

Reference: Python requests GET takes a long time to respond to some requests

Yash
  • 1,271
  • 1
  • 7
  • 9
  • Thanks, It worked! I did encounter this header issue in few other sites too but in those sites I was getting error of connection refused and I solved it using headers, But I was getting nothing here so I ruled out this header issue out. Guess I should have tried with header. Lesson learned. – yf879 Nov 20 '20 at 17:26