Pagination

There may be requests for retrieving large number of records, $SELF names, or referred metadata that have to be converted to .json In this guide, we will look at how to work with paginated responses when querying the SELF API or relaying web3 requests. At this moment and by default, all responses are limited to 15 records. However, we can change the maximum number as high as x ? (to be discussed) by adding a limit parameter as per your requests. If you are using one of the official SELF API client libraries, you don't need to worry about pagination, as we will take care of this for you.

Scores API call

In this example, we request the scores of a virtual game we have created that utilizes the $SELF API in order to identify the actual player and can, for instance, store earned awards or bonuses in attached metadata for this particular $SELF ID. As a result, we get a list of x scores for the past games played.

  • Name
    self
    Type
    string
    Description

    The hashed name of the SELF NFT id. In this case we store as string, however there are more format options.

  • Name
    provider
    Type
    string
    Description

    The sample game or 'provider' that initiates the records.

  • Name
    score
    Type
    integer
    Description

    Actual gamescore that was logged.

Manual pagination using cURL

curl -G https://self-api.com/api/v1/score
  -d limit=3
  -s default=asc

Paginated response

  "data": [
    {
          "id":  1,
          "self":  "davinci",
          "provider": "spaceShip",
          "nft_earned":  "none",
          "score": 23250,
          "stage": 3,
          "bonus": 1,
          "json":  "{}",
          "created_at": "2023-07-20T14:23:31.000000Z",
          "updated_at": "2023-07-20T14:23:31.000000Z"
    },
    {
          "id": 2,
          "self":  "orange",
          "provider": "spaceShip",
          "nft_earned": "none",
          "score": 53900,
          "stage": 5,
          "bonus": 1,
          "json":  "{}",
          "created_at": "2023-07-20T14:25:16.000000Z",
          "updated_at": "2023-07-20T14:25:16.000000Z"
    },
    {
          "id": 3,
          "self":  "mumbai",
          "provider": "spaceShip",
          "nft_earned": "none",
          "score": 66250,
          "stage": 6,
          "bonus": 3,
          "json":  "{}",
          "created_at": "2023-07-20T14:43:14.000000Z",
          "updated_at": "2023-07-20T14:43:14.000000Z"
    }
  ]

List Contract call

In this example, we make two calls. The first call will resolve the wallet address based on the $SELF name. The second call will list all names that have been registered by the repsonse of the first call. As a result, we get an array of all $SELF names we can use in other routines.

Manual call using terminal

/list spiderman

  -d limit=3
  -s default=asc

And then the response may be ;

Custom formatted response

  "data": [
    {"wallet"; "0x333930ab9544Df01211441262510c13D3cc3c0e4"},
    {"names" : ["spiderman","mickemouse","goofy","kenclarke","kermit","ironman","slipknot","hanniballecter"] }
  ]

The responded format can be altered in line with the Dapps requirements.