Skip to main content

API overview

BarkSwap's data API is GraphQL, served by a graph-node running the BarkSwap subgraphs. There is no REST API — pools, tokens, positions, farmings, and gauges are all read with GraphQL queries. This is the same API the BarkSwap app uses.

Base URL

https://subgraph.barkswap.fi

Data is split across four subgraphs, each at its own path:

SubgraphEndpointServes
Core…/subgraphs/name/barkswap/corePools, tokens, ticks, prices, analytics
Farming…/subgraphs/name/barkswap/farmingEternal farmings, farm deposits
Positions…/subgraphs/name/barkswap/positionsPosition deposits & rewards
Gauges…/subgraphs/name/barkswap/gaugesve(3,3) gauges & staked positions

See Endpoints for what each one contains and which to query.

Public & read-only

The subgraphs are public — no API key or auth. Send GraphQL queries over POST. The API is read-only; all state changes happen onchain.

Sending a query

POST a JSON body with a query (and optional variables) to a subgraph endpoint.

curl -X POST https://subgraph.barkswap.fi/subgraphs/name/barkswap/core \
-H 'Content-Type: application/json' \
--data '{"query":"{ pools(first: 5) { id token0 { symbol } token1 { symbol } totalValueLockedUSD } }"}'
const ENDPOINT = 'https://subgraph.barkswap.fi/subgraphs/name/barkswap/core';

async function query(query, variables) {
const res = await fetch(ENDPOINT, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query, variables }),
});
const { data, errors } = await res.json();
if (errors) throw new Error(errors[0].message);
return data;
}

const { pools } = await query(`{ pools(first: 5) { id totalValueLockedUSD } }`);

With Apollo Client (as the app does):

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

const client = new ApolloClient({
link: new HttpLink({ uri: 'https://subgraph.barkswap.fi/subgraphs/name/barkswap/core' }),
cache: new InMemoryCache(),
});

Query conventions (The Graph)

All subgraphs follow standard The Graph query semantics:

FeatureExample
Paginationpools(first: 100, skip: 200)first ≤ 1000 per page
Filteringpools(where: { token0: "0xabc…" }), suffixes like _gt, _in, _contains
Orderingpools(orderBy: totalValueLockedUSD, orderDirection: desc)
Single entitypool(id: "0x123…") — ids are lowercased addresses
Time travelpools(block: { number: 5300000 })

Checking freshness

Every subgraph exposes _meta — use it to see the indexed head block and whether indexing is healthy before trusting a read:

{
_meta {
block { number timestamp }
hasIndexingErrors
}
}
  1. Endpoints — the four subgraphs and what each serves.
  2. Queries — copy-paste queries for pools, tokens, farmings, and gauges.
  3. Schema reference — entities and their fields.