1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

GITBOOK-479: change request with no subject merged in GitBook

This commit is contained in:
Veronica Manuel 2023-06-09 12:07:19 +00:00 committed by gitbook-bot
parent f50b0d4cc1
commit 1423348c6e
No known key found for this signature in database
GPG Key ID: 07D2180C7B12D0FF

View File

@ -57,29 +57,56 @@ https://v4.subgraph.goerli.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-
https://v4.subgraph.mumbai.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
```
You can then use the following example query to find what you're looking for (you can remove datatokens, or the lines with `where: {datatoken/consumer}` to tweak your filtering criteria. You can then explore the graphql editor via the links above to learn how to use it, and to add/remove information to the query.
You can then use the following example Javascript query to list the buyers of the datatoken.
Copy and paste the query below to fetch a list of data NFTs in the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql). Note, that you must first fill in the missing fields for the datatoken address.
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). 
```graphql
query GetFilteredOrders {
orders(
where: { datatoken: { id: "0xc22bfd40f81c4a28c809f80d05070b95a11829d9" } }
orderBy: createdTimestamp
orderDirection: desc
first: 1000
) {
datatoken {
id
name
symbol
nft {
id
}
```runkit nodeVersion="18.x.x"
const axios = require('axios')
const query = `{ token(id :"0x9a9e3fb78b021ce12fc4e23bde1cb0104913ea93") {
id,
orders(
orderBy: createdTimestamp
orderDirection: desc
first: 1000
) {
id
consumer {
id
}
payer {
id
}
reuses {
id
}
block
createdTimestamp
amount
}
}
}`
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)
}
consumer {
id
}
}
}
console.log(response.data.data.token.orders)
})
.catch(function (error) {
console.log(error);
});
```