Skip to main content

API client

Version: V2
View Markdown

This client calls the hosted V1 GraphQL API and is not a V2 read path; see The SDK read client.

API for @0xintuition/sdk@4.1.0. Compatibility · Source.

Import from @0xintuition/sdk/api.

Signatures show the exact accepted inputs and return types. Named input/output structures and dependency-injection types are listed below; viem and protocol types come from their respective packages. Preparation and quote functions can perform RPC reads. Envelope builders on the action-envelope pages use caller-supplied read context and perform no RPC reads or signing. feeProxyExecutePlan sends transactions; the other SDK actions on these pages prepare transactions or read data.

getIntuitionApiUrl​

Select the built-in local, testnet, or mainnet hosted GraphQL endpoint. This is a pure URL lookup, not a Core REST connection.

Source

function getIntuitionApiUrl(network: IntuitionApiNetwork): string;

createIntuitionApiClient​

Construct a read client for the hosted GraphQL schema. Its four methods return normalized atom/triple models or null for absent rows, and throw for transport or GraphQL failures.

Source

function createIntuitionApiClient(
config: IntuitionApiClientConfig,
): IntuitionApiClient;

Constants​

export const INTUITION_API_URL_LOCAL = 'http://localhost:8080/v1/graphql';
export const INTUITION_API_URL_TESTNET =
'https://testnet.intuition.sh/v1/graphql';
export const INTUITION_API_URL_MAINNET =
'https://mainnet.intuition.sh/v1/graphql';

Input and result types​

Exported declarations are public imports from the SDK subpath above. Module-local helper aliases describe accepted shapes but are not public exports.

FetchHeaders​

Module-local helper; not a public export.

type FetchHeaders = Record<string, string>;

FetchResponseLike​

Module-local helper; not a public export.

type FetchResponseLike = {
ok: boolean;
status: number;
json(): Promise<unknown>;
text(): Promise<string>;
};

FetchLike​

Public export.

export type FetchLike = (
input: string,
init?: {
method?: string;
headers?: FetchHeaders;
body?: string;
},
) => Promise<FetchResponseLike>;

IntuitionApiClientAuth​

Public export.

export type IntuitionApiClientAuth =
| {
kind: 'bearer';
token: string;
}
| {
kind: 'apiKey';
value: string;
headerName?: string;
};

IntuitionApiClientConfig​

Public export.

export type IntuitionApiClientConfig = {
baseUrl?: string;
auth?: IntuitionApiClientAuth;
fetch?: FetchLike;
headers?: FetchHeaders;
};

IntuitionApiNetwork​

Public export.

export type IntuitionApiNetwork = 'local' | 'testnet' | 'mainnet';

IntuitionApiAtom​

Public export.

export type IntuitionApiAtom = {
termId: string;
label: string | null;
data: string | null;
image: string | null;
emoji: string | null;
type: string | null;
};

IntuitionApiTermReference​

Public export.

export type IntuitionApiTermReference = {
termId: string;
label: string | null;
image: string | null;
type: string | null;
};

IntuitionApiTriple​

Public export.

export type IntuitionApiTriple = {
termId: string;
subject: IntuitionApiTermReference;
predicate: IntuitionApiTermReference;
object: IntuitionApiTermReference;
};

IntuitionApiClient​

Public export.

export type IntuitionApiClient = {
atoms: {
getById(inputs: { termId: string }): Promise<IntuitionApiAtom | null>;
getByLabel(inputs: { label: string }): Promise<IntuitionApiAtom | null>;
getByData(inputs: { data: string }): Promise<IntuitionApiAtom | null>;
};
triples: {
getById(inputs: { termId: string }): Promise<IntuitionApiTriple | null>;
};
};

GraphqlSuccess​

Module-local helper; not a public export.

type GraphqlSuccess<TData> = {
data?: TData;
errors?: Array<{ message?: string }>;
};

Applies to V2 · @0xintuition/sdk 4.1.0