CNN์์ ์ฌ์ฉํ๋ ๊ณต์ ๋ฐ์ดํฐ ํธ์ถ ๋ก์ง์ ๋๋ค. ๋ธ๋ผ์ฐ์ ๋ก ์ ์์ ๋ฐ์ดํฐ ํ์ธ ๊ฐ๋ฅํ๋ฉฐ, ํฌ๋กค๋ง์ ๋ฐฉ์งํ๊ธฐ ์ํด์ 418 I'm a teapot์ ๋์ฐ๊ธฐ ๋๋ฌธ์ User-Agent๋ฅผ ์ถ๊ฐํ์ฌ ํธ์ถํ์ต๋๋ค.
const data = await fetch("https://production.dataviz.cnn.io/index/fearandgreed/graphdata",
{
headers: {
"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
}
}
)
interface FearAndGreedData {
score: number;
rating: string;
timestamp: string;
previous_close: number;
previous_1_week: number;
previous_1_month: number;
previous_1_year: number;
}
interface HistoricalData {
timestamp: number;
score: number;
rating: string;
data: {
x: number;
y: number;
rating: string;
}[];
}
interface MarketMomentumData {
timestamp: number;
score: number;
rating: string;
data: Array<Record<string, any>>;
}
interface StockPriceData {
timestamp: number;
score: number;
rating: string;
data: Array<Record<string, any>>;
}
interface PutCallOptionsData {
timestamp: number;
score: number;
rating: string;
data: Array<Record<string, any>>;
}
interface MarketVolatilityData {
timestamp: number;
score: number;
rating: string;
data: Array<Record<string, any>>;
}
interface JunkBondDemandData {
timestamp: number;
score: number;
rating: string;
data: Array<Record<string, any>>;
}
interface SafeHavenDemandData {
timestamp: number;
score: number;
rating: string;
data: Array<Record<string, any>>;
}
interface FearAndGreedIndex {
fear_and_greed: FearAndGreedData;
fear_and_greed_historical: HistoricalData;
market_momentum_sp500: MarketMomentumData;
market_momentum_sp125: MarketMomentumData;
stock_price_strength: StockPriceData;
stock_price_breadth: StockPriceData;
put_call_options: PutCallOptionsData;
market_volatility_vix: MarketVolatilityData;
market_volatility_vix_50: MarketVolatilityData;
junk_bond_demand: JunkBondDemandData;
safe_haven_demand: SafeHavenDemandData;
}
'๐ํ๋ก๊ทธ๋๋ฐ > Next.js' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์ ๋ณด] ํ๊ตญํฌ์์ฆ๊ถ API ์ฌ์ฉ ํ๊ธฐ - ์์คํ ํธ๋ ์ด๋ฉ (0) | 2024.08.17 |
---|---|
[Next.js] npm run start prisma findMany ๊ฐฑ์ ์๋ ๋ (0) | 2024.08.02 |
[Next.js] ๋ฆฌ์ํธ ํ ์ด๋ธ CSV ์ ์ฅ ๊ตฌํ(feat. Shadcn) (0) | 2024.06.21 |
[์ ๋ณด] NextAuth.js Type ์๋ฌ ์ก๊ธฐ - CredentialsProvider / prisma (0) | 2024.02.07 |
[Nextjs] api return ๊ฐ ๊ฐฑ์ ์๋๋ ์ด์ (0) | 2023.12.04 |