This is a REST API for SQL operations. The SQL API enables flexible SQL interaction with the SxT Data Warehouse. Using this API, you can run SQL against:
- Your own tables in Space and Time, containing off-chain data that you've ingested
- Tables containing relational, realtime blockchain data that we've indexed from major chains
Before calling the SQL Operations REST APIs, make sure you've authenticated to Space and Time.
API Requirements
Security requirements:
accessToken
provided in Authorization header (as bearer token) must matchaccessToken
received from in the Authentication Token API in the API authentication workflow- Biscuit token must provided in the
biscuit
header (for details about biscuits, see here).
Other requirements:
resourceId
must be the full qualification of the resource.
Example:
For the following query:
SELECT * FROM ETH.TRANSACTIONS LIMIT 1000;
resourceId
is ETH.TRANSACTIONS
.
DQL Endpoint: Query Data
Execute SELECT
commands with the DQL Endpoint.
Example command:
SELECT EXCHANGE_NAME, COUNT(*)
FROM ETH.DEX_TRADE
GROUP BY EXCHANGE_NAME
ORDER BY 2 DESC
DDL Endpoint: Configure Resources
Execute CREATE
, ALTER
, and DROP
commands with the DDL Endpoint.
Example commands:
CREATE TABLE My_User_Wallets (
User_Wallet_Address VARCHAR PRIMARY KEY,
User_Subscription VARCHAR
) WITH "publicKey=4c4d31237894198ab4174f8b49f9e9dc370737bcc4e741897ba56e86ffb5fa2f,accessType=public_write"
ALTER TABLE My_User_Wallets
ADD Created_TS timestamp;
DROP TABLE My_User_Wallets;
DML Endpoint: Modify Data
Execute insert, update, or delete commands with the DML Endpoint.
Example commands:
INSERT INTO My_User_Wallets (User_Wallet_Address, User_Subscription)
VALUES ('0x456008396BFdd64159998cE362b8D650FFd6F28b', 'premium')
UPDATE My_User_Wallets
SET User_Subscription = 'premium'
WHERE User_Wallet_Address = '0x456008396BFdd64159998cE362b8D650FFd6F28b'
DELETE FROM My_User_Wallets WHERE User_Subscription = 'expired'