keept-sdk
v0.1.4
Published
Lightweight multi-platform user data sync SDK
Downloads
579
Maintainers
Readme
keept-sdk
Lightweight user data sync SDK — set/get/delete key-value data across Web, App, and plugins in 3 lines of code.
Installation
npm install keept-sdkQuick Start
import { KeeptClient } from 'keept-sdk'
const client = new KeeptClient({ baseUrl: 'https://ripple-api.fengwenyi.com/keept' })
// upsert with a known key
await client.set('theme', 'dark')
const theme = await client.get('theme') // 'dark'
// auto-generate a key — returns the generated key
const key = await client.set('hello world')On first use, the SDK automatically registers an account and logs in. Credentials are saved locally (browser: localStorage, Node.js: .keept file) and reused on subsequent calls. Tokens are refreshed automatically.
API
Initialization
const client = new KeeptClient({
baseUrl: 'https://ripple-api.fengwenyi.com/keept',
// Optional: called once after the very first auto-registration.
// Save these credentials — api_secret will NOT be retrievable again.
onRegister(apiKey, apiSecret) {
console.log('api_key :', apiKey)
console.log('api_secret:', apiSecret)
}
})KV Methods
// Write a value with a known key (creates or overwrites)
await client.set('key', 'value')
// Write a value without a key — server auto-generates one and returns it
const generatedKey = await client.set('value')
// Read a value (returns null if not found)
const value = await client.get('key')
// Delete a key (returns true if existed, false otherwise)
await client.delete('key')
// Get key-value pairs (paginated)
const result = await client.page({ page: 1, pageSize: 20 })
// {
// data: [{ key: 'theme', value: 'dark' }, ...],
// total: 42,
// page: 1,
// page_size: 20
// }
// Delete all data
await client.clear()Utilities
// Get the current api_key (returns null if not yet registered)
const apiKey = client.getApiKey()
// Get usage stats
const stats = await client.stats()
// {
// plan: 'free',
// monthly_calls: 42,
// monthly_call_limit: 1000,
// storage_used: 1024,
// storage_limit_bytes: 1048576,
// ...
// }Plans
| Plan | Monthly Calls | Storage | Max Value Size | Price | |-------|--------------|---------|----------------|--------| | Free | 1,000 | 1 MB | 10 KB | $0 | | Indie | 100,000 | 100 MB | 100 KB | $9/mo | | Pro | 1,000,000 | 1 GB | 1 MB | $29/mo |
Free accounts expire after 30 days of inactivity.
Platform Support
| Environment | Credential Storage |
|-------------|-------------------|
| Browser | localStorage |
| Node.js | .keept file |
| Other | In-memory |
Documentation
License
MIT
