---
title: GraphQL NPM Package
description: Comprehensive guide to use the Intuition GraphQL NPM package
url: https://docs.intuition.systems/docs/v1/graphql-api/npm-package
markdown_url: https://docs.intuition.systems/docs/v1/graphql-api/npm-package.md
version: V1
llms_index: https://docs.intuition.systems/docs/v1/llms.txt
---

The Intuition GraphQL package provides a type-safe interface for interacting with the Intuition API. It functions as the core data fetching layer, supplying generated types and React Query hooks for easy integration with the semantic knowledge graph.

## Key Features

- React Query hooks for data fetching
- Type-safe data fetching
- Error handling
- Loading state
- Pagination
- Sorting
- Filtering

## Installation

Install the package using your preferred package manager:

### npm

```bash
npm install @0xintuition/graphql
```

### pnpm

```bash
pnpm install @0xintuition/graphql
```

### yarn

```bash
yarn add @0xintuition/graphql
```

### bun

```bash
bun install @0xintuition/graphql
```

## Quick Start

### 1. Client Configuration (Optional)

Configure the GraphQL client at the root of your application:

```tsx
import {
  configureClient,
  API_URL_DEV,
  API_URL_PROD,
  API_URL_LOCAL,
  PIN_API_URL,
} from '@0xintuition/graphql';

// Configure the GraphQL client with desired API URL
configureClient({
  apiUrl: API_URL_LOCAL, // For local development
});
```

**Available API URLs:**

- `API_URL_PROD`: `https://mainnet.intuition.sh/v1/graphql` (default)
- `API_URL_DEV`: `https://testnet.intuition.sh/v1/graphql`
- `API_URL_LOCAL`: `http://localhost:8080/v1/graphql`
- `PIN_API_URL`: `https://pin.intuition.systems/v1/graphql`

If you omit this configuration, the package defaults to `API_URL_PROD`.

Pinning mutations use the public gated pinning endpoint and require an Intuition pin API key. Configure the key from a trusted server runtime before calling generated pinning fetchers or pinning helpers:

```typescript
import { configureClient } from '@0xintuition/graphql';

configureClient({
  pinApiKey: process.env.INTUITION_PIN_API_KEY,
});
```

Do not expose `INTUITION_PIN_API_KEY` in public browser environment variables.

### 2. Server Client Usage

For server-side operations:

```typescript
import { createServerClient } from '@0xintuition/graphql';

// Basic usage (most common)
const client = createServerClient({});

// With optional authentication token (rarely needed)
const clientWithAuth = createServerClient({
  token: 'your-auth-token',
});
```

### 3. Using Generated Hooks

Import and use the generated React Query hooks:

```typescript
import { useGetStatsQuery } from '@0xintuition/graphql'

function StatsComponent() {
  const { data, isLoading, error } = useGetStatsQuery()

  if (isLoading) return <div>Loading...</div>
  if (error) return <div>Error: {error.message}</div>

  return <div>{/* Render stats data */}</div>
}
```

```tsx
import {
  useAtomsQuery,
  useTriplesQuery,
  useUserPositionsQuery,
} from '@0xintuition/graphql';

function MyComponent() {
  // Query atoms
  const { data: atoms, isLoading: atomsLoading } = useAtomsQuery({
    variables: { limit: 10 },
  });

  // Query triples
  const { data: triples, isLoading: triplesLoading } = useTriplesQuery({
    variables: { limit: 10 },
  });

  // Query user positions
  const { data: positions } = useUserPositionsQuery({
    variables: { userAddress: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6' },
  });

  if (atomsLoading || triplesLoading) {
    return <div>Loading...</div>;
  }

  return (
    <div>
      <h2>Atoms ({atoms?.atoms?.length || 0})</h2>
      {atoms?.atoms?.map((atom) => (
        <div key={atom.term_id}>
          <strong>{atom.label}</strong> - {atom.type}
        </div>
      ))}

      <h2>Triples ({triples?.triples?.length || 0})</h2>
      {triples?.triples?.map((triple) => (
        <div key={triple.term_id}>
          {triple.subject.label} - {triple.predicate.label} -{' '}
          {triple.object.label}
        </div>
      ))}
    </div>
  );
}
```

## Available React Hooks

The following groups correspond to the query documents in the `src/queries` subdirectory of the package. Hook names are generated from each document and follow the `use<Name>Query` convention. The complete and canonical list may be found in the directory: [`packages/graphql/src/queries`](https://github.com/0xIntuition/intuition-ts/tree/main/packages/graphql/src/queries)

### Accounts

#### Get by ID

        useAccountByIdQuery

#### Search & Filter

        useAccountsQuery

### Atoms

#### Get by ID

        useAtomByIdQuery

        useGetAtomQuery

#### Search & Filter

        useAtomsQuery

        useGetAtomsQuery

### Claims

#### Get by ID

        useClaimByIdQuery

#### Search & Filter

        useClaimsQuery

### Events

#### Get by ID

        useEventByIdQuery

#### Search & Filter

        useEventsQuery

### Follows

#### Get by ID

        useFollowByIdQuery

#### Search & Filter

        useFollowsQuery

### Lists

#### Get by ID

        useListByIdQuery

#### Search & Filter

        useListsQuery

### Points

#### Get by ID

        usePointByIdQuery

#### Search & Filter

        usePointsQuery

### Positions

#### Get by ID

        usePositionByIdQuery

#### Search & Filter

        usePositionsQuery

        useUserPositionsQuery

### Signals

#### Get by ID

        useSignalByIdQuery

#### Search & Filter

        useSignalsQuery

        useGetSignalsQuery

### Stats

#### Get

        useGetStatsQuery

#### Search & Filter

        useStatsQuery

### Tags

#### Get by ID

        useTagByIdQuery

#### Search & Filter

        useTagsQuery

### Triples

#### Get by ID

        useTripleByIdQuery

#### Search & Filter

        useTriplesQuery

### Vaults

#### Get by ID

        useVaultByIdQuery

#### Search & Filter

        useVaultsQuery

These hooks are generated via GraphQL Code Generator and may expand over time as new documents are added. See the package source below for the current and authoritative list.

## Source Code

The GraphQL package source code is available on GitHub: [`intuition-ts/packages/graphql`](https://github.com/0xIntuition/intuition-ts/tree/main/packages/graphql)

## Related Resources

- [GraphQL Code Generator](https://the-guild.dev/graphql/codegen)
- [React Query Documentation](https://tanstack.com/query)
