Skip to content

API Documentation

neobenedict edited this page Jul 31, 2024 · 10 revisions

API

The rayshift API is available at https://rayshift.io/api/v1. It uses a JSON format. The response is in JSON format for all text-based APIs.

Swagger documentation is at https://rayshift.io/api/v1 and may be more up to date than this document.

Rate limit

API end points are rate limited. If you exceed this rate limit, you will receive a response such as:

{
    "status": 429,
    "response": {},
    "message": "rate limit exceeded",
    "wait": 57
}

You should then wait the number of seconds specified before retrying your request.

Public API Endpoints

/support/decks

Endpoint: https://rayshift.io/api/v1/support/decks/{region}/{friendCode}

Request type: GET

Where region is jp or na, and friendcode is a 9 digit friend code.

Example response:

Success:

{
    "status": 200,
    "response": {
        "lastUpdate": 1595864824,
        "name": "Name",
        "code": "123456789",
        "lastLogin": 1595859008,
        "guid": "b4a791ee-6e80-4297-b95d-0d4caf1fdaf5",
        "decksPresent": [
          1,
          2,
          4,
          8,
          16,
          32
        ],
        "decks": {
            "0": "/static/images/deck-gen/jp/123456789/b4a791ee-6e80-4297-b95d-0d4caf1fdaf5/1/1.png",
            "1": "/static/images/deck-gen/jp/123456789/b4a791ee-6e80-4297-b95d-0d4caf1fdaf5/8/1.png"
        }
    },
    "message": "ok"
}

Failure:

{
    "status": 404,
    "response": {},
    "message": "Friend support not found"
}
  • decksPresent shows which decks exist (see documentation below)

Image generation

Endpoint: https://rayshift.io/static/images/deck-gen/{string region}/{int friendId}/{Guid guid}/{int decksToStack}/{int flags}.png

Request type: GET

As of 15th September 2021, the deck image format has changed. The old format is only supported for older images that were previously generated.

  • region is na or jp only
  • guid is a unique reference to a particular lookup returned by the API.
  • decksToStack should be a bitmask of the decks you want stacking. 1/2/4 = Main Deck 1/2/3, 8/16/32 = Event Deck 1/2/3. Eg 1+8 = 9 will give you the first Main Deck and Event Deck stacked.
  • flags should be a bitmask of the following options:
None = 0,
Transparent = 1,
TemplateOnly = 2,
DisableCustomImages = 4,
HighResolution = 8,
NoCommandCodes = 16,
NoAppendSkills = 32

For a transparent, high resolution image with no command codes, you would use 1 + 8 + 16 = 25.

e.g. https://rayshift.io/static/images/deck-gen/jp/123456789/6865c360-1b4b-43c0-b080-0edb5baeea8d/63/9.png generates a full 6 deck image (1+2+4+8+16+32=63), with high resolution and transparency (1+8=9), for a JP friend id 123456789 and deck guid 6865c360-1b4b-43c0-b080-0edb5baeea8d.

Private API Endpoints

These API endpoints require authentication. To authenticate, set apiKey=key in your request. To get an API key, you need to apply for one, please PM Neo#8090 on discord with your use application and endpoints you need to access.

/support/lookup

This endpoint is used to refresh a player's profile.

Endpoint: https://rayshift.io/api/v1/support/lookup

Request Type: GET, POST

Parameters:

region: 1 (JP), 2 (NA)
friendId: 9 digit friend ID

Example request: https://rayshift.io/api/v1/support/lookup?apiKey=key&region=1&friendId=123456799

Response: {"status":200,"response":{},"message":"in queue"}

You should then requery this endpoint every 1-2 seconds until you get a response other than processing or in queue. If you are running a lookup bot, please let us know the IP address for rate limit whitelisting.

  • Status code 503: Server under maintenance
  • Status code 404: User not found
  • Status code 200: Processing / in queue / finished
  • Status code 500: Internal failure

A completed lookup will have message "finished" and return the same response result as the lookup endpoint.

For example:

{
    "status": 200,
    "response": {
        "lastUpdate": 1595976026,
        "name": "Player Name",
        "code": "123456789",
        "lastLogin": 1595959565,
        "guid": "b4a791ee-6e80-4297-b95d-0d4caf1fdaf5",
        "decks": {
            "0": "/static/images/deck-gen/jp/123456789/b4a791ee-6e80-4297-b95d-0d4caf1fdaf5/1/1.png",
            "1": "/static/images/deck-gen/jp/123456789/b4a791ee-6e80-4297-b95d-0d4caf1fdaf5/8/1.png"
        }
        "time": 1595976021425
    },
    "message": "finished"
}