Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

Issue with GetRecentlyAxiesSold not working correctly. #46

Closed
deeredman1991 opened this issue Mar 12, 2022 · 1 comment
Closed

Issue with GetRecentlyAxiesSold not working correctly. #46

deeredman1991 opened this issue Mar 12, 2022 · 1 comment

Comments

@deeredman1991
Copy link

deeredman1991 commented Mar 12, 2022

Sending a get/post request to the "GetRecentlyAxiesSold" operation always SAYS that it's returning 100 results but only ACTUALLY returns 20 results always starting from 0 no matter what the "size" and "from" variables are set to.

I wrote a test in python that I simplified to 43 lines to test if the API behaves as I expected it to from reading the documentation. I could be misunderstanding the documentation but if that is the case; then I have no idea what the "from" and "size" variables are supposed to do.

Here are my tests. Please let me know if I am misunderstanding something about how the API is supposed to work and this isn't an actual issue.

import requests
import json


def getRequest( frm=0, size=20 ):
    url = 'https://graphql-gateway.axieinfinity.com/graphql'
    return requests.get( url, params = {
      "operationName": "GetRecentlyAxiesSold",
      "variables": {
        "from": frm,
        "size": size
      },
      "query": '''
        query GetRecentlyAxiesSold($from: Int, $size: Int) {
            settledAuctions {
                axies(from: $from, size: $size) {
                    total
                    results {
                        ...AxieSettledBrief
                    }
                }
            }
        }
        
        fragment AxieSettledBrief on Axie {
            id
        }'''})

x, y = [ getRequest(frm = 40, size = 5), getRequest(frm = 0, size = 5) ]
    
json_data_x = json.loads(x.text)["data"]["settledAuctions"]["axies"]
json_data_y = json.loads(y.text)["data"]["settledAuctions"]["axies"]
    
total = int(json_data_x["total"])
results_x, results_y = [ json_data_x["results"], json_data_y["results"] ]

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

#From Test
id_x, id_y = [ results_x[0]['id'], results_y[0]['id'] ]
assert ( id_x != id_y )
@deeredman1991
Copy link
Author

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 )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant