Skip to content

How do I get all the keys in a table? #37

Answered by banool
banool asked this question in Questions
Discussion options

You must be logged in to vote

Indexer API

You can make a query to the table_items table. You will need to paginate to get all the items:

query MyQuery {
  table_items(
    where: {table_handle: {_eq: "0xd71c4400706e2addf04f8728fbc4f0a87d0612456cdcec95ae8fea0a4bd31b67"}}
    limit: 100
    offset: 0
  ) {
    key
  }
}

Each request increase offset by limit (e.g. in this case, by 100 each time). Continue until the response has fewer than 100 items.

Learn about the indexer API here: https://aptos.dev/indexer/api/.

Node API

Unfortunately with regular tables there is no way to do this via the node API right now.

Alternatives

  • If you know you'll only ever have a small number of items (like < 100), you could use SimpleMap. T…

Replies: 1 comment

Comment options

banool
Mar 7, 2024
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by banool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
move Questions related to the Move Language
1 participant