Bug in API /owners endpoint

Hi, moralis is a great product and we are relying more on its API. Recently
i got an error “Rate limit exceed” using this url:
https://deep-index.moralis.io/api/v2/nft/0x4e1f41613c9084fdb9e34e11fae9412427480e56/owners?chain=eth&format=decimal&offset=3000&limit=1

while i get valid response using next offset (3001)
https://deep-index.moralis.io/api/v2/nft/0x4e1f41613c9084fdb9e34e11fae9412427480e56/owners?chain=eth&format=decimal&offset=3001&limit=1

Can you please look into this this? Also, better error messaging would be nice as this error is not related to rate limiting at all. Thanks!

1 Like

team is checking :eyes: will get back

you can use cursor to iterate over pages, this is a python example:

import requests
import json
import base64
import time


def get_nft_owners(offset, cursor):
    print("offset", offset)
    url = 'https://deep-index.moralis.io/api/v2/nft/0x4e1f41613c9084fdb9e34e11fae9412427480e56/owners?chain=eth&format=decimal&offset=%d' % offset
    if cursor:
        url = url + "&cursor=%s" % cursor

    print("api_url", url)
    headers = {
        "Content-Type": "application/json",
        "X-API-Key": "asdfasdfdfs"
    }
    statusResponse = requests.request("GET", url, headers=headers)
    data = statusResponse.json()
    try:
        print("nr results", len(data['result']))
    except:
        print(repr(data))
        print("exiting")
        raise SystemExit

    cursor = data['cursor']
    return cursor


cursor = None
for j in range(10):
    cursor = get_nft_owners(j*500, cursor)
    print()
    time.sleep(1.1)

1 Like

now it should return valid response for offset 3000 too

Thank you guys for a quick response and the fix! :slight_smile:

2 Likes