Base URL
Endpoints
1. Logging In (***Required First Step ***)
Description: login and retrieve JWT token
a. Request
Headers: Content-Type: application/json
Body:
username (string): The username of the user.
password (string): The password of the user.
b. Responce
Copy { "access_token": "<access_token>", "refresh_token": "<refresh_token>" }
c. Example
Copy fetch('https://max1-funding-arb.uc.r.appspot.com/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: 'admin',
password: 'admin'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
2. Get Raw Data Table (requires JWT token)
Endpoint: /raw_data_table
Description: Retrieves all records from the raw_data_table.
a. Request
b. Response
Body: JSON array of objects containing the raw data records.
c. Example
Copy fetch('https://max1-funding-arb.uc.r.appspot.com/raw_data_table', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
d. Response Example
Copy [
{"funding_id":1,"fundingrate":"-0.00021167","fundingtime":1713456000000,"markprice":"63515.40000000","symbol":"BTCUSD_PERP","time":"Thu, 27 Jun 2024 08:03:24 GMT"},
{"funding_id":2,"fundingrate":"-0.00029339","fundingtime":1713484800000,"markprice":"63477.88531564","symbol":"BTCUSD_PERP","time":"Thu, 27 Jun 2024 08:03:24 GMT"},
…
]
3.1 Get Portfolio Track Records (requires JWT token)
Endpoint: /portfolio_track_records
Description: Retrieves all records from the portfolio_track_records table.
a. Request
- page (optional): The page number to retrieve. Defaults to all records if not provided.
- limit (optional): The number of records per page. Defaults to all records if not provided.
b. Response
Body: JSON array of objects containing the portfolio track records.
c. Example
Copy fetch('https://max1-funding-arb.uc.r.appspot.com/portfolio_track_records?page=1&limit=60, {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
d. Response Example
Copy {[
{"id":1,"money_at_risk_percent":"-0.7635539234855009","net_exposure_value":"-0.7577440087800085","portfolio_implied_30days_earnings":"0.8605773848134116","portfolio_implied_apr":"0.10406109150689863","timestamp":"Fri, 28 Jun 2024 04:20:33 GMT","total_assets_value":"99.23909569098001"},
{"id":2,"money_at_risk_percent":"-0.7301864268488106","net_exposure_value":"-0.7248933446900026","portfolio_implied_30days_earnings":"0.8606027411036695","portfolio_implied_apr":"0.10402641079258573","timestamp":"Fri, 28 Jun 2024 07:05:01 GMT","total_assets_value":"99.27510537526001"},
…..
],
"total_records": 120,
"page": 1,
"limit": 60
}
3.2 Get Latest Portfolio Data food a time range (requires JWT token)
Endpoint: /track_records_daily_latest
Description: retrieves the latest records for each day up to 1:00 UTC within a specified date range. If no date range is provided, it fetches the latest records up to 1:00 UTC for all available days.
a. Request
- start_date (optional, string, format: YYYY-MM-DD
- The start date of the range from which to fetch records.
- end_date (optional, string, format: YYYY-MM-DD)
- The end date of the range up to which to fetch records.
b. Response
Body: JSON array of objects containing the track of records data.
c. Example
Copy fetch('https://max1-funding-arb.uc.r.appspot.com/track_records_daily_latest?start_date=2024-08-03&end_date=2024-09-02', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// Some code
4. Get Portfolio Latest Data (requires JWT token)
Endpoint: /portfolio_latest
Description: Retrieves all records from the portfolio_latest table.
a. Request
b. Response
Body: JSON array of objects containing the latest portfolio data.
c. Example
Copy fetch('https://max1-funding-arb.uc.r.appspot.com/portfolio_latest', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
d. Response Example
Copy [
{"amount":"6.8792","assets_types":"Crypto","assets_value":"62.2633","implied_apr":"0.0","mark_price":"9.051","order_value_required":"0.0","portfolio_allocation":"0.6271","product_category":"Coin-M Futures","symbol":"UNI","target_allocation_percent":"0.0","utc_timestamp":"Tue, 02 Jul 2024 08:20:19 GMT"},
{"amount":"0.2512","assets_types":"Crypto","assets_value":"37.0242","implied_apr":"0.0","mark_price":"147.389","order_value_required":"0.0","portfolio_allocation":"0.3729","product_category":"Coin-M Futures","symbol":"SOL","target_allocation_percent":"0.0","utc_timestamp":"Tue, 02 Jul 2024 08:20:19 GMT"},
…
]
5. Get Monitor APR Attribute Data (requires JWT token)
Endpoint: /monitor_apr_attribute
Description: Retrieves all records from the monitor_apr_attribute table.
a. Request
b. Response
Body: JSON array of objects containing the monitor APR attribute data.
c. Example
Copy fetch('https://max1-funding-arb.uc.r.appspot.com/monitor_apr_attribute', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
d. Response Example
Copy [
{"30_day_cum_funding":"0.09370907999999999","3_day_cum_funding":"0.1376676","7_day_cum_funding":"0.07607777142857143","allocation_percentage":"0.4","apr_id":1,"apr_score":"0.1449632622857143","next_funding_rate":"0.2306664","previous_funding_rate":"0.14273280000000002","simulator_id":null,"symbol":"BNBUSD_PERP","time":"Thu, 27 Jun 2024 08:00:00 GMT"},
{"30_day_cum_funding":"0.12468504000000001","3_day_cum_funding":"0.13084440000000003","7_day_cum_funding":"0.09699222857142857","allocation_percentage":"0.35","apr_id":2,"apr_score":"0.11432026971428573","next_funding_rate":"0.10800000000000001","previous_funding_rate":"0.10800000000000001","simulator_id":null,"symbol":"RUNEUSD_PERP","time":"Thu, 27 Jun 2024 08:00:00 GMT"},
…..
]
6. Refresh Token
Description: This endpoint allows a user to refresh their access token using a valid refresh token.
a. Request
Headers
Authorization: Bearer <refresh_token>
Content-Type: application/json
b. Response
Body: {"access_token": "<new_access_token>"}
7. Trigger Cloud Function DataSync
Description: Triggers the dataSync function to fetch data and store into database
a. Request
b. Response
8. Trigger Cloud Run Monitor
Description: Triggers the monitor instance to fetch data and store into database
a. Request
b. Response
9. Trigger Cloud Run Portfolio
Description: Triggers the portfolio instance to fetch data and store into database
a. Request
b. Response