mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
6e2daf6ee0
* Feature: Ocean-subgraph javascript and python examples * Feature: Ocean-subgraph example add credit * Rename js example file * Feature: Add ocean-subgraph python example
35 lines
654 B
Markdown
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)
|
|
```
|