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

GITBOOK-242: Updated get datatoken information

This commit is contained in:
Ana Loznianu 2023-05-23 17:10:38 +00:00 committed by gitbook-bot
parent 1ea6904099
commit 2239ff66ca
No known key found for this signature in database
GPG Key ID: 07D2180C7B12D0FF
5 changed files with 215 additions and 236 deletions

View File

@ -45,7 +45,7 @@
* [Get data NFTs](developers/using-ocean-subgraph/list-data-nfts.md) * [Get data NFTs](developers/using-ocean-subgraph/list-data-nfts.md)
* [Get data NFT Information](developers/using-ocean-subgraph/get-data-nft-information.md) * [Get data NFT Information](developers/using-ocean-subgraph/get-data-nft-information.md)
* [Get datatokens](developers/using-ocean-subgraph/list-datatokens.md) * [Get datatokens](developers/using-ocean-subgraph/list-datatokens.md)
* [Get Datatoken Information](developers/using-ocean-subgraph/get-datatoken-information.md) * [Get datatoken Information](developers/using-ocean-subgraph/get-datatoken-information.md)
* [List Fixed Rate Exchanges](developers/using-ocean-subgraph/list-fixed-rate-exchanges.md) * [List Fixed Rate Exchanges](developers/using-ocean-subgraph/list-fixed-rate-exchanges.md)
* [Ocean.py](developers/ocean.py/README.md) * [Ocean.py](developers/ocean.py/README.md)
* [Page 1](developers/ocean.py/page-1.md) * [Page 1](developers/ocean.py/page-1.md)

View File

@ -12,15 +12,19 @@ Now that you are familiar with the process of retrieving a list of data NFTs
The result of the following GraphQL query returns the information about a particular data NFT. In this example, `0x1c161d721e6d99f58d47f709cdc77025056c544c`. The result of the following GraphQL query returns the information about a particular data NFT. In this example, `0x1c161d721e6d99f58d47f709cdc77025056c544c`.
PS: In this example, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to [this table](../ocean-subgraph/#ocean-subgraph-deployments). _PS: In this example, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to_ [_this table_](../ocean-subgraph/#ocean-subgraph-deployments)_._
{% tabs %} {% tabs %}
{% tab title="Query" %} {% tab title="Javascript" %}
Copy the query to fetch the information about a data NFT in the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql). If you want to fetch the information about another NFT, replace the `id` with the address of your choice. The javascript below can be used to run the query and fetch the information of a data NFT. If you wish to change the network, replace the variable's value `network` as needed. Change the value of the variable `datanftAddress` with the address of your choice.
```graphql ```runkit nodeVersion="18.x.x"
{ var axios = require('axios');
nft (id:"0x1c161d721e6d99f58d47f709cdc77025056c544c", subgraphError:deny){
const datanftAddress = "0x1c161d721e6d99f58d47f709cdc77025056c544c";
const query = `{
nft (id:"${datanftAddress}", subgraphError:deny){
id id
name name
symbol symbol
@ -41,7 +45,25 @@ Copy the query to fetch the information about a data NFT in the Ocean Subgraph [
template template
orderCount orderCount
} }
} }`
const network = "mainnet"
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) {
let result = JSON.stringify(response.data)
console.log(result)
})
.catch(function (error) {
console.log(error);
});
``` ```
{% endtab %} {% endtab %}
@ -103,16 +125,12 @@ print(json.dumps(result, indent=4, sort_keys=True))
</strong></code></pre> </strong></code></pre>
{% endtab %} {% endtab %}
{% tab title="Javascript" %} {% tab title="Query" %}
The javascript below can be used to run the query and fetch the information of a data NFT. If you wish to change the network, replace the variable's value `network` as needed. Change the value of the variable `datanftAddress` with the address of your choice. Copy the query to fetch the information about a data NFT in the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql). If you want to fetch the information about another NFT, replace the `id` with the address of your choice.
```runkit nodeVersion="18.x.x" ```graphql
var axios = require('axios'); {
nft (id:"0x1c161d721e6d99f58d47f709cdc77025056c544c", subgraphError:deny){
const datanftAddress = "0x1c161d721e6d99f58d47f709cdc77025056c544c";
const query = `{
nft (id:"${datanftAddress}", subgraphError:deny){
id id
name name
symbol symbol
@ -133,25 +151,7 @@ const query = `{
template template
orderCount orderCount
} }
}` }
const network = "mainnet"
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) {
let result = JSON.stringify(response.data)
console.log(result)
})
.catch(function (error) {
console.log(error);
});
``` ```
{% endtab %} {% endtab %}
{% endtabs %} {% endtabs %}

View File

@ -1,16 +1,30 @@
# Get Datatoken Information ---
description: >-
Explore the Power of Querying: Unveiling In-Depth Details of Individual
Datatokens
---
The result of following GraphQL query returns the information about a particular datatoken. Here, `0x122d10d543bc600967b4db0f45f80cb1ddee43eb` is the address of the datatoken. # Get datatoken Information
{% hint style="info" %} To fetch detailed information about a specific datatoken, you can utilize the power of GraphQL queries. By constructing a query tailored to your needs, you can access key parameters such as the datatoken's ID, name, symbol, total supply, creator, and associated dataTokenAddress. This allows you to gain a deeper understanding of the datatoken's characteristics and properties. With this information at your disposal, you can make informed decisions, analyze market trends, and explore the vast potential of datatokens within the Ocean ecosystem. Harness the capabilities of GraphQL and unlock a wealth of datatoken insights.
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/#ocean-subgraph-graphiql).
{% endhint %}
#### Query
```graphql
{ The result of the following GraphQL query returns the information about a particular datatoken. Here, `0x122d10d543bc600967b4db0f45f80cb1ddee43eb` is the address of the datatoken.
token(id:"0x122d10d543bc600967b4db0f45f80cb1ddee43eb", subgraphError: deny){
_PS: In this example, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to_ [_this table_](../ocean-subgraph/#ocean-subgraph-deployments)_._
{% tabs %}
{% tab title="Javascript" %}
The javascript below can be used to run the query and fetch the information of a datatoken. If you wish to change the network, replace the variable's value `network` as needed. Change the value of the variable `datatokenAddress` with the address of your choice.
```runkit nodeVersion="18.x.x"
var axios = require('axios');
const datatokenAddress = "0x122d10d543bc600967b4db0f45f80cb1ddee43eb";
const query = `{
token(id:"${datatokenAddress}", subgraphError: deny){
id id
symbol symbol
nft { nft {
@ -43,14 +57,30 @@ Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprot
price price
active active
} }
} }`
const network = "mainnet"
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) {
let result = JSON.stringify(response.data)
console.log(result);
})
.catch(function (error) {
console.log(error);
});
``` ```
{% endtab %}
#### Code
{% tabs %}
{% tab title="Python" %} {% 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. The Python script below can be used to run the query and fetch a datatoken information. If you wish to change the network, replace the variable's value `base_url` as needed. Change the value of the variable `datatoken_address` with the address of the datatoken of your choice.
**Create script** **Create script**
@ -119,19 +149,10 @@ print(json.dumps(result, indent=4, sort_keys=True))
</strong></code></pre> </strong></code></pre>
{% endtab %} {% endtab %}
{% tab title="Javascript" %} {% tab title="Query" %}
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** token(id:"0x122d10d543bc600967b4db0f45f80cb1ddee43eb", subgraphError: deny){
{% code title="datatokenInfo.js" %}
```javascript
var axios = require('axios');
const datatokenAddress = "0x122d10d543bc600967b4db0f45f80cb1ddee43eb";
const query = `{
token(id:"${datatokenAddress}", subgraphError: deny){
id id
symbol symbol
nft { nft {
@ -164,35 +185,7 @@ const query = `{
price price
active 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);
});
```
{% endcode %}
**Execute script**
```bash
node datatokenInfo.js
``` ```
{% endtab %} {% endtab %}
{% endtabs %} {% endtabs %}

View File

@ -16,26 +16,42 @@ There are several options available to see this query in action. Below, you will
2. Execute the query in Python by following the code snippet. 2. Execute the query in Python by following the code snippet.
3. Execute the query in JavaScript by clicking on the "Run" button of the Javascript tab. 3. Execute the query in JavaScript by clicking on the "Run" button of the Javascript tab.
PS: In these examples, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to [this table](../ocean-subgraph/#ocean-subgraph-deployments). _PS: In these examples, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to_ [_this table_](../ocean-subgraph/#ocean-subgraph-deployments)_._
{% tabs %} {% tabs %}
{% tab title="Query" %} {% tab title="Javascript" %}
Copy the query 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). The javascript below can be used to run the query and retrieve a list of NFTs. If you wish to change the network, then replace the value of `network` variable as needed.
```graphql ```runkit nodeVersion="18.x.x"
{ const axios = require('axios')
nfts (skip:0, first: 10, subgraphError:degraphny){
id const query = `{
name nfts (skip:0, first: 10, subgraphError:deny){
symbol id
owner name
address symbol
assetState owner
tx address
block assetState
transferable tx
} block
transferable
}
}`
const network = "mainnet"
const 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 })
} }
const response = await axios(config)
for (let nft of response.data.data.nfts) {
console.log(' id:' + nft.id + ' name: ' + nft.name + ' address: ' + nft.address)
}
``` ```
{% endtab %} {% endtab %}
@ -87,39 +103,23 @@ python list_dataNFTs.py
``` ```
{% endtab %} {% endtab %}
{% tab title="Javascript" %} {% tab title="Query" %}
The javascript below can be used to run the query and retrieve a list of NFTs. If you wish to change the network, then replace the value of `network` variable as needed. Copy the query 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).
```runkit nodeVersion="18.x.x" ```graphql
const axios = require('axios') {
nfts (skip:0, first: 10, subgraphError:degraphny){
const query = `{ id
nfts (skip:0, first: 10, subgraphError:deny){ name
id symbol
name owner
symbol address
owner assetState
address tx
assetState block
tx transferable
block }
transferable
}
}`
const network = "mainnet"
const 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 })
} }
const response = await axios(config)
for (let nft of response.data.data.nfts) {
console.log(' id:' + nft.id + ' name: ' + nft.name + ' address: ' + nft.address)
}
``` ```
{% endtab %} {% endtab %}
{% endtabs %} {% endtabs %}

View File

@ -4,54 +4,72 @@ description: 'Discover the World of datatokens: Retrieving a List of datatokens'
# Get datatokens # Get datatokens
The result of following GraphQL query returns the information about datatokens. With your newfound knowledge of fetching data NFTs and retrieving the associated information, fetching a list of datatokens will be a breeze :ocean:. Building upon your understanding, let's now delve into the process of retrieving a list of datatokens. By applying similar techniques and leveraging the power of GraphQL queries, you'll be able to effortlessly navigate the landscape of datatokens and access the wealth of information they hold. So, let's dive right in and unlock the potential of exploring datatokens with ease and efficiency.
{% 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 use [this table](../ocean-subgraph/#ocean-subgraph-graphiql).
{% endhint %}
#### Query
#### Code _PS: In this example, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to_ [_this table_](../ocean-subgraph/#ocean-subgraph-deployments)_._
{% tabs %} {% tabs %}
{% tab title="Query" %} {% tab title="Javascript" %}
```graphql The javascript below can be used to run the query. If you wish to change the network, replace the variable's value `network` as needed.&#x20;
{
tokens(skip:0, first: 2, subgraphError: deny){ ```runkit nodeVersion="18.x.x"
id var axios = require('axios');
symbol
nft { const query = `{
tokens(skip:0, first: 2, subgraphError: deny){
id
symbol
nft {
name
symbol
address
}
name name
symbol symbol
address cap
} isDatatoken
name holderCount
symbol orderCount
cap orders(skip:0,first:1){
isDatatoken amount
holderCount serviceIndex
orderCount payer {
orders(skip:0,first:1){ id
amount }
serviceIndex consumer{
payer { id
id }
estimatedUSDValue
lastPriceToken
lastPriceValue
} }
consumer{
id
}
estimatedUSDValue
lastPriceToken
lastPriceValue
} }
} }`
}
const network = "mainnet"
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) {
let result = JSON.stringify(response.data)
console.log(result);
})
.catch(function (error) {
console.log(error);
});
``` ```
{% endtab %} {% endtab %}
{% tab title="Python" %} {% 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. The Python script below can be used to run the query and fetch a list of datatokens. If you wish to change the network, then replace the value of the variable `base_url` as needed.
**Create script** **Create script**
@ -115,72 +133,40 @@ python list_all_tokens.py
``` ```
{% endtab %} {% endtab %}
{% tab title="Javascript" %} {% tab title="Query" %}
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. Copy the query to fetch a list of datatokens in the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql).&#x20;
**Create script** ```graphql
{
{% code title="listAllTokens.js" %} tokens(skip:0, first: 2, subgraphError: deny){
```javascript id
var axios = require('axios'); symbol
nft {
const query = `{
tokens(skip:0, first: 2, subgraphError: deny){
id
symbol
nft {
name
symbol
address
}
name name
symbol symbol
cap address
isDatatoken
holderCount
orderCount
orders(skip:0,first:1){
amount
serviceIndex
payer {
id
}
consumer{
id
}
estimatedUSDValue
lastPriceToken
lastPriceValue
}
} }
}` name
symbol
const baseUrl = "https://v4.subgraph.mainnet.oceanprotocol.com" cap
const route = "/subgraphs/name/oceanprotocol/ocean-subgraph" isDatatoken
holderCount
const url = `${baseUrl}${route}` orderCount
orders(skip:0,first:1){
var config = { amount
method: 'post', serviceIndex
url: url, payer {
headers: { "Content-Type": "application/json" }, id
data: JSON.stringify({ "query": query }) }
}; consumer{
id
axios(config) }
.then(function (response) { estimatedUSDValue
console.log(JSON.stringify(response.data)); lastPriceToken
}) lastPriceValue
.catch(function (error) { }
console.log(error); }
}); }
```
{% endcode %}
**Execute script**
```bash
node listAllTokens.js
``` ```
{% endtab %} {% endtab %}
{% endtabs %} {% endtabs %}