This quickstart describes a flow to publish & consume GraphQL-style URIs. In our example, the data asset is a query to find data NFTs via ocean-subgraph.
Here are the steps:
- Setup
- Publish dataset
- Consume dataset
Let's go through each step.
Ensure that you've already (a) installed Ocean, and (b) set up locally or remotely.
In the same Python console:
#data info
name = "Data NFTs in Ocean"
url="https://v4.subgraph.goerli.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph"
query="""query{
nfts(orderBy: createdTimestamp,orderDirection:desc){
id
symbol
createdTimestamp
}
}
"""
#create asset
(data_nft, datatoken, ddo) = ocean.assets.create_graphql_asset(name, url, query, {"from": alice})
print(f"Just published asset, with did={ddo.did}")
That's it! You've created a data asset of "GraphqlQuery" asset type. It includes a data NFT, a datatoken for the data NFT, and metadata.
Consume here is just like in consume-flow. The file downloaded is a .json. From that, use the python json
library to parse it as desired.