ocean-subgraph/examples/python/global-statistics.md
Akshay 6e2daf6ee0
Feature/examples (#261)
* Feature: Ocean-subgraph javascript and python examples

* Feature: Ocean-subgraph example add credit

* Rename js example file

* Feature: Add ocean-subgraph python example
2021-11-02 12:48:34 +01:00

35 lines
654 B
Markdown

## Ocean-subgraph python example
Query global statistics like `totalValueLocked`, `totalOceanLiquidity`, `orderCount`, etc.
```python
import requests
import json
base_url = "https://subgraph.rinkeby.oceanprotocol.com"
route = "/subgraphs/name/oceanprotocol/ocean-subgraph"
url = base_url + route
query = """
{
globals {
id
totalValueLocked
totalOceanLiquidity
totalSwapVolume
totalOrderVolume
orderCount
poolCount
}
}"""
headers = {"Content-Type": "application/json"}
payload = json.dumps({"query": query})
response = requests.request("POST", url, headers=headers, data=payload)
result = json.loads(response.text)
print(result)
```