PocketPass API

Read and write PocketPass user data with their permission. Access is controlled via OAuth 2.0.

https://pocketpass.xyz/functions/v1/api-v1

Overview

The PocketPass API gives third-party apps access to user profiles, encounter history, friend lists, leaderboards, and more. All requests require an OAuth access token scoped to the data you need.

The API follows REST conventions: JSON request/response bodies, standard HTTP methods, and meaningful status codes.

Authentication

1. Register your app

Go to the Developer Dashboard, sign in, and create an app. You'll receive a client_id and client_secret.

2. Redirect user to authorize

// Send the user here
https://dev.pocketpass.xyz/authorize
  ?client_id=YOUR_CLIENT_ID
  &scopes=read:profile,read:encounters
  &redirect_uri=https://yourapp.com/callback

The user logs in and approves the requested scopes, then gets redirected back with an authorization code:

https://yourapp.com/callback?code=AUTH_CODE

3. Exchange code for token

POST https://pocketpass.xyz/functions/v1/api-token

{
  "client_id": "your_client_id",
  "client_secret": "your_client_secret",
  "code": "AUTH_CODE"
}

Response:

{
  "access_token": "abc-123-...",
  "token_type": "Bearer",
  "expires_in": 2592000,
  "scopes": ["read:profile", "read:encounters"]
}

Tokens expire after 30 days. Re-authorize the user to get a new one.

PKCE (recommended for public clients)

For mobile apps and SPAs, use PKCE to prevent authorization code interception:

// 1. Generate code_verifier (random 43-128 char string)
// 2. Compute code_challenge = base64url(SHA-256(code_verifier))
// 3. Add code_challenge to authorize URL
?client_id=...&scopes=...&code_challenge=HASH

// 4. Include code_verifier in token exchange
{ "code_verifier": "ORIGINAL", ... }

State parameter

Pass a random state value in the authorize URL. It's returned in the redirect so you can verify the response.

4. Make API calls

GET /me
Authorization: Bearer YOUR_ACCESS_TOKEN

Scopes

ScopeAccess
read:profileName, avatar, origin, age, greeting, mood, games, friend code, stats
read:encountersEncounter history with other users
read:friendsFriend list with basic profile info
read:leaderboardGlobal leaderboard rankings
read:spotpassSpotPass items and active events
write:profileUpdate greeting and mood
write:messagesSend messages to friends

Profile

GET /me read:profile

Returns the authorized user's profile.

{
  "id": "312c8f81-ae71-...",
  "user_name": "simply0004",
  "avatar_hex": "AwEA...",
  "greeting": "Hello!",
  "mood": "HAPPY",
  "origin": "Sweden",
  "age": "18",
  "hobbies": "Gaming",
  "is_male": true,
  "friend_code": "56814231",
  "selected_games": ["Animal Crossing", "Mario Kart"],
  "token_balance": 42,
  "puzzle_progress": { ... }
}
PUT /profile write:profile

Update the user's greeting or mood. Only the fields you send are updated.

{
  "greeting": "Hey there!",
  "mood": "EXCITED"
}

Valid moods: HAPPY, SAD, EXCITED, SLEEPY, ANGRY, COOL, SHY, CONFUSED

Avatar

GET /me/avatar read:profile

Returns the user's Piip as a PNG image.

ParamDefaultDescription
width270Image width: 128, 256, or 512
typefaceface, face_body, or all_body

Response: image/png binary data.

// Embed in HTML
<img src="https://pocketpass.xyz/functions/v1/api-v1/me/avatar?width=256" />

// Fetch with token
fetch('/me/avatar?width=128', {
  headers: { 'Authorization': 'Bearer TOKEN' }
})
GET /avatar/:userId read:profile

Returns any user's Piip avatar by their user ID. Same query params as /me/avatar.

Encounters

GET /encounters read:encounters

Returns the user's encounter history, sorted newest first.

ParamDefaultDescription
limit50Max 100
offset0Pagination offset
[
  {
    "other_user_id": "uuid",
    "other_user_name": "Nashi",
    "other_user_avatar_hex": "AwEA...",
    "origin": "Japan",
    "greeting": "Hello!",
    "meet_count": 3,
    "timestamp": 1711152000000
  }
]

Friends

GET /friends read:friends

Returns the user's accepted friends with basic profile info.

[
  {
    "id": "uuid",
    "user_name": "Bubbleeey",
    "avatar_hex": "AwEA...",
    "origin": "UK",
    "greeting": "Hi!",
    "mood": "HAPPY",
    "friend_code": "08375706"
  }
]

Leaderboard

GET /leaderboard read:leaderboard

Returns global leaderboard rankings.

ParamDefaultDescription
sorttotal_encountersSort field (see below)
limit50Max 100

Sort options: total_encounters, unique_encounters, unique_regions, puzzles_completed, achievements_unlocked

[
  {
    "user_id": "uuid",
    "user_name": "xevylicious",
    "avatar_hex": "AwEA...",
    "total_encounters": 247,
    "unique_encounters": 189,
    "unique_regions": 14,
    "puzzles_completed": 8,
    "achievements_unlocked": 12
  }
]

SpotPass

GET /spotpass read:spotpass

Returns all published SpotPass items (puzzle panels and events).

[
  {
    "id": "uuid",
    "type": "puzzle_panel",
    "title": "Castle Collection",
    "description": "A medieval castle puzzle",
    "panel_image_url": "https://...",
    "published_at": "2026-03-20T12:00:00Z",
    "expires_at": null
  },
  {
    "id": "uuid",
    "type": "event",
    "title": "Double Token Weekend",
    "event_effect": "{\"type\":\"token_multiplier\",\"value\":2}",
    "published_at": "2026-03-25T00:00:00Z",
    "expires_at": "2026-03-27T00:00:00Z"
  }
]

Messages

POST /messages write:messages

Send a message to a friend. The receiver must be in the user's friend list.

{
  "receiver_id": "friend-uuid",
  "content": "Hello from the API!"
}

Returns 201 Created on success.

Error Codes

StatusMeaning
400Bad request — missing fields or invalid data
401Missing or invalid access token
403Token doesn't have the required scope
404Endpoint or resource not found
429Rate limited
500Server error

Error responses include a JSON body:

{
  "error": "Token does not have the required scope: read:friends"
}

Rate Limits

60 requests per minute per access token. Exceeding this returns 429 with a Retry-After header.

Data Models

Profile

FieldTypeDescription
idUUIDUser ID
user_namestringDisplay name
avatar_hexstringPiip data (base64 studio encoding)
greetingstringPersonal greeting shown on encounter
moodstringCurrent mood emoji
originstringHome region/country
agestringAge (user-set)
hobbiesstringHobbies/interests
is_malebooleanGender for Piip body type
friend_codestring8-digit friend code
selected_gamesJSONList of favorite games
token_balanceintegerCurrent token count

Encounter

FieldTypeDescription
other_user_idUUIDEncountered user's ID
other_user_namestringTheir display name
other_user_avatar_hexstringTheir Piip data
originstringTheir home region
greetingstringTheir greeting at time of encounter
meet_countintegerTimes met this person
timestamplongUnix epoch millis

Leaderboard Entry

FieldTypeDescription
user_idUUIDUser ID
user_namestringDisplay name
total_encountersintegerTotal encounters (including repeats)
unique_encountersintegerUnique people met
unique_regionsintegerDistinct regions encountered
puzzles_completedintegerPuzzle panels completed
achievements_unlockedintegerAchievements earned