# Quick Start

## Get your API key

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](https://www.0x.org/#contact) 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 <https://graphql.org/learn/>.

{% hint style="info" %}
GraphQL Endpoint:

<https://api.0x.org/data/v0>
{% endhint %}

## Playground Access

The fastest way to get querying is to access [Hasura's GraphQL Explorer](https://cloud.hasura.io/public/graphiql?endpoint=https%3A%2F%2Fapi.0x.org%2Fdata%2Fv0).

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.

<figure><img src="https://2884585771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqNWXbqX023Z6VibdVgud%2Fuploads%2FWgZ1jYmcek3iykDdSgaA%2Fimage.png?alt=media&#x26;token=1b8ae0ec-60e4-4ece-a03e-8dd3f420b46f" alt=""><figcaption><p>Adding API Key</p></figcaption></figure>

## Programmatic Access

{% tabs %}
{% tab title="Node" %}

```javascript
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
```

{% endtab %}

{% tab title="Python" %}
Install dependencies

```shell
pip install gql
```

Save the following as `get_chains.py`

```python
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

```shell
python get_chains.py
```

{% endtab %}
{% endtabs %}

More examples can be found in each of the types in the Reference section.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://0x-docs.gitbook.io/data-api/GO2tLD8DYyx4JW6MuM7l/quick-start.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
