forked from vaibhav45sktech/crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.js
More file actions
26 lines (21 loc) · 869 Bytes
/
api.js
File metadata and controls
26 lines (21 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import axios from 'axios'
const api = axios.create({
baseURL: '/api',
timeout: 8000
})
export async function getCryptoPrices(ids, vsCurrency = 'usd') {
const { data } = await api.get('/crypto/prices', { params: { ids, vs_currency: vsCurrency } })
return data
}
export async function getCryptoMarketChart(id, vsCurrency = 'usd', days = 1) {
const { data } = await api.get('/crypto/market_chart', { params: { id, vs_currency: vsCurrency, days } })
return data
}
export async function getStockIntraday(symbol, interval = '5min') {
const { data } = await api.get('/stock/intraday', { params: { symbol, interval } })
return data
}
export async function getRedditSentiment(keywords = 'anxiety,stress,happy', limit = 50) {
const { data } = await api.get('/sentiment/reddit', { params: { q: keywords, limit } })
return data
}