Query From a Client

There are several ways to query our GraphQL API :

GraphQL Client

You can use any GraphQL client. Here is an example with Apollo Client:

import { ApolloClient, InMemoryCache, gql } from '@apollo/client';

const client = new ApolloClient({
  uri: 'https://api.sismo.io',
  cache: new InMemoryCache(),
});
const query = gql`
query {
  mintedBadges {
    balance
    tokenId
    badge {
      name
    }
  }
}`
const result = await client.query({ query });
POST Request
const query = `
query {
  mintedBadges {
    level
    badge {
      tokenId
    }
    badge {
      name
    }
  }
}`

const res = await fetch('https://api.sismo.io', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
  },
  body: JSON.stringify({ query})
});
const { data, errors } = await res.json();

cURL
curl -g \
-X POST https://api.sismo.io/ \
-H "Content-Type: application/json" \
--data-binary @- << EOF
{
  "query": "query { mintedBadges { level badge { tokenId } badge { name } } }"
}
EOF

Last updated