Introduction

Add play tracking to your app

retroshelf's API lets your emulator, launcher, or app record what a player plays to their retroshelf activity. When a play session ends, send the game, play time, and timestamp, and retroshelf logs it automatically.

Begin by applying for a client ID. Once approved, link players with the device-code flow and send completed play sessions in the background.

Authentication

Device flow overview

1

Request a device code with your approved client ID.

2

Show the user code and verification URL to the user.

3

Poll the token endpoint until the user approves access.

4

Send the bearer token with completeLink and syncSessions.

POST/api/auth/device/code

Request a device code

Creates a short user code and verification URL for the OAuth device flow.

FieldTypeRequiredDescription
client_idstringYesThe client ID issued after your integration application is approved.

Request

{
  "client_id": "rs_your_client_id"
}

Response

{
  "device_code": "internal-device-code",
  "user_code": "483921",
  "verification_uri": "https://retroshelf.org/link",
  "expires_in": 1800,
  "interval": 5
}
POST/api/auth/device/token

Poll for an access token

Poll at the returned interval until the user approves the code.

FieldTypeRequiredDescription
grant_typestringYesUse urn:ietf:params:oauth:grant-type:device_code.
device_codestringYesThe internal device code returned by the device-code endpoint.
client_idstringYesThe same approved client ID used to request the device code.

Request

{
  "grant_type": "urn:ietf:params:oauth:grant-type:device_code",
  "device_code": "internal-device-code",
  "client_id": "rs_your_client_id"
}

Response

{
  "access_token": "bearer_access_token",
  "token_type": "Bearer"
}
POST/api/syncClient/syncSessions

Upload play sessions

Sends completed play sessions. Offline clients should queue sessions locally and retry with the same values.

Authorization: Bearer access_token

FieldTypeRequiredDescription
syncClientIdstringYesThe sync client ID returned by completeLink.
sessions[].romPathstringYesThe path or filename available to the emulator or launcher.
sessions[].durationnumberYesSession length in seconds.
sessions[].devicePlayedAtnumberYesUnix timestamp, in seconds, for when the session happened on the device.
sessions[].romNamestringNoClean game name when available. Used before falling back to romPath matching.
sessions[].romHashstringNoROM hash when available.
sessions[].platformHintstringNoConsole or platform hint, such as snes, gba, psx, or arcade.

Request

{
  "syncClientId": "sync_client_id_from_completeLink",
  "sessions": [
    {
      "romPath": "Roms/SFC/Chrono Trigger.sfc",
      "romName": "Chrono Trigger",
      "romHash": "optional-rom-hash",
      "duration": 5400,
      "devicePlayedAt": 1781229600,
      "platformHint": "snes"
    }
  ]
}

Response

{
  "synced": 1,
  "matched": 1,
  "unmatched": 0,
  "results": [
    {
      "romPath": "Roms/SFC/Chrono Trigger.sfc",
      "matched": true,
      "gameId": "game_id",
      "gameName": "Chrono Trigger"
    }
  ]
}
retroshelf deduplicates by sync client, ROM path, played-at timestamp, and duration. Retrying the same queued session is safe.