Quickstart

Learn how to register and manage games, fetch data from the API, and submit points for players.

0. Prerequisites

This guide assumes you've followed the setup guide from the previous page.

1. Register a Game

First, we will register a new game on play.fun:

try {
  const game = await ogp.games.register({
    name: 'My Game Name',
    description: 'A description of more than 10 characters',
    gameUrl: 'https://mygame.com',
    platform: 'HTML', // 'HTML' or 'EXTERNAL_URL'
    isHTMLGame: true, // Optional: Defaults to True
    iframable: true, // Optional: Defaults to True
    twitter: 'https://x.com/mytwitter', // Optional
    discord: 'https://discord.gg/invite', // Optional
    telegram: 'https://t.me/mychannel', // Optional
    maxScorePerSession: 0, // Optional: 0 or null = Unlimited
    maxSessionsPerDay: 0, // Optional: 0 or null = Unlimited
    maxCumulativePointsPerDay: 0, // Optional: 0 or null = Unlimited
    base64Image: '...', // Required if not passing image file
    base64CoverImage: '...', // Optional
  });
  console.log('Game registered:', game.id);
} catch (e) {
  throw e;
}

Interacting with the Game API

Verify Game Ownership

Without claiming game ownership, you will only earn 5% of allocated creator rewards. By claiming ownership, you gain access to the full creator rewards allocation.

To verify game ownership, you will need to embed the following meta tag in the head of your game URL webpage:

Once this is in your webpage head, call the following via the client:

circle-exclamation

2. Submit Points for Players

Use the play module to save points for players from your server. This is the dev endpoint — it's for server-to-server integration where your backend validates gameplay and submits scores.

Single Player

Batch Save (Multiple Players)

Player Identifier Formats

The playerId field supports multiple formats. The system will resolve the identifier to an internal OGP user ID and create users if they don't exist:

Format
Example
Description

Solana wallet

sol:9qdvVLY3v... or solana:9qdvVLY3v...

Looks up/creates user by Solana address

Ethereum wallet

eth:0x123... or ethereum:0x123...

Looks up/creates user by ETH address

Email

Looks up/creates user by email

Twitter/X

twitter:username or x:username

Looks up/creates user by Twitter/X handle

Privy ID

did:privy:abc123

Direct Privy user ID

OGP User ID

550e8400-e29b-41d4-...

Raw UUID — direct internal user ID

circle-info

Performance tip: The response includes a playerIdToOgpId mapping. Cache these mappings and use OGP User IDs (raw UUIDs) in subsequent requests to skip identifier resolution and improve throughput.

circle-exclamation

Response Format

Important Notes

  • Points are cumulative — they add to existing points for the day

  • Only the game owner or creator can save points

  • Points are stored per user, per game, per day

  • Maximum 1000 entries per batch request

  • Rate limit: 3 requests per second

3. Validate Session Tokens

If you're using a hybrid integration (client SDK for auth + server SDK for points), you can validate session tokens sent from the client:

Response Format

Important Notes

  • Session tokens are player_xxx format strings issued by the client SDK

  • Tokens are scoped per-game and expire after 30 minutes

  • The returned ogpId can be used directly as the playerId in savePoints / batchSavePoints for best performance

4. Query Points & Leaderboard

Last updated