Code Examples
JavaScript
import MoonSDK from '@moontraze/sdk';
const moon = new MoonSDK({
projectId: 'YOUR_PROJECT_ID',
apiKey: 'YOUR_API_KEY',
});
const reg = await moon.auth.register('john@example.com', 'secret123', 'John');
moon.setToken(reg.token);
await moon.db.set(`users/${reg.user.id}`, {
name: 'John',
email: 'john@example.com',
});
const upload = await moon.storage.upload(file);
await moon.notifications.sendToProject('YOUR_PROJECT_ID', {
title: 'Hello',
body: 'World',
});Python
from moontraze import MoonSDK, MoonConfig
moon = MoonSDK(MoonConfig(
project_id='YOUR_PROJECT_ID',
api_key='YOUR_API_KEY',
))
result = moon.auth.register('john@example.com', 'secret123', 'John')
moon.set_token(result['token'])
moon.db.set(f"users/{result['user']['id']}", {'name': 'John'})
with open('photo.jpg', 'rb') as f:
upload = moon.storage.upload(f, 'photo.jpg')
moon.notifications.send_to_project('YOUR_PROJECT_ID', title='Hello', body='World')Flutter
final moon = MoonSDK(MoonConfig(
projectId: 'YOUR_PROJECT_ID',
apiKey: 'YOUR_API_KEY',
));
final result = await moon.auth.register('john@example.com', 'secret123', 'John');
moon.setToken(result['token']);
await moon.db.set('users/${result['user']['id']}', {'name': 'John'});
final file = File('photo.jpg');
final upload = await moon.storage.upload(file);
await moon.notifications.sendToProject('YOUR_PROJECT_ID', title: 'Hello', body: 'World');React Native
const moon = new MoonSDK({
projectId: 'YOUR_PROJECT_ID',
apiKey: 'YOUR_API_KEY',
});
const result = await moon.auth.register('john@example.com', 'secret123', 'John');
moon.setToken(result.token!);
await moon.db.set(`users/${result.user?.id}`, { name: 'John' });
await moon.storage.upload({
uri: 'file:///path/to/photo.jpg',
name: 'photo.jpg',
type: 'image/jpeg',
});
await moon.notifications.sendToProject('YOUR_PROJECT_ID', {
title: 'Hello',
body: 'World',
});