Skip to main content

API reference: getOwnedObjects

Retrieves a paginated list of on-chain objects owned by a specific 32-byte Sui wallet address.

Use this method to populate wallet dashboards, user inventory screens, and token balance lists. Because a single account can hold thousands of objects, the Sui JSON-RPC API returns owned objects in discrete pages using cursor-based pagination. Because getOwnedObjects is a read operation served directly from fullnode local state, it executes immediately without submitting a transaction or consuming gas.

  • Class: SuiClient
  • Package: @mysten/sui/client
  • Operation type: read operation (no gas, no wallet signature)

Overviewโ€‹

Calling getOwnedObjects queries the fullnode index for objects with ownership assigned to the target address (AddressOwner). To avoid high latency and network timeouts, fullnodes paginate results rather than returning an entire inventory in a single response.

Visualizing the pagination loopโ€‹

Cursor pagination flowchart

Signatureโ€‹

Signature
client.getOwnedObjects(input: GetOwnedObjectsParams): Promise<PaginatedObjectsResponse>

Parametersโ€‹

The method accepts a configuration object with the following properties:

ParameterTypeRequiredDescription
ownerstringYesThe 32-byte hexadecimal address of the target wallet.
filterSuiObjectDataFilterNoCriteria to filter results by type, package, or module.
optionsSuiObjectDataOptionsNoFlags to include additional details (for example, showType, showContent, showDisplay).
cursorstring | nullNoThe nextCursor token from a previous response to fetch the subsequent page.
limitnumberNoMaximum items to return per page (default and maximum is typically 50 on public RPC nodes).

SuiObjectDataFilterโ€‹

The filter parameter narrows queries on the fullnode, saving bandwidth and client-side processing:

Filter KeyValue TypeDescription
MatchAllSuiObjectDataFilter[]Logical AND. An object must satisfy all provided filter criteria.
MatchAnySuiObjectDataFilter[]Logical OR. An object can satisfy any of the provided filter criteria.
StructTypestringExact match for a fully qualified Move Struct type (for example, 0x2::coin::Coin<0x2::sui::SUI>).
PackagestringMatches any object instantiated from modules within the specified package ID.
MoveModule{ package: string, module: string }Matches any object defined within a specific module of a package.

Return valueโ€‹

Returns a Promise that resolves to a PaginatedObjectsResponse object:

Response
{
"data": [
{ "data": { "objectId": "0xA...", "version": "1", "type": "0x2::coin::Coin<0x2::sui::SUI>" } },
{ "data": { "objectId": "0xB...", "version": "4", "type": "0x2::coin::Coin<0x2::sui::SUI>" } }
],
"hasNextPage": true,
"nextCursor": "0x12345...ResultCursor"
}

The response envelope contains the following fields:

FieldTypeDescription
dataSuiObjectResponse[]Array of object response envelopes for the current page.
hasNextPagebooleanIndicates whether additional pages of objects exist.
nextCursorstring | nullOpaque pagination token to pass as cursor in the next call. When hasNextPage is false, this value is null.

Usage examplesโ€‹

Fetch the first page of an inventoryโ€‹

Retrieve the first 5 objects owned by an address:

basicInventory.js
const response = await client.getOwnedObjects({
owner: '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef',
limit: 5,
options: { showType: true }
});

response.data.forEach((item) => {
if (item.data) {
console.log(`ID: ${item.data.objectId}, Type: ${item.data.type}`);
}
});

Filter assets by Move struct typeโ€‹

Query only SUI coin objects owned by a user, excluding other tokens and NFTs:

filterCoins.js
const response = await client.getOwnedObjects({
owner: '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef',
filter: {
StructType: '0x2::coin::Coin<0x2::sui::SUI>'
},
options: { showContent: true }
});

console.log(`Found ${response.data.length} SUI coin objects`);

Paginate through all owned objectsโ€‹

Use a while loop to traverse through every object an address owns:

pagination.js
let hasNextPage = true;
let nextCursor = null;
const allObjects = [];

while (hasNextPage) {
const response = await client.getOwnedObjects({
owner: '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef',
cursor: nextCursor,
limit: 50
});

allObjects.push(...response.data);

hasNextPage = response.hasNextPage;
nextCursor = response.nextCursor;
}

console.log(`Total objects fetched: ${allObjects.length}`);

Common errorsโ€‹

Error codeCauseResolution
cursor_invalidThe string passed to cursor is expired, malformed, or originates from a different query.Pass the exact string returned in nextCursor from the preceding query.
limit_exceededThe requested limit exceeds the fullnode maximum allowed page size (typically 50).Reduce the limit parameter to 50 or fewer items.

See alsoโ€‹