I'm using the Daohaus Xdai API (https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus-xdai) to create a dataset of DAOs. What I want to know is how to deal with pagination and get all records?
import json
import requests
def run_query():
q = """
{
moloches {
id
totalShares
totalLoot
}
}
"""
# The Graph DAOhaus xDAI endpoint
response = requests.post(
'https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus-xdai',
'',
json={"query": q}
)
if response.status_code == 200:
result = response.text
daos = []
# put each moloch record into a list
for dao in json.loads(result)['data']['moloches']:
data = dict()
data["dao_hash"] = dao["id"]
daos.append(dao)
# return count of moloch records added to list
return print(len(daos))
else:
raise Exception("Query failed. Return code is {}. {}".format(response.status_code, q))
if __name__ == "__main__":
run_query()
This short example returns 100 records. There are far more DAOs than that on the xDAI network I assume if correct - how does the API handle pagination?
I'm using the Daohaus Xdai API (https://api.thegraph.com/subgraphs/name/odyssy-automaton/daohaus-xdai) to create a dataset of DAOs. What I want to know is how to deal with pagination and get all records?
This short example returns 100 records. There are far more DAOs than that on the xDAI network I assume if correct - how does the API handle pagination?