The official API service for the Open Game System
Open Game API is a Cloudflare Workers application providing the backend services that power the Open Game System (OGS) ecosystem. It implements all the API endpoints defined in the OGS specification, enabling cross-platform features for web games.
- 🔐 Authentication & Account Linking - Connect game accounts with OGS
- 📱 Push Notifications - Send notifications to users across platforms
- 📺 TV Casting Support - Backend for Chromecast functionality
- ⚡ Globally Distributed - Edge computing via Cloudflare Workers
- 🔄 Real-time Updates - WebSocket support for live features
- 🧩 Modular Architecture - Extensible design for future features
The Open Game API is built as a Cloudflare Workers application, offering serverless edge computing with global distribution. The architecture consists of:
- API Routes: RESTful endpoints implementing the OGS specification
- Authentication Layer: JWT-based authentication and authorization
- Storage Layer: Cloudflare KV and D1 for data persistence
- Notification Service: Push notification delivery and tracking
- Cast Service: Chromecast session management
flowchart TD
subgraph "Client SDKs"
AuthKit[auth-kit]
NotificationKit[notification-kit]
CastKit[cast-kit]
end
subgraph "API Endpoints"
AuthAPI[Authentication API]
NotificationAPI[Notification API]
CastAPI[Cast API]
end
subgraph "Core Services"
AuthService[Auth Service]
PushService[Push Service]
CastService[Cast Service]
end
subgraph "Storage"
KV[Cloudflare KV]
D1[Cloudflare D1]
end
AuthKit -->|Requests| AuthAPI
NotificationKit -->|Requests| NotificationAPI
CastKit -->|Requests| CastAPI
AuthAPI -->|Uses| AuthService
NotificationAPI -->|Uses| PushService
CastAPI -->|Uses| CastService
AuthService -->|Stores| KV
PushService -->|Stores| KV
CastService -->|Stores| KV
AuthService -->|Queries| D1
PushService -->|Queries| D1
CastService -->|Queries| D1
The API implements all endpoints defined in the OGS Specification:
POST /api/v1/auth/account-link-token
- Request an account link tokenPOST /api/v1/auth/verify-link-token
- Verify an account link tokenPOST /api/v1/auth/web-code
- Generate a web auth codePOST /api/v1/auth/verify-token
- Verify a web auth tokenPOST /api/v1/auth/refresh
- Refresh an expired session token
POST /api/v1/notifications/send
- Send a notification to usersGET /api/v1/notifications/status/:id
- Get notification delivery statusPOST /api/v1/notifications/register
- Register a device for notifications
POST /api/v1/cast/session
- Create a cast sessionPOST /api/v1/cast/input
- Send input to a cast sessionGET /api/v1/cast/session/:id
- Get cast session statusDELETE /api/v1/cast/session/:id
- End a cast session
- Node.js (v16 or later)
- Wrangler CLI
- Cloudflare account with Workers enabled
- Clone the repository:
git clone https://github.com/open-game-system/opengame-api.git
cd opengame-api
- Install dependencies:
npm install
- Configure local environment:
cp .env.example .env
# Edit .env with your configuration
- Start local development server:
npm run dev
The API will be available at http://localhost:8787
.
Deploy to Cloudflare Workers:
npm run deploy
The API uses JWT-based authentication for secure access:
- API Keys: For server-to-server communication (game servers → OGS)
- Session Tokens: For authenticated user sessions (OGS app → OGS)
Game servers use API keys to access the OGS API:
POST /api/v1/notifications/send HTTP/1.1
Host: api.opengame.org
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{
"recipient": {
"gameUserId": "user-123"
},
"notification": {
"title": "Game Invitation",
"body": "You've been invited to play!"
}
}
User sessions use short-lived JWTs with refresh tokens:
GET /api/v1/cast/session/session-123 HTTP/1.1
Host: api.opengame.org
Authorization: Bearer USER_SESSION_TOKEN
The API uses Cloudflare's storage solutions:
- KV: For high-performance key-value data (tokens, sessions, etc.)
- D1: For relational data (user accounts, device registrations, etc.)
The API implements several security measures:
- Rate Limiting: Prevents abuse of endpoints
- CORS: Controls cross-origin access
- Input Validation: Validates all incoming requests
- Audit Logging: Records security-relevant events
All API endpoints return standardized error responses:
{
"error": {
"code": "invalid_token",
"message": "The provided token is invalid or expired",
"status": 401
}
}
The API collects anonymized usage metrics:
- Request volume per endpoint
- Error rates
- Performance metrics
- Regional distribution
No personally identifiable information is included in analytics.
Contributions are welcome! Please read our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- GitHub Issues: https://github.com/open-game-system/opengame-api/issues
- Discord Community: Join our Discord
- Email Support: hello@opengame.org
Open Game API is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ by the Open Game Collective