Query all our underlying data using SQL syntax.
Method: POST
Endpoint: https://api.syve.ai/v1/sql
Requests to our SQL endpoint require using the POST
method. To run a query: Enter the SQL as a string in the query
field of the JSON body of the request.
curl -X POST \
https://api.syve.ai/v1/sql \
-H 'Content-Type: application/json' \
-d '{
"query": "<sql_query_string_goes_here>"
}'
A simple example of using the SQL API is given below. For more (advanced) examples also look here.
Restrictions
In optimizing for speed we have a few restrictions in place on the SQL that can be run. The main restrictions are:
- No Join operations.
INNER JOIN
,OUTER JOIN
,LEFT JOIN
,RIGHT JOIN
are not permitted. If you need to join two tables you can run two separate queries instead.- No sub-queries. You cannot use the result of one query as a table in another.
Example: Latest DEX trades
Query
curl -X POST \
https://api.syve.ai/v1/sql \
-H 'Content-Type: application/json' \
-d '{
"query": "SELECT * FROM eth_dex_trades ORDER BY timestamp DESC LIMIT 5"
}'
Response
[
{
"timestamp": "2023-07-31T13:42:47.000Z",
"amount_eth": 0.25,
"amount_token": 6180.536498001015,
"amount_usd": 467.5827704348493,
"block_hash": null,
"block_number": 17813362,
"num_trades_1h": 80,
"num_trades_24h": 3086,
"pool_address": "0xed06839ed05219b87cbd39dd8f9495e02497bc10",
"price_token_usd_tick_1": 0.07565407478559193,
"price_token_usd_tick_100": 0.07565407478559193,
"price_token_usd_wavg_1h": 0.07883530857920834,
"price_token_usd_wavg_24h": 0.07639071551042267,
"protocol_name": "uniswap_v2",
"record_index": 7125344800000377,
"side": "buy",
"token_address": "0xcb50350ab555ed5d56265e096288536e8cac41eb",
"transaction_hash": "0x28e3297b63908a3abee1b4dd85a5e0e822ad7693db70b6195b9ed479ed046857",
"volume_1h_usd": 80282.94123498432,
"volume_24h_usd": 3629782.089002692
},
{
"timestamp": "2023-07-31T13:42:47.000Z",
"amount_eth": 0.075,
"amount_token": 8895903.71,
"amount_usd": 140.27483113045477,
"block_hash": null,
"block_number": 17813362,
"num_trades_1h": 1,
"num_trades_24h": 10,
"pool_address": "0x65b9ad105b95290bcde1ed91f2f6688232ad5782",
"price_token_usd_tick_1": 1.5768474536518423e-05,
"price_token_usd_tick_100": 1.5768474536518423e-05,
"price_token_usd_wavg_1h": null,
"price_token_usd_wavg_24h": null,
"protocol_name": "uniswap_v2",
"record_index": 7125344800000363,
"side": "buy",
"token_address": "0x83249c6794bca5a77eb8c0af9f1a86e055459cea",
"transaction_hash": "0xc7a0fed4d22efae67efdeb2c8c8c7b866a671870fdece847ccd0aa0eb07ba15e",
"volume_1h_usd": 140.27483113045346,
"volume_24h_usd": 3364.659423064507
},
{
"timestamp": "2023-07-31T13:42:47.000Z",
"amount_eth": 0.2723975935604604,
"amount_token": 222845174388.49847,
"amount_usd": 509.47368582714455,
"block_hash": null,
"block_number": 17813362,
"num_trades_1h": 102,
"num_trades_24h": 2446,
"pool_address": "0x41f50f520f5095fc8403df083285232b822611c3",
"price_token_usd_tick_1": 2.28622265312755e-09,
"price_token_usd_tick_100": 2.28622265312755e-09,
"price_token_usd_wavg_1h": 1.8314835514839511e-09,
"price_token_usd_wavg_24h": 1.3302379962169194e-09,
"protocol_name": "uniswap_v2",
"record_index": 7125344800000352,
"side": "sell",
"token_address": "0x3d806324b6df5af3c1a81acba14a8a62fe6d643f",
"transaction_hash": "0x02fe0c9558174d85bc6172e4a6053c626712874cc225a2dd0454a26345903d04",
"volume_1h_usd": 120685.34255576947,
"volume_24h_usd": 2326269.0249887905
},
{
"timestamp": "2023-07-31T13:42:47.000Z",
"amount_eth": 0.45,
"amount_token": 285118929592.8197,
"amount_usd": 841.6489867827288,
"block_hash": null,
"block_number": 17813362,
"num_trades_1h": 1,
"num_trades_24h": 23,
"pool_address": "0x7bdb64fb70adb01c7bbfed98e4def7df70c8318b",
"price_token_usd_tick_1": 2.9519225117206123e-09,
"price_token_usd_tick_100": 2.9519225117206123e-09,
"price_token_usd_wavg_1h": null,
"price_token_usd_wavg_24h": 3.1386439318993094e-09,
"protocol_name": "uniswap_v2",
"record_index": 7125344800000347,
"side": "buy",
"token_address": "0x9778ac3d5a2f916aa9abf1eb85c207d990ca2655",
"transaction_hash": "0x1f8f1cfdc0c4545d8531bbfd13ee91d565cc7a1f9c9df5e55b1f8fe42fb3ea29",
"volume_1h_usd": 841.648986782734,
"volume_24h_usd": 16300.351867262541
},
{
"timestamp": "2023-07-31T13:42:47.000Z",
"amount_eth": 0.13,
"amount_token": 323245.8511365566,
"amount_usd": 243.14304062612163,
"block_hash": null,
"block_number": 17813362,
"num_trades_1h": 49,
"num_trades_24h": 1075,
"pool_address": "0xc37f45b35aa582e1eac16d4af3cf9e5ba77bc2be",
"price_token_usd_tick_1": 0.0007521923012196831,
"price_token_usd_tick_100": 0.0007521923012196831,
"price_token_usd_wavg_1h": 0.0006721756730572669,
"price_token_usd_wavg_24h": 0.00038270958421279697,
"protocol_name": "uniswap_v2",
"record_index": 7125344800000338,
"side": "buy",
"token_address": "0xe2f72c3fa7b02bbeeb7f528013e2c2ac2580c588",
"transaction_hash": "0xc95d4f0123f70729fa4e41bf679ed988c0f78c2ed145975702b1834bd3101bc3",
"volume_1h_usd": 18850.831852910404,
"volume_24h_usd": 737381.0128165156
}
]