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 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.
A note on GraphQL
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 .
GraphQL Endpoint:
Playground Access
The fastest way to get querying is to access .
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.
Programmatic Access
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
Install dependencies
pip install gql
Save the following as get_chains.py
from gql import Client, gql
from gql.transport.aiohttp import AIOHTTPTransport
# Select your transport with a defined url endpoint
transport = AIOHTTPTransport(
url="https://api.0x.org/data/v0",
headers={"0x-api-key": "YOUR API KEY GOES HERE"},
)
# Create a GraphQL client using the defined transport
client = Client(transport=transport, fetch_schema_from_transport=True)
# Provide a GraphQL query
query = gql(
"""
query getChains {
chains {
name
namespace
reference
}
}
"""
)
# Execute the query on the transport
result = client.execute(query)
print(result)
Run with
python get_chains.py
More examples can be found in each of the types in the Reference section.