Aller au contenu principal

GraphQL API Example Queries

This page contains some example queries to get you started exploring Intuition data. You can run these queries directly in the embedded playground on the previous page.

For ease of exploration these example queries have the GraphQL fragments included and contain a robust set of fields. We encourage you to open the Apollo Explorer links and interact with each query.

If you’re looking for a thorough, robust view into our published queries we recommended experimenting with our GraphQL package in our monorepo: https://github.com/0xIntuition/intuition-ts/tree/main/packages/graphql

  • This package is published on npm and contains fragments, queries, and typesafe query documents and hooks that can be integrated into a React/Node app.

Atom Queries

There are two primary queries available for retrieving Atom data:

  • GetAtoms: Retrieves a collection of atoms based on specified filters and parameters
  • GetAtom: Fetches a single atom by its unique identifier (id)

These Atom queries are foundational and are used in more complex queries to retrieve data from the Intuition protocol.

GetAtoms

query GetAtoms(
$limit: Int
$offset: Int
$orderBy: [atoms_order_by!]
$where: atoms_bool_exp
) {
atoms_aggregate(where: $where) {
aggregate {
count
}
}
atoms(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {
# AtomMetadata fields
data
id
image
label
emoji
type
creator {
id
label
image
}
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}

# AtomTxn fields
block_number
block_timestamp
transaction_hash
creator_id

# AtomVaultDetails fields
vault_id
wallet_id
vault {
position_count
total_shares
current_share_price
positions_aggregate {
aggregate {
count
sum {
shares
}
}
}
positions {
id
account {
label
id
}
shares
}
}

# AtomTriple fields
as_subject_triples {
id
object {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
predicate {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
}
as_predicate_triples {
id
subject {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
object {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
}
as_object_triples {
id
subject {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
predicate {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
}
}
}

Interact with this query in Apollo Sandbox

GetAtom

query GetAtom($id: numeric!) {
atom(id: $id) {
# AtomMetadata fields
data
id
image
label
emoji
type
creator {
id
label
image
}
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}

# AtomTxn fields
block_number
block_timestamp
transaction_hash
creator_id

# AtomVaultDetails fields
vault_id
wallet_id
vault {
position_count
total_shares
current_share_price
positions_aggregate {
aggregate {
count
sum {
shares
}
}
}
positions {
id
account {
label
id
}
shares
}
}

# AtomTriple fields
as_subject_triples {
id
object {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
predicate {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
}
as_predicate_triples {
id
subject {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
object {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
}
as_object_triples {
id
subject {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
predicate {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
}

triplesPredicateTotal: as_predicate_triples_aggregate {
aggregate {
count
}
}

triplesObjectTotal: as_object_triples_aggregate {
aggregate {
count
}
}
}
}

# Variables
{
"id": "23151",
}

Interact with this query in Apollo Sandbox

Account Queries

There are two primary queries available for retrieving Account data:

  • GetAccounts: Retrieves a collection of atoms based on specified filters and parameters
  • GetAccount: Fetches a single atom by its unique identifier (address)

We have more supporting Account queries in our GraphQL package.

GetAccounts

query GetAccounts {
accounts {
# AccountMetadata fields
label
image
id
atom_id
type

# AccountClaims fields
claims(order_by: { shares: desc }) {
triple {
id
}
shares
counter_shares
}

# AccountPositions fields
positions(order_by: { shares: desc }) {
id
shares
vault {
id
total_shares
current_share_price
atom {
id
label
}
triple {
id
}
}
}
atom {
vault_id
wallet_id
vault {
position_count
total_shares
positions_aggregate {
aggregate {
count
sum {
shares
}
}
}
positions {
id
account {
label
id
}
shares
}
}
}
}
}

Interact with this query in Apollo Sandbox

GetAccount

query GetAccount($address: String!, $orderBy: [atoms_order_by!]) {
account(id: $address) {
label
image
id
atom_id
type
atom {
id
data
image
label
emoji
type
wallet_id
creator {
id
label
image
}
}

claims(order_by: { shares: desc }) {
triple {
id
}
shares
counter_shares
}
}
}

# Variables
{
"address": "0x...", // change to valid address
"orderBy": {
"vault": {
"totalShares": "desc"
}
}
}

Interact with this query in Apollo Sandbox

Triple Queries

There are two primary queries available for retrieving Triple data:

  • GetTriples: Retrieves a collection of triples based on specified filters and parameters
  • GetTriple: Fetches a single triple by its unique identifier (id)

We have additional Triple queries in our GraphQL package.

GetTriples

query GetTriples(
$limit: Int
$offset: Int
$orderBy: [triples_order_by!]
$where: triples_bool_exp
) {
triples(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {
# TripleMetadata fields
id
subject {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
predicate {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
object {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}

# TripleTxn fields
block_number
block_timestamp
transaction_hash
creator_id

# TripleVaultDetails fields
vault_id
counter_vault_id
vault {
id
total_shares
current_share_price
position_count
atom {
id
label
}
}
counter_vault {
id
total_shares
current_share_price
position_count
atom {
id
label
}
}

# Creator fields
creator {
label
image
id
atom_id
type
}
}
}

Interact with this query in the Apollo Sandbox

GetTriple

query GetTriple($tripleId: numeric!) {
triple(id: $tripleId) {
# TripleMetadata fields
id
subject {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
predicate {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}
object {
data
id
image
label
emoji
type
creator {
label
image
id
atom_id
type
}
}

# TripleTxn fields
block_number
block_timestamp
transaction_hash
creator_id

# TripleVaultDetails fields
vault_id
counter_vault_id
vault {
id
total_shares
current_share_price
position_count
atom {
id
label
}
}
counter_vault {
id
total_shares
current_share_price
position_count
atom {
id
label
}
}

# Creator fields
creator {
label
image
id
atom_id
type
}
}
}

# Variables
{
"tripleId": "15"
}

Interact with this query in Apollo Sandbox

Positions

GetPositions

# Main pagination query
query GetPositions(
$where: positions_bool_exp
) {
total: positions_aggregate(where: $where) {
aggregate {
count
sum {
shares
}
}
}
positions(where: $where) {
id
account {
id
label
image
}
vault {
id
atom {
id
label
image
}
triple {
id
vault {
id
position_count
positions_aggregate {
aggregate {
sum {
shares
}
}
}
}
counter_vault {
id
position_count
positions_aggregate {
aggregate {
sum {
shares
}
}
}
}
subject {
data
id
label
image
emoji
type
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}
creator {
label
image
id
atom_id
type
}
}
predicate {
data
id
label
image
emoji
type
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}
creator {
label
image
id
atom_id
type
}
}
object {
data
id
label
image
emoji
type
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}
creator {
label
image
id
atom_id
type
}
}
}
}
shares
vault_id
}
}

Interact with this query in Apollo Sandbox

GetPosition

query GetPosition($positionId: String!) {
position(id: $positionId) {
id
account {
id
label
image
}
vault {
id
atom {
id
label
image
}
triple {
id
vault {
id
position_count
positions_aggregate {
aggregate {
sum {
shares
}
}
}
}
counter_vault {
id
position_count
positions_aggregate {
aggregate {
sum {
shares
}
}
}
}
subject {
data
id
label
image
emoji
type
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}
creator {
label
image
id
atom_id
type
}
}
predicate {
data
id
label
image
emoji
type
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}
creator {
label
image
id
atom_id
type
}
}
object {
data
id
label
image
emoji
type
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}
creator {
label
image
id
atom_id
type
}
}
}
}
shares
vault_id
}
}

Interact with this query in Apollo Sandbox

Vaults

GetVaults

query GetVaults(
$where: vaults_bool_exp
) {
vaults_aggregate(
where: $where
) {
aggregate {
count
}
}
vaults {
id
atom {
id
label
}
triple {
id
subject {
id
label
}
predicate {
id
label
}
object {
id
label
}
}
position_count
positions {
account {
id
label
}
shares
}
current_share_price
total_shares
}
}
}

Interact with this query in Apollo Sandbox

GetVault

query GetVault($vaultId: numeric!) {
vault(id: $vaultId) {
id
atom {
id
label
}
triple {
id
subject {
id
label
}
predicate {
id
label
}
object {
id
label
}
}
current_share_price
total_shares
}
}

# Variables
{
"vaultId": "1"
}

Interact with this query in Apollo Sandbox

“Utility” Queries

Our “utility” queries don’t necessarily fall into the other categories but are examples of how you can query for specific purpose data.

We have several more queries in our GraphQL package.

GetEvents

query GetEvents($where: events_bool_exp, $addresses: [String!]) {
total: events_aggregate(where: $where) {
aggregate {
count
}
}
events(where: $where) {
id
block_number
block_timestamp
type
transaction_hash
atom_id
triple_id
deposit_id
redemption_id
atom {
id
data
image
label
emoji
type
wallet_id
creator {
id
label
image
}
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}
vault {
total_shares
position_count
positions(where: { account: { id: { _in: $addresses } } }) {
account_id
shares
account {
id
label
image
}
}
}
}
triple {
id
creator {
label
image
id
atom_id
type
}
subject {
data
id
image
label
emoji
type
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}
creator {
label
image
id
atom_id
type
}
}
predicate {
data
id
image
label
emoji
type
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}
creator {
label
image
id
atom_id
type
}
}
object {
data
id
image
label
emoji
type
value {
person {
name
image
description
url
}
thing {
name
image
description
url
}
organization {
name
image
description
url
}
}
creator {
label
image
id
atom_id
type
}
}
vault {
total_shares
position_count
positions(where: { account: { id: { _in: $addresses } } }) {
account_id
shares
account {
id
label
image
}
}
}
counter_vault {
total_shares
position_count
positions(where: { account: { id: { _in: $addresses } } }) {
account_id
shares
account {
id
label
image
}
}
}
}
deposit {
sender_id
sender {
id
}
shares_for_receiver
sender_assets_after_total_fees
vault {
total_shares
position_count
positions(where: { account: { id: { _in: $addresses } } }) {
account_id
shares
account {
id
label
image
}
}
}
}
redemption {
sender_id
sender {
id
}
}
}
}


# Variables

{
"addresses": ["0x..."]
}

Interact with this query in Apollo Sandbox