Now that you have the basics, try a few more calls:
Get the latest stock price
Copy
import requests# authenticateheaders = {"X-API-KEY": "your_api_key_here"}# get the real-time price snapshot for NVDAurl = "https://api.financialdatasets.ai/prices/snapshot?ticker=NVDA"response = requests.get(url, headers=headers)# parse the snapshot from the responsesnapshot = response.json()["snapshot"]print(f"NVDA: ${snapshot['close']}")
Look up company info
Copy
import requests# authenticateheaders = {"X-API-KEY": "your_api_key_here"}# get company facts for Teslaurl = "https://api.financialdatasets.ai/company/facts?ticker=TSLA"response = requests.get(url, headers=headers)# parse company facts from the responsefacts = response.json()["company_facts"]print(f"{facts['name']} — {facts['sector']}, {facts['industry']}")
Check insider trades
Copy
import requests# authenticateheaders = {"X-API-KEY": "your_api_key_here"}# get the 5 most recent insider trades for Appleurl = "https://api.financialdatasets.ai/insider-trades?ticker=AAPL&limit=5"response = requests.get(url, headers=headers)# parse insider trades from the responsetrades = response.json()["insider_trades"]for t in trades: print(f"{t['name']}: {t['transaction_shares']} shares on {t['transaction_date']}")
Search for high-revenue companies
Copy
import requests# authenticateheaders = {"X-API-KEY": "your_api_key_here"}# use the screener to find companies with revenue > $50Burl = "https://api.financialdatasets.ai/financials/search/screener"body = { "filters": [ {"field": "revenue", "operator": "gt", "value": 50000000000} ], "limit": 10}response = requests.post(url, json=body, headers=headers)# parse the results from the responseresults = response.json()["results"]for r in results: print(f"{r['ticker']}: Revenue = ${r['revenue']:,.0f}")