Quick Start
Last updated
Last updated
Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.
Please fill out this form for an API key if you are new to 0x API, or get Data API enabled in your current key through the existing communication channel.
The 0x Tx History API is a GraphQL API, not a REST API. GraphQL takes a more modern approach to building APIs by using a type system and allowing for more flexible requests. See more in https://graphql.org/learn/.
The fastest way to get querying is to access Hasura's GraphQL Explorer.
In the headers section add a new header called 0x-api-key
and use your API Key as the value.
The explorer should load the available types to start building a query.
async function fetchGraphQL(operationsDoc, operationName, variables) {
const result = await fetch(
"https://api.0x.org/data/v0",
{
method: "POST",
headers: {
'0x-api-key': 'USE_APY_KEY_HERE'
},
body: JSON.stringify({
query: operationsDoc,
variables: variables,
operationName: operationName
})
}
);
return await result.json();
}
const operationsDoc = `
query Chains {
chains {
name
namespace
reference
uuid
}
}
`;
function fetchChains() {
return fetchGraphQL(
operationsDoc,
"Chains",
{}
);
}
async function startFetchChains() {
const { errors, data } = await fetchChains();
if (errors) {
// handle those errors like a pro
console.error(errors);
}
// do something great with this precious data
console.log(data);
}
startFetchChains();java
More examples can be found in each of the types in the Reference section.