📊
Tx History API [Beta]
  • Introduction
  • Quick Start
  • Reference
    • API Reference
      • App
      • Chain
      • Fill
      • Liquidity Source
      • Transaction
  • Tips
Powered by GitBook
On this page
  1. Reference
  2. API Reference

App

An App is a service that provides users access to the 0x API

query Apps {
  apps(limit: 1) {
    chains
    app
  }
}
{
  "data": {
    "apps": [
      {
        "chains": [
          "Avalanche",
          "BSC",
          "Celo",
          "Ethereum",
          "Fantom",
          "Optimism",
          "Polygon"
        ],
        "app": "Brave Wallet"
      }
    ]
  }
}

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 {
    apps(limit: 1) {
      chains
      app
    }
  }
`;

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();
PreviousAPI ReferenceNextChain

Last updated 1 year ago