Skip to content
For the complete documentation index optimized for AI agents, see llms.txt or llms-full.txt. A markdown version of this page is available by appending .md to the URL or sending Accept: text/markdown.

Filtering Feeds

For AI agents: the documentation index is at llms.txt (full corpus: llms-full.txt). A markdown source for this page is /using-stacks/filtering-feeds.md.

When streaming data from views, you can control what the server sends to reduce bandwidth and improve performance.


All Arete SDKs support these parameters when subscribing to feeds:

ParameterTypeDescription
takenumberMaximum number of entities to return
skipnumberNumber of entities to skip (for pagination)
keystringEntity key for state view subscriptions

Use take and skip to paginate through large datasets:

import { useArete } from "arete-react";
import { TOKEN_STACK } from "arete-stacks/token";
function TokenList() {
const a4 = useArete(TOKEN_STACK);
const [page, setPage] = useState(1);
const pageSize = 10;
// Paginated subscription
const { data: tokens } = a4.views.Token.list.use({
take: pageSize,
skip: (page - 1) * pageSize,
});
return (
<div>
{tokens?.map(t => <TokenRow key={t.id.mint} token={t} />)}
<button onClick={() => setPage(p => p + 1)}>Next Page</button>
</div>
);
}

For state views, pass the entity key to subscribe to a specific entity:

const { data: token } = a4.views.Token.state.use(tokenAddress);

Beyond the default state and list views, stacks can define custom views with sorting and limits applied at the server level.

  • Reduced bandwidth - Server applies sorting/limits before transmitting
  • Consistent ordering - Sort order is defined once in your stack
  • Pre-configured limits - Useful for “top N” or “latest N” views

Custom views are defined using the #[view] attribute on your entity struct:

use arete::prelude::*;
#[arete(idl = "idl/ore.json")]
pub mod ore_stream {
#[entity(name = "OreRound")]
#[view(name = "latest", sort_by = "id.round_id", order = "desc")]
pub struct OreRound {
pub id: RoundId,
pub state: RoundState,
// ... other fields
}
}
ParameterTypeDescription
namestringView name (e.g., "latest")
sort_bystringField path to sort by (e.g., "id.round_id")
order"asc" | "desc"Sort order (default: "desc")
takenumberOptional limit on results

Custom views appear alongside the default views in your SDK:

import { useArete } from "arete-react";
import { ORE_STREAM_STACK } from "arete-stacks/ore";
function LatestRounds() {
const a4 = useArete(ORE_STREAM_STACK);
// Default views
const { data: allRounds } = a4.views.OreRound.list.use();
const { data: round } = a4.views.OreRound.state.use(roundAddress);
// Custom view - sorted by round_id desc
const { data: latestRounds } = a4.views.OreRound.latest.use();
return <div>{latestRounds?.map(r => <Round key={r.id.round_id} round={r} />)}</div>;
}
#[entity(name = "Token")]
#[view(name = "topByVolume", sort_by = "metrics.total_volume", order = "desc", take = 10)]
pub struct Token {
pub id: TokenId,
pub metrics: TokenMetrics,
}
// Get top 10 tokens by volume
for await (const token of a4.views.Token.topByVolume.use()) {
console.log(token.id.mint, token.metrics.total_volume);
}

See Stack Definitions for complete documentation on defining entities and views.


If you need dynamic filtering that changes at runtime, apply filters client-side after receiving data:

The React SDK provides a where clause for declarative client-side filtering:

import { useArete } from "arete-react";
import { TOKEN_STACK } from "arete-stacks/token";
function HighVolumeTokens() {
const a4 = useArete(TOKEN_STACK);
// Client-side filtering with where clause
const { data: tokens } = a4.views.Token.list.use({
where: {
volume: { gte: 10000 },
price: { lte: 100 }
},
limit: 20, // Client-side limit
});
return <TokenList tokens={tokens} />;
}

Supported where operators:

OperatorDescription
gteGreater than or equal
lteLess than or equal
gtGreater than
ltLess than
(value)Exact match