GithubHelp home page GithubHelp logo

Comments (1)

deeredman1991 avatar deeredman1991 commented on June 24, 2024

The issue was on my end (sort of) I needed to add "Content-Type": "application/json" to the headers and it started working almost how you would expect. The only reason why I say "sort of" is because the "total" is still 100.

Anyway I cleaned up the code a little so it looks a little different but here is my fix for anyone else having the same issue.

import requests
import json


def getRequest( frm=0, size=20 ):
    return requests.post( 'https://graphql-gateway.axieinfinity.com/graphql', json={
        "headers": {
            "operation": "GetRecentlyAxiesSold",
            "Content-Type": "application/json"
        }, 
        "query": '''
            query GetRecentlyAxiesSold($from: Int, $size: Int) {
                settledAuctions {
                    axies(from: $from, size: $size) {
                        total
                        results {
                            ...AxieSettledBrief
                        }
                    }
                }
            }

            fragment AxieSettledBrief on Axie {
                id
            }
        ''',
        "variables": {
            "from": frm, 
            "size": size
        }}
    )

x, y = [getRequest(frm = 40, size = 5).json()["data"]["settledAuctions"]["axies"], 
        getRequest(frm = 0, size = 5).json()["data"]["settledAuctions"]["axies"]]

total = int(x["total"])
results_x, results_y = [ x["results"], y["results"] ]
id_x, id_y = [ results_x[0]['id'], results_y[0]['id'] ]

#Size Test
#assert ( total == 5 )
assert ( len(results_x) <= 5 )

#From Test
assert ( id_x != id_y )

from axie-graphql-documentation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.