Stargaze
Ask or search…
K

Stargaze API

The Stargaze API provides programmatic access to Stargaze data.
Query data on collections, offers on Marketplace, NFT media info, Stargaze Names, or whatever you want. Everything that is on the website at stargaze.zone is available via this API.

GraphQL

Here is a quick and basic example which returns a subset of available data for a given collectionAddr and tokenId using the @apollo/client package.
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
const client = new ApolloClient({
uri: 'https://graphql.mainnet.stargaze-apis.com/graphql',
cache: new InMemoryCache(),
});
const getTraitsAndOwner = (collectionAddr, tokenId) =>
client.query({
query: gql`
query Query {
token(
collectionAddr: "${collectionAddr}"
tokenId: "${tokenId}"
) {
traits {
name
value
}
owner {
address
name {
name
}
}
}
}
`,
});
Notes:
  • You can use your favorite GraphQL tech and tools such as react-query if you wish
  • If you run into CORS issues you can proxy the request through your own server or a serverless solution such as CloudFlare functions (example).