Skip to content

Latest commit

 

History

History
85 lines (65 loc) · 1.39 KB

query-from-a-client.md

File metadata and controls

85 lines (65 loc) · 1.39 KB

Query from a client

There are several ways to query our GraphQL API :

{% embed url="https://api.sismo.io/" %} Visit the Explorer and interact with our API {% endembed %}

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