2023-06-08 21:31:59 +02:00
---
2023-06-08 21:40:03 +02:00
description: >-
Use these steps to reveal the information contained within an asset's DID and
2023-06-16 14:34:22 +02:00
list the buyers of a datatoken using the Subgraph
2023-06-08 21:31:59 +02:00
---
2023-06-09 02:07:13 +02:00
# List datatoken buyers
2023-06-08 21:31:59 +02:00
2023-06-16 14:34:22 +02:00
## Query the Subgraph to see all buyers of a datatoken
2023-06-08 21:40:03 +02:00
2023-06-09 02:07:13 +02:00
Select the corresponding subgraph URL for the asset's network. Below are some of the popular subgraph URLs, to show you the subgraph URL format.
2023-06-08 21:40:03 +02:00
```
https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.polygon.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.bsc.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.moonriver.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.energyweb.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.goerli.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.mumbai.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
```
2023-06-09 00:43:13 +02:00
2023-06-09 14:07:19 +02:00
You can then use the following example Javascript query to list the buyers of the datatoken.
Note, that you can also copy and paste the contents of the query function below to fetch the same info from the Ocean Subgraph [GraphiQL interface ](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql ). 
```runkit nodeVersion="18.x.x"
const axios = require('axios')
2023-06-09 15:10:40 +02:00
const datatoken = "0xc22bfd40f81c4a28c809f80d05070b95a11829d9".toLowerCase()
const query = `{
token(id : "${datatoken}") {
2023-06-09 14:07:19 +02:00
id,
orders(
orderBy: createdTimestamp
orderDirection: desc
first: 1000
) {
id
consumer {
id
}
payer {
id
}
reuses {
id
}
block
createdTimestamp
amount
}
}
2023-06-09 15:10:40 +02:00
}`
2023-06-09 14:07:19 +02:00
const network = "mumbai"
var config = {
method: 'post',
url: `https://v4.subgraph.${network}.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph` ,
headers: { "Content-Type": "application/json" },
data: JSON.stringify({ "query": query })
};
axios(config)
.then(function (response) {
const orders = response.data.data.token.orders
console.log(orders)
for (let order of orders) {
console.log('id:' + order.id + ' consumer: ' + order.consumer.id + ' payer: ' + order.payer.id)
2023-06-09 00:43:13 +02:00
}
2023-06-09 14:07:19 +02:00
console.log(response.data.data.token.orders)
})
.catch(function (error) {
console.log(error);
});
2023-06-09 00:43:13 +02:00
```