<p>Took a while for me to figure out as well but this works. It will return all the asset ids of a particular policy</p>
<pre><code>query TokensByPolicy($policy_id: Hash28Hex) {
  assets(where: { policyId: { _eq: $policy_id } }) {
    assetId
    policyId
    assetName
  }
}
</code></pre>
<p>And you need to pass the policy id as a parameter</p>
<pre><code>{&quot;policy_id&quot;: &quot;7be8b5c60e913079bc1ccf58247dbaf5433fcb70d0abc89a7dd333d4&quot;}
</code></pre>
<p>You can try it out at <a href="https://graphql-api.mainnet.dandelion.link/" rel="nofollow noreferrer">https://graphql-api.mainnet.dandelion.link/</a></p>
<p><a href="https://i.sstatic.net/OOt2E.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OOt2E.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-04-26T12:54:13.790Z
2022-04-26T12:54:13.790Z
elson serrao
<p>currently I'm using blockfrost to request NFT metadata information one by one from a specific policy_id. A policy ID can have up to 10k assets minted so it takes quite a while to fully sync to my local database.</p>
<p>Can I define a graphql schema to do the same thing with dbsync but with just 1 or a few request to the Cardano graphql server?</p>
<p>Was trying on <a href="https://graphql-api.mainnet.dandelion.link/" rel="nofollow noreferrer">https://graphql-api.mainnet.dandelion.link/</a> and couldn't figure this out, any help would be appreciated, thanks.</p>

<cardano-graphql>
How to query cardano graphql api to get all assets metadata from a specific policy id
# How to query cardano graphql api to get all assets metadata from a specific policy id

(Asked by: username_0 on 2022-04-19)

currently I'm using blockfrost to request NFT metadata information one by one from a specific policy\_id. A policy ID can have up to 10k assets minted so it takes quite a while to fully sync to my local database.

Can I define a graphql schema to do the same thing with dbsync but with just 1 or a few request to the Cardano graphql server?

Was trying on <https://graphql-api.mainnet.dandelion.link/> and couldn't figure this out, any help would be appreciated, thanks.

**Tags:** cardano-graphql

---

## 1 answers

### Answer by username_1 on 2022-04-26. Score: 1 | Accepted answer

Took a while for me to figure out as well but this works. It will return all the asset ids of a particular policy
query TokensByPolicy($policy_id: Hash28Hex) {
  assets(where: { policyId: { _eq: $policy_id } }) {
    assetId
    policyId
    assetName
  }
}

And you need to pass the policy id as a parameter
{"policy_id": "7be8b5c60e913079bc1ccf58247dbaf5433fcb70d0abc89a7dd333d4"}

You can try it out at https://graphql-api.mainnet.dandelion.link/


---

