Get market beta snapshot
curl --request GET \
--url https://api.financialdatasets.ai/prices/beta \
--header 'X-API-KEY: <api-key>'import requests
url = "https://api.financialdatasets.ai/prices/beta"
headers = {"X-API-KEY": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-KEY': '<api-key>'}};
fetch('https://api.financialdatasets.ai/prices/beta', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.financialdatasets.ai/prices/beta",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.financialdatasets.ai/prices/beta"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-KEY", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.financialdatasets.ai/prices/beta")
.header("X-API-KEY", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.financialdatasets.ai/prices/beta")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-KEY"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"beta": {
"value": 123,
"ticker": "<string>",
"benchmark": "<string>",
"requested_lookback": "<string>",
"interval": "<string>",
"start_date": "2023-12-25",
"end_date": "2023-12-25",
"n_observations": 123,
"r_squared": 123,
"method": "<string>",
"price_type": "<string>",
"reason": "<string>"
}
}{
"error": "Bad Request",
"message": "Invalid request parameters"
}{
"error": "Unauthorized",
"message": "Invalid API key provided"
}{
"error": "Payment Required",
"message": "This endpoint requires a paid subscription. Please upgrade your plan."
}{
"error": "Not Found",
"message": "Ticker XXXX not found"
}Stock Prices
Stock Beta API
The market beta of a US stock against SPY, from 5 years of monthly returns, for 15,000+ tickers, updated daily.
GET
/
prices
/
beta
Get market beta snapshot
curl --request GET \
--url https://api.financialdatasets.ai/prices/beta \
--header 'X-API-KEY: <api-key>'import requests
url = "https://api.financialdatasets.ai/prices/beta"
headers = {"X-API-KEY": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-KEY': '<api-key>'}};
fetch('https://api.financialdatasets.ai/prices/beta', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.financialdatasets.ai/prices/beta",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.financialdatasets.ai/prices/beta"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-KEY", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.financialdatasets.ai/prices/beta")
.header("X-API-KEY", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.financialdatasets.ai/prices/beta")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-KEY"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"beta": {
"value": 123,
"ticker": "<string>",
"benchmark": "<string>",
"requested_lookback": "<string>",
"interval": "<string>",
"start_date": "2023-12-25",
"end_date": "2023-12-25",
"n_observations": 123,
"r_squared": 123,
"method": "<string>",
"price_type": "<string>",
"reason": "<string>"
}
}{
"error": "Bad Request",
"message": "Invalid request parameters"
}{
"error": "Unauthorized",
"message": "Invalid API key provided"
}{
"error": "Payment Required",
"message": "This endpoint requires a paid subscription. Please upgrade your plan."
}{
"error": "Not Found",
"message": "Ticker XXXX not found"
}Overview
The Beta API returns the market beta of a stock: how much the stock moved for each move of the market. Each beta uses the same method:- Benchmark:
SPY(S&P 500) - Lookback:
5y(the last 5 years) - Interval:
month(returns from one month end to the next) - Price type:
adjusted_close - Method:
ols(the slope of the stock’s returns against the benchmark’s returns)
value is null and reason says why.
To get started, please create an account and grab your API key at financialdatasets.ai.
You will use the API key to authenticate your API requests.
Coverage
| Tickers | Years of Coverage | Updated |
|---|---|---|
| 15,000+ | Latest | Daily |
Available Tickers
You can fetch a list of available tickers with aGET request to:
https://api.financialdatasets.ai/prices/tickers/
Getting Started
There are only 3 steps for making a successful API call:- Add your API key to the header of the request as
X-API-KEY. - Add query params like
tickerto filter the data. - Execute the API request.
ticker.
Example
Beta
import requests
# add your API key to the headers
headers = {
"X-API-KEY": "your_api_key_here"
}
# set your query params
ticker = 'AAPL'
# create the URL
url = (
f'https://api.financialdatasets.ai/prices/beta'
f'?ticker={ticker}'
)
# make API request
response = requests.get(url, headers=headers)
# parse beta from the response
beta = response.json().get('beta')
Example Response
{
"beta": {
"value": 1.18,
"ticker": "AAPL",
"benchmark": "SPY",
"requested_lookback": "5y",
"interval": "month",
"start_date": "2021-02-26",
"end_date": "2026-01-30",
"n_observations": 59,
"r_squared": 0.62,
"method": "ols",
"price_type": "adjusted_close"
}
}
Response Fields
value: the beta, ornullwhen there are too few months of prices.start_dateandend_date: the first and the last month end used.n_observations: the number of months used.r_squared: how closely the stock follows the benchmark, from 0 to 1.reason: only whenvalueisnull. One ofinsufficient_observations,no_overlapping_observationsorzero_benchmark_variance.