From bc4c1becfae1d29e0c4c0864900ee70d89f472c5 Mon Sep 17 00:00:00 2001 From: Akshay Patel Date: Mon, 8 Aug 2022 13:32:52 +0000 Subject: [PATCH 1/2] GitBook: [#1] No subject --- .../using-ocean-subgraph/README.md | 29 ++++++++++++++----- .../get-data-nft-information.md | 6 ++-- .../get-datatoken-information.md | 11 +++---- .../using-ocean-subgraph/list-data-nfts.md | 6 ++-- .../using-ocean-subgraph/list-datatokens.md | 10 +++---- .../list-fixed-rate-exchanges.md | 10 +++---- 6 files changed, 40 insertions(+), 32 deletions(-) diff --git a/building-with-ocean/using-ocean-subgraph/README.md b/building-with-ocean/using-ocean-subgraph/README.md index 10409898e..80541fb4d 100644 --- a/building-with-ocean/using-ocean-subgraph/README.md +++ b/building-with-ocean/using-ocean-subgraph/README.md @@ -1,10 +1,23 @@ ---- -description: >- - Ocean subgraph is an off-chain service which provides information about - datatokens, users, balances using the GraphQL. Ocean subgraph provides a - faster way to fetch data rather than on-chain query. ---- - # Using Ocean Subgraph -For each supported network, an individual Ocean subgraph is deployed. The information about supported networks and the subgraph URL is available on [this page](../../core-concepts/networks.md). +Ocean subgraph is an off-chain service that provides information about datatokens, users, and balances using GraphQL. The Ocean subgraph provides a faster way to fetch data rather than an on-chain query. The data from Ocean subgraph can be queried using [GraphQL](https://graphql.org/learn/). + +You can use the Subgraph instances hosted by Ocean Protocol or host your instance. The page on Deploying Ocean Subgraph provides a guide on hosting your own Ocean Subgraph instance. + +For each supported network, an individual Ocean subgraph is deployed. The information about supported networks are available on this [page](../../core-concepts/networks.md). + +#### Ocean Subgraph GraphiQL + +The below table provides the link to GraphiQL for the support networks. The Graphql queries can be directly executed using the GraphiQL interface without the need of any setup. + +| Network and link | +| ----------------------------------------------------------------------------------------------------------------------- | +| [Ethereum Mainnet](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) | +| [Polygon Mainnet](https://v4.subgraph.polygon.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) | +| [Binance Smart Chain](https://v4.subgraph.bsc.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) | +| [Energy Web Chain](https://v4.subgraph.energyweb.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) | +| [Moonriver](https://v4.subgraph.moonriver.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) | +| [Mumbai](https://v4.subgraph.mumbai.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) | +| [Rinkeby](https://v4.subgraph.rinkeby.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) | +| [Ropsten](https://v4.subgraph.ropsten.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) | +| [Moonbase](https://v4.subgraph.moonbase.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) | diff --git a/building-with-ocean/using-ocean-subgraph/get-data-nft-information.md b/building-with-ocean/using-ocean-subgraph/get-data-nft-information.md index f1f1ff2c0..438b0f426 100644 --- a/building-with-ocean/using-ocean-subgraph/get-data-nft-information.md +++ b/building-with-ocean/using-ocean-subgraph/get-data-nft-information.md @@ -1,9 +1,9 @@ # Get data NFT information -The result of following GraphQL query returns the information about a particular datatoken. Here, `0x1c161d721e6d99f58d47f709cdc77025056c544c` is the address of the dataNFT. +The result of following GraphQL query returns the information about a particular datatoken. Here, `0x1c161d721e6d99f58d47f709cdc77025056c544c` is the address of the dataNFT. {% hint style="info" %} -Copy the query in the [graphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks, change the domain name with appropriate subgraph domain as mentioned in [this page](../../core-concepts/networks.md). +Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](./#ocean-subgraph-graphiql). {% endhint %} ```graphql @@ -83,7 +83,7 @@ print(json.dumps(result, indent=4, sort_keys=True)) ``` {% endcode %} -#### Execute script +**Execute script** ``` python dataNFT_information.py diff --git a/building-with-ocean/using-ocean-subgraph/get-datatoken-information.md b/building-with-ocean/using-ocean-subgraph/get-datatoken-information.md index 9e8262e2b..3c8220ce4 100644 --- a/building-with-ocean/using-ocean-subgraph/get-datatoken-information.md +++ b/building-with-ocean/using-ocean-subgraph/get-datatoken-information.md @@ -1,11 +1,9 @@ # Get datatoken information - - -The result of following GraphQL query returns the information about a particular datatoken. Here, `0x122d10d543bc600967b4db0f45f80cb1ddee43eb` is the address of the datatoken. +The result of following GraphQL query returns the information about a particular datatoken. Here, `0x122d10d543bc600967b4db0f45f80cb1ddee43eb` is the address of the datatoken. {% hint style="info" %} -Copy the query in the [graphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks, change the domain name with appropriate subgraph domain as mentioned in [this page](../../core-concepts/networks.md). +Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](./#ocean-subgraph-graphiql). {% endhint %} ```graphql @@ -50,7 +48,7 @@ The python script below can be used to run the the query. If you wish to change {% tabs %} {% tab title="Python" %} -#### Create script +**Create script** {% code title="datatoken_information.py" %} ```python @@ -108,11 +106,10 @@ response = requests.request("POST", url, headers=headers, data=payload) result = json.loads(response.text) print(json.dumps(result, indent=4, sort_keys=True)) - ``` {% endcode %} -#### Execute script +**Execute script** ``` python datatoken_information.py diff --git a/building-with-ocean/using-ocean-subgraph/list-data-nfts.md b/building-with-ocean/using-ocean-subgraph/list-data-nfts.md index 152b2029e..0fc994a93 100644 --- a/building-with-ocean/using-ocean-subgraph/list-data-nfts.md +++ b/building-with-ocean/using-ocean-subgraph/list-data-nfts.md @@ -1,9 +1,9 @@ # List data NFTs -The result of following GraphQL query returns the information about data nfts. +The result of following GraphQL query returns the information about data nfts. {% hint style="info" %} -Copy the query in the [graphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks, change the domain name with appropriate subgraph domain as mentioned in [this page](../../core-concepts/networks.md). +Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](./#ocean-subgraph-graphiql). {% endhint %} ```graphql @@ -62,7 +62,7 @@ print(json.dumps(result, indent=4, sort_keys=True)) ``` {% endcode %} -#### Execute script +**Execute script** ``` python list_dataNFTs.py diff --git a/building-with-ocean/using-ocean-subgraph/list-datatokens.md b/building-with-ocean/using-ocean-subgraph/list-datatokens.md index 7ab4ee619..afbdba1c0 100644 --- a/building-with-ocean/using-ocean-subgraph/list-datatokens.md +++ b/building-with-ocean/using-ocean-subgraph/list-datatokens.md @@ -1,9 +1,9 @@ # List all tokens -The result of following GraphQL query returns the information about datatokens. +The result of following GraphQL query returns the information about datatokens. {% hint style="info" %} -Copy the query in the [graphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks, change the domain name with appropriate subgraph domain as mentioned in [this page](../../core-concepts/networks.md). +Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](./#ocean-subgraph-graphiql). {% endhint %} ```graphql @@ -43,7 +43,7 @@ The python script below can be used to run the the query. If you wish to change {% tabs %} {% tab title="Python" %} -#### Create script +**Create script** {% code title="list_all_tokens.py" %} ```python @@ -95,11 +95,10 @@ response = requests.request("POST", url, headers=headers, data=payload) result = json.loads(response.text) print(json.dumps(result, indent=4, sort_keys=True)) - ``` {% endcode %} -#### Execute script +**Execute script** ``` python list_all_tokens.py @@ -147,4 +146,3 @@ python list_all_tokens.py ``` - diff --git a/building-with-ocean/using-ocean-subgraph/list-fixed-rate-exchanges.md b/building-with-ocean/using-ocean-subgraph/list-fixed-rate-exchanges.md index c42cd8a72..708df1a26 100644 --- a/building-with-ocean/using-ocean-subgraph/list-fixed-rate-exchanges.md +++ b/building-with-ocean/using-ocean-subgraph/list-fixed-rate-exchanges.md @@ -1,9 +1,9 @@ # List Fixed Rate Exchanges -The result of following GraphQL query returns the information about the Fixed Rate Exchanges. +The result of following GraphQL query returns the information about the Fixed Rate Exchanges. {% hint style="info" %} -Copy the query in the [graphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks, change the domain name with appropriate subgraph domain as mentioned in [this page](../../core-concepts/networks.md). +Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](./#ocean-subgraph-graphiql). {% endhint %} ```graphql @@ -42,11 +42,11 @@ Copy the query in the [graphiQL interface](https://v4.subgraph.mainnet.oceanprot } ``` -The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. +The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. {% tabs %} {% tab title="Python" %} -#### Create script +**Create script** {% code title="list_fixed_rate_exchanges.py" %} ```python @@ -104,7 +104,7 @@ print(json.dumps(result, indent=4, sort_keys=True)) ``` {% endcode %} -#### Execute script +**Execute script** ``` python list_fixed_rate_exchanges.py From b6a2ee404141c3b1234733450cee3dbb0474e2bf Mon Sep 17 00:00:00 2001 From: Akshay Patel Date: Mon, 8 Aug 2022 14:08:09 +0000 Subject: [PATCH 2/2] GitBook: [#2] Minor fix --- .../get-data-nft-information.md | 77 ++++++++++++++++- .../get-datatoken-information.md | 85 ++++++++++++++++++- .../using-ocean-subgraph/list-data-nfts.md | 62 +++++++++++++- .../using-ocean-subgraph/list-datatokens.md | 77 ++++++++++++++++- .../list-fixed-rate-exchanges.md | 82 +++++++++++++++++- 5 files changed, 374 insertions(+), 9 deletions(-) diff --git a/building-with-ocean/using-ocean-subgraph/get-data-nft-information.md b/building-with-ocean/using-ocean-subgraph/get-data-nft-information.md index 438b0f426..c1a83dfb8 100644 --- a/building-with-ocean/using-ocean-subgraph/get-data-nft-information.md +++ b/building-with-ocean/using-ocean-subgraph/get-data-nft-information.md @@ -6,6 +6,8 @@ The result of following GraphQL query returns the information about a particular Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](./#ocean-subgraph-graphiql). {% endhint %} +#### Query + ```graphql { nft (id:"0x1c161d721e6d99f58d47f709cdc77025056c544c", subgraphError:deny){ @@ -29,13 +31,17 @@ Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprot template orderCount } -}b +} ``` -The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. Change the value of the variable dataNFT\_address with the address of the datatoken of your choice. +#### Code {% tabs %} {% tab title="Python" %} +The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. Change the value of the variable dataNFT\_address with the address of the datatoken of your choice. + +#### Create script + {% code title="dataNFT_information.py" %} ```python import requests @@ -85,12 +91,77 @@ print(json.dumps(result, indent=4, sort_keys=True)) **Execute script** +
python dataNFT_information.py
+{% endtab %} + +{% tab title="Javascript" %} +The javascript below can be used to run the the query. If you wish to change the network, then replace the value of variable `baseUrl` as needed. Change the value of the variable `datanftAddress` with the address of the datatoken of your choice. + +#### Create script + +{% code title="dataNFTInfo.js" %} +```javascript +var axios = require('axios'); + +const datanftAddress = "0x1c161d721e6d99f58d47f709cdc77025056c544c"; + +const query = `{ + nft (id:"${datanftAddress}", subgraphError:deny){ + id + name + symbol + owner + address + assetState + tx + block + transferable + creator + createdTimestamp + providerUrl + managerRole + erc20DeployerRole + storeUpdateRole + metadataRole + tokenUri + template + orderCount + } +}` + +const baseUrl = "https://v4.subgraph.mainnet.oceanprotocol.com" +const route = "/subgraphs/name/oceanprotocol/ocean-subgraph" + +const url = `${baseUrl}${route}` + +var config = { + method: 'post', + url: url, + headers: { "Content-Type": "application/json" }, + data: JSON.stringify({ "query": query }) +}; + +axios(config) + .then(function (response) { + console.log(JSON.stringify(response.data)); + }) + .catch(function (error) { + console.log(error); + }); + ``` -python dataNFT_information.py +{% endcode %} + +#### Execute script + +```bash +node dataNFTInfo.js ``` {% endtab %} {% endtabs %} +#### Response +
Sample response diff --git a/building-with-ocean/using-ocean-subgraph/get-datatoken-information.md b/building-with-ocean/using-ocean-subgraph/get-datatoken-information.md index 3c8220ce4..a4f4277cf 100644 --- a/building-with-ocean/using-ocean-subgraph/get-datatoken-information.md +++ b/building-with-ocean/using-ocean-subgraph/get-datatoken-information.md @@ -6,6 +6,8 @@ The result of following GraphQL query returns the information about a particular Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](./#ocean-subgraph-graphiql). {% endhint %} +#### Query + ```graphql { token(id:"0x122d10d543bc600967b4db0f45f80cb1ddee43eb", subgraphError: deny){ @@ -44,10 +46,12 @@ Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprot } ``` -The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. Change the value of the variable `datatoken_address` with the address of the datatoken of your choice. +#### Code {% tabs %} {% tab title="Python" %} +The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. Change the value of the variable `datatoken_address` with the address of the datatoken of your choice. + **Create script** {% code title="datatoken_information.py" %} @@ -111,12 +115,89 @@ print(json.dumps(result, indent=4, sort_keys=True)) **Execute script** +
python datatoken_information.py
+{% endtab %} + +{% tab title="Javascript" %} +The javascript below can be used to run the the query. If you wish to change the network, then replace the value of variable `baseUrl` as needed. Change the value of the variable `datatokenAddress` with the address of the datatoken of your choice. + +**Create script** + +{% code title="datatokenInfo.js" %} +```javascript +var axios = require('axios'); + +const datatokenAddress = "0x122d10d543bc600967b4db0f45f80cb1ddee43eb"; + +const query = `{ + token(id:"${datatokenAddress}", subgraphError: deny){ + id + symbol + nft { + name + symbol + address + } + name + symbol + cap + isDatatoken + holderCount + orderCount + orders(skip:0,first:1){ + amount + serviceIndex + payer { + id + } + consumer{ + id + } + estimatedUSDValue + lastPriceToken + lastPriceValue + } + } + fixedRateExchanges(subgraphError:deny){ + id + price + active + } +}` + +const baseUrl = "https://v4.subgraph.mainnet.oceanprotocol.com" +const route = "/subgraphs/name/oceanprotocol/ocean-subgraph" + +const url = `${baseUrl}${route}` + +var config = { + method: 'post', + url: url, + headers: { "Content-Type": "application/json" }, + data: JSON.stringify({ "query": query }) +}; + +axios(config) + .then(function (response) { + console.log(JSON.stringify(response.data)); + }) + .catch(function (error) { + console.log(error); + }); + ``` -python datatoken_information.py +{% endcode %} + +#### Execute script + +```bash +node datatokenInfo.js ``` {% endtab %} {% endtabs %} +#### Response +
Sample response diff --git a/building-with-ocean/using-ocean-subgraph/list-data-nfts.md b/building-with-ocean/using-ocean-subgraph/list-data-nfts.md index 0fc994a93..69e310819 100644 --- a/building-with-ocean/using-ocean-subgraph/list-data-nfts.md +++ b/building-with-ocean/using-ocean-subgraph/list-data-nfts.md @@ -6,6 +6,8 @@ The result of following GraphQL query returns the information about data nfts. Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](./#ocean-subgraph-graphiql). {% endhint %} +#### Query + ```graphql { nfts (skip:0, first: 10, subgraphError:deny){ @@ -22,10 +24,14 @@ Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprot } ``` -The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. +#### Code snippets {% tabs %} {% tab title="Python" %} +The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. + +#### Create script + {% code title="list_dataNFTs.py" %} ```python import requests @@ -68,8 +74,62 @@ print(json.dumps(result, indent=4, sort_keys=True)) python list_dataNFTs.py ``` {% endtab %} + +{% tab title="Javascript" %} +The javascript below can be used to run the the query. If you wish to change the network, then replace the value of variable `baseUrl` as needed. + +#### Create script + +{% code title="listDatatoken.js" %} +```javascript +var axios = require('axios'); + +const query = `{ + nfts (skip:0, first: 10, subgraphError:deny){ + id + name + symbol + owner + address + assetState + tx + block + transferable + } +}` + +const baseUrl = "https://v4.subgraph.mainnet.oceanprotocol.com" +const route = "/subgraphs/name/oceanprotocol/ocean-subgraph" + +const url = `${baseUrl}${route}` + +var config = { + method: 'post', + url: url, + headers: { "Content-Type": "application/json" }, + data: JSON.stringify({ "query": query }) +}; + +axios(config) + .then(function (response) { + console.log(JSON.stringify(response.data)); + }) + .catch(function (error) { + console.log(error); + }); +``` +{% endcode %} + +#### Execute script + +```bash +node listDatatoken.js +``` +{% endtab %} {% endtabs %} +#### Response +
Sample response diff --git a/building-with-ocean/using-ocean-subgraph/list-datatokens.md b/building-with-ocean/using-ocean-subgraph/list-datatokens.md index afbdba1c0..3a6dc6a7e 100644 --- a/building-with-ocean/using-ocean-subgraph/list-datatokens.md +++ b/building-with-ocean/using-ocean-subgraph/list-datatokens.md @@ -6,6 +6,8 @@ The result of following GraphQL query returns the information about datatokens. Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](./#ocean-subgraph-graphiql). {% endhint %} +#### Query + ```graphql { tokens(skip:0, first: 2, subgraphError: deny){ @@ -39,10 +41,12 @@ Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprot } ``` -The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. +#### Code {% tabs %} {% tab title="Python" %} +The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. + **Create script** {% code title="list_all_tokens.py" %} @@ -104,8 +108,79 @@ print(json.dumps(result, indent=4, sort_keys=True)) python list_all_tokens.py ``` {% endtab %} + +{% tab title="Javascript" %} +The javascript below can be used to run the the query. If you wish to change the network, then replace the value of variable `baseUrl` as needed. + +#### Create script + +{% code title="listAllTokens.js" %} +```javascript +var axios = require('axios'); + +const query = `{ + tokens(skip:0, first: 2, subgraphError: deny){ + id + symbol + nft { + name + symbol + address + } + name + symbol + cap + isDatatoken + holderCount + orderCount + orders(skip:0,first:1){ + amount + serviceIndex + payer { + id + } + consumer{ + id + } + estimatedUSDValue + lastPriceToken + lastPriceValue + } + } +}` + +const baseUrl = "https://v4.subgraph.mainnet.oceanprotocol.com" +const route = "/subgraphs/name/oceanprotocol/ocean-subgraph" + +const url = `${baseUrl}${route}` + +var config = { + method: 'post', + url: url, + headers: { "Content-Type": "application/json" }, + data: JSON.stringify({ "query": query }) +}; + +axios(config) + .then(function (response) { + console.log(JSON.stringify(response.data)); + }) + .catch(function (error) { + console.log(error); + }); +``` +{% endcode %} + +#### Execute script + +```bash +node listAllTokens.js +``` +{% endtab %} {% endtabs %} +#### Response +
Sample Response diff --git a/building-with-ocean/using-ocean-subgraph/list-fixed-rate-exchanges.md b/building-with-ocean/using-ocean-subgraph/list-fixed-rate-exchanges.md index 708df1a26..25c1151f5 100644 --- a/building-with-ocean/using-ocean-subgraph/list-fixed-rate-exchanges.md +++ b/building-with-ocean/using-ocean-subgraph/list-fixed-rate-exchanges.md @@ -6,6 +6,8 @@ The result of following GraphQL query returns the information about the Fixed Ra Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](./#ocean-subgraph-graphiql). {% endhint %} +#### Query + ```graphql { fixedRateExchanges(skip:0, first:2, subgraphError:deny){ @@ -42,10 +44,12 @@ Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprot } ``` -The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. +#### Code {% tabs %} {% tab title="Python" %} +The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. + **Create script** {% code title="list_fixed_rate_exchanges.py" %} @@ -56,7 +60,7 @@ import json query = """ { - fixedRateExchanges(skip:0, first:2, subgraphError:deny){ + fixedRateExchanges(skip:0, first:2, subgraphError:deny){ id contract exchangeId @@ -110,8 +114,82 @@ print(json.dumps(result, indent=4, sort_keys=True)) python list_fixed_rate_exchanges.py ``` {% endtab %} + +{% tab title="Javascript" %} +The javascript below can be used to run the the query. If you wish to change the network, then replace the value of variable `baseUrl` as needed. + +#### Create script + +{% code title="listFRE.js" %} +```javascript +var axios = require('axios'); + +const query = `{ + fixedRateExchanges(skip:0, first:2, subgraphError:deny){ + id + contract + exchangeId + owner{id} + datatoken{ + id + name + symbol + } + price + datatokenBalance + active + totalSwapValue + swaps(skip:0, first:1){ + tx + by { + id + } + baseTokenAmount + dataTokenAmount + createdTimestamp + } + updates(skip:0, first:1){ + oldPrice + newPrice + newActive + createdTimestamp + tx + } + } +}` + +const baseUrl = "https://v4.subgraph.mainnet.oceanprotocol.com" +const route = "/subgraphs/name/oceanprotocol/ocean-subgraph" + +const url = `${baseUrl}${route}` + +var config = { + method: 'post', + url: url, + headers: { "Content-Type": "application/json" }, + data: JSON.stringify({ "query": query }) +}; + +axios(config) + .then(function (response) { + console.log(JSON.stringify(response.data)); + }) + .catch(function (error) { + console.log(error); + }); +``` +{% endcode %} + +#### Execute script + +```bash +node listFRE.js +``` +{% endtab %} {% endtabs %} +#### Response +
Sample response