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:
| Subgraph | Endpoint | Serves |
|---|---|---|
| Core | …/subgraphs/name/barkswap/core | Pools, tokens, ticks, prices, analytics |
| Farming | …/subgraphs/name/barkswap/farming | Eternal farmings, farm deposits |
| Positions | …/subgraphs/name/barkswap/positions | Position deposits & rewards |
| Gauges | …/subgraphs/name/barkswap/gauges | ve(3,3) gauges & staked positions |
See Endpoints for what each one contains and which to query.
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:
| Feature | Example |
|---|---|
| Pagination | pools(first: 100, skip: 200) — first ≤ 1000 per page |
| Filtering | pools(where: { token0: "0xabc…" }), suffixes like _gt, _in, _contains |
| Ordering | pools(orderBy: totalValueLockedUSD, orderDirection: desc) |
| Single entity | pool(id: "0x123…") — ids are lowercased addresses |
| Time travel | pools(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
}
}
Read next
- Endpoints — the four subgraphs and what each serves.
- Queries — copy-paste queries for pools, tokens, farmings, and gauges.
- Schema reference — entities and their fields.