@quested/sdk
v0.2.0
Published
[](./LICENSE) [](https://bundlephobia.com/package/@quested/sdk) [;
</script>Usage
Initializing the SDK
import { init } from '@quested/sdk';
// Normal mode (communicates with parent frame)
const sdk = init({
activityId: 'my-activity-id',
onReady: () => {
console.log('SDK is ready');
// Start your game or activity here
}
});Working with Player Profiles
// Get the current player's profile
const profile = await sdk.api.player.me();
console.log(`Hello, ${profile.publicName}!`);
// Update a profile specification
await sdk.api.player.updateProfileSpecification('skill_level', 'intermediate');Storing Game State
// Save game progress
await sdk.api.player.setGameProperty('current_level', '5');
await sdk.api.player.setGameProperty('score', '1250');
// Retrieve saved data
const level = await sdk.api.player.getGameProperty('current_level');
const score = await sdk.api.player.getGameProperty('score');Tracking Player Events
// Track when a player completes a level
await sdk.api.player.trackEvent('event:activityEnded', {
durationInSeconds: 120,
mistakes: 2,
answers: 10
});
// Track custom events
await sdk.api.player.trackEvent('quest:levelCompleted', {
level: 5,
score: 1250,
timeSpent: 120
});Working with Lists
// Get all available lists
const lists = await sdk.api.player.getAllLists();
const favorites = lists.find(list => list.id === 'favorites');
// Add an item to a list
await sdk.api.player.addToList('favorites', 'item-123');
// Remove an item from a list
await sdk.api.player.removeFromList('favorites', 'item-456');Local Development Mode
The SDK supports a local development mode that stores all data in the browser's localStorage instead of communicating with an external application. This is useful for:
- Developing and testing your app without needing to run the full Quested platform
- Prototyping new features in isolation
- Debugging specific scenarios with controlled data
// Local development mode (stores data in localStorage)
const sdk = init({
activityId: 'my-activity-id',
mode: 'local', // Uses localStorage instead of postMessage
onReady: () => {
console.log('SDK is ready in local mode');
// Test your game or activity here
}
});When in local mode:
- All data is persisted in localStorage with the prefix
quested_sdk_ - Default profile and list data is created automatically
- No postMessage communication occurs with parent frames
- All API calls work identically to production mode
Configuration Options
The init function accepts the following options:
| Option | Type | Required | Description |
|--------|------|----------|-------------|
| activityId | string | Yes | Unique identifier for your activity |
| mode | 'bridge' | 'local' | No | Operation mode (default: 'bridge') |
| onReady | () => void | No | Callback executed when SDK is initialized |
| logLevel | LogLevel | No | Controls logging verbosity |
| logger | ILogger | No | Custom logger implementation |
Advanced Usage
Error Handling
All API methods return Promises, allowing you to implement error handling:
try {
await sdk.api.player.setGameProperty('level', '10');
} catch (error) {
console.error('Failed to save game property:', error);
}Integration with Game Frameworks
The SDK works seamlessly with popular game frameworks:
// Example with Phaser
class GameScene extends Phaser.Scene {
async create() {
// Load player progress when scene starts
const level = await sdk.api.player.getGameProperty('level') || '1';
this.currentLevel = parseInt(level, 10);
// Set up the level
this.setupLevel(this.currentLevel);
}
async completeLevel() {
// Save progress and track completion
await sdk.api.player.setGameProperty('level', (this.currentLevel + 1).toString());
await sdk.api.player.trackEvent('quest:levelCompleted', {
level: this.currentLevel,
stars: this.stars
});
}
}Integrating Your Game with Quested
Once you've built your game using the SDK, follow these steps to publish it on the Quested platform:
- Development & Testing: Fully test your game using the local development mode.
- Contact Quested: Email [email protected] to start the publishing process.
- Submission: The Quested team will provide details on how to submit your game for review.
- Review Process: Your game will be reviewed for quality and educational value.
- Publication: Once approved, your game will be published on Quested.io and made available to the public.
About the Quested Ecosystem
Quested is the Steam of educational gaming - a platform where:
- Game Developers can create and publish educational games without worrying about backend infrastructure, user management, or distribution
- Students can discover and play games that make learning engaging and effective
- Teachers can assign specific games and track student progress through detailed analytics
Platform Benefits
By integrating your game with Quested, you gain access to:
AI-Generated Game Levels
Provide a schema for your game levels, and Quested's AI can automatically generate custom content tailored to specific learning objectives or difficulty levels.
Leaderboards
Built-in competitive features that encourage engagement and replay value.
Level Library
A growing collection of user-created and AI-generated levels for your game that extends its educational value and replayability.
Analytics & Insights
Comprehensive data on how students interact with your game, helping you improve and iterate.
Distribution
Reach educational institutions and individual learners through Quested's growing platform.
Documentation
For detailed API documentation, see Documentation generated from source files by Typedoc.
License
Released under MIT License.
