You’ll need an API Key + Client Name Request an API Key + API User
Make a GraphQL HTTP POST request to https://api.indexer.xyz/graphql with the following headers:
"x-api-key": YOUR_API_KEY,
"x-api-user": YOUR_API_USER
Example using axios
import axios from "axios"
const query = `
query fetchCollectionInfo($slug: String = "") {
near {
collections(where: { slug: { _eq: $slug } }) {
slug
title
cover_url
supply
verified
}
}
}
`
const vars = {
slug: "asac.near"
}
const res = await axios({
url: "<https://api.indexer.xyz/graphql>",
method: 'post',
data: {
query,
variables: vars
},
headers: {
"x-api-key": process.env.INDEXER_API_KEY,
"x-api-user": process.env.INDEXER_API_USER
}
})
Example using graphql-request
and graphql-tag
import { GraphQLClient } from "graphql-request"
import gql from "graphql-tag"
const query = gql`
query fetchCollectionInfo($slug: String = "") {
near {
collections(where: { slug: { _eq: $slug } }) {
slug
title
cover_url
supply
verified
}
}
}
`
const vars = {
slug: "asac.near"
}
const client = new GraphQLClient("<https://api.indexer.xyz/graphql>", {
headers: {
"x-api-key": YOUR_API_KEY,
"x-api-user": YOUR_API_USER
}
})
await client.request(query, vars)
These are just a few examples to get you started. Keep in mind there are many libraries and tools out for making GraphQL requests. For example you can use Apollo GraphQL, or Tanstack Query that will help manage caching for you (along with a load of other stuff)
If you need help don’t hesitate to reach out to us, we would love to help you get up and running with Indexer!
Discord: https://discord.com/invite/b8qYwxTr3K
Twitter: https://twitter.com/indexer_xyz