From 1423348c6efc687436f22526d4672cbdaee88c7d Mon Sep 17 00:00:00 2001 From: Veronica Manuel Date: Fri, 9 Jun 2023 12:07:19 +0000 Subject: [PATCH] GITBOOK-479: change request with no subject merged in GitBook --- developers/subgraph/list-datatoken-buyers.md | 71 ++++++++++++++------ 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/developers/subgraph/list-datatoken-buyers.md b/developers/subgraph/list-datatoken-buyers.md index e3c56a5f..235ae3de 100644 --- a/developers/subgraph/list-datatoken-buyers.md +++ b/developers/subgraph/list-datatoken-buyers.md @@ -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); +}); + ```