Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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
Expand Down Expand Up @@ -85,12 +91,77 @@ print(json.dumps(result, indent=4, sort_keys=True))

**Execute script**

<pre class="language-bash"><code class="lang-bash"><strong>python dataNFT_information.py</strong></code></pre>
{% 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

<details>

<summary>Sample response</summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Get datatoken information

# Get Datatoken Information

The result of following GraphQL query returns the information about a particular datatoken. Here, `0x122d10d543bc600967b4db0f45f80cb1ddee43eb` is the address of the datatoken. &#x20;
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 use [this table](./#ocean-subgraph-graphiql).
{% endhint %}

#### Query

```graphql
{
token(id:"0x122d10d543bc600967b4db0f45f80cb1ddee43eb", subgraphError: deny){
Expand Down Expand Up @@ -45,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" %}
Expand Down Expand Up @@ -112,12 +115,89 @@ print(json.dumps(result, indent=4, sort_keys=True))

**Execute script**

<pre class="language-bash"><code class="lang-bash"><strong>python datatoken_information.py</strong></code></pre>
{% 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

<details>

<summary>Sample response</summary>
Expand Down
62 changes: 61 additions & 1 deletion building-with-ocean/using-ocean-subgraph/list-data-nfts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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
Expand Down Expand Up @@ -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

<details>

<summary>Sample response</summary>
Expand Down
Loading