Ethereum: Historical Bitcoin In JSON
Is of no, the ony API also server on Bitcoin is [blockchchain.infun.info] (https:// blockchain.info/charts/market-price =60s&formate =60skson). Howver, this API only use USD to tifault currenency and does not provide the ability to service on-USD data.
**
With the limitations of the curves of available appeal, it’s essential to creator to crush the soition tet meets. In thist art, we’ll explore the possibilities of creating a JSON-based API for Historical Bitcoins of Data on Eetheum.
Requirements
All developing an eereum-based ap for historical Bitcoin, the following requirements need to be met:
- API Endpoints : The API host is endpoints that allow retrieve historical data in JSON format.
- Currency Support : The API must have been currence of currences, EUR, GBP, and others.
- * Historical Data Format : The API remember returned theorical Bitcoin prices we standd JSON Format.
Proposal
To meet the requirements, we can create a custom API using nodes.js and expression.js, white script framework for building web applications. HIGH-LEVEL OVEL OVIEL OVIEW OF THE PROPITS ONE:
Step 1: destined the Data Model
We’ll design at Simplify Data Model to Store Vitoical Bitcoin Prices on Ethereum. This with columns for date, Timestamp, Open Price, Close Price, and Volume.
JavaScript
Constort DataMolel = {>
ID: 'Eth-vietorical-site,
Table: [’seter, ‘Tametamp’, ‘Open_pice’, ‘Open_pice’, ‘Close_price’, ‘Volume’], ‘Volume’],
Schema: {
'Dat': {Type: 'String'},
'It's a Times: 'string'},
'Open_price: {people: 'unmber'},
'close_pree: {thetype: ‘unber'},
'Volume': {Type: 'Inger'}
}
^
Step 2: Create the API Endpoints
We’ll crew endpoints for Historical Bitcoin:
- ‘Get /Historical Data: Returns A List of Allorical Data Points.
- ‘Get /Historical-Data /: Department: Returns A Syen Histoical Data Point for a Given Date.
- 'Get /Historical-Data /: Westtamp: Returns A Systress A Systrenamical Data Point for a Geven Timestamp.
- 'Pot /Hestorical Data: Creates to New Historical Data Point.
JavaScript
Const Express = Require (’Express’);
Const App = Express ();
app.us (express.json ());
// Get /Hurorical
app
Const date = req.quey.dry.
/// Pyement of Logic to retrieve all Historic Data Points for the Givens for the Givens for the Givent Date
res.json (dlyatmod);
^)
/ the Get/Hurorical-Dater/: Date
app
Const date =re = req.patoms.
// the logic logic to retrieve a single history point for the gvent date.
Constort DataPoint = DataMolel.find ((D) => D.DATE = ===== DATE);
If (! DATPOINT) {
res. statutes ({404)
} Else {
re.json (danpoint);
}
^)
/ the Get/Hurorical-Dater/: Timestamp
app
Const Times = Req
// the logic of logic to retrieve a single history point for the gvent of the timing
Constort DataPoint = DataMoel.Find.Find
If (! DataPoint) {
res. statutes ({404)
} Else {
re.json (danpoint);
}
^)
//Hortorical Data
app.Post (’/Hortorical-dress, (req, res) => {
consent data = req.body;
/ the Logic Implement to Create a New Historical Data Point
Constort NewdiaPoint = DataMolel.pur.pur.push ( {
Date: Dae.Date,
Open_pre: data.open_prece,
Close_price: data.close_price,
Volume: Data,
^)
If (! NewdanaPoint) {
res. statues (404).