@nurev/sdk
v1.1.0
Published
Official NUREV Publisher SDK — track installs, earnings, sessions, rewards, and manage payouts
Maintainers
Readme
@nurev/sdk
Official NUREV Publisher SDK. Track installs, earnings, sessions, manage payouts, and build publisher incentive programs.
Install
npm install @nurev/sdkQuick Start
const Nurev = require('@nurev/sdk')
const nurev = new Nurev({ apiKey: 'your-api-key' })
// Authenticate
await nurev.login('[email protected]', 'password')
// Get install stats
const stats = await nurev.installs.getStats('30d')
// Check active sessions
const sessions = await nurev.sessions.getActiveUsers()
// List earnings
const earnings = await nurev.earnings.list({ limit: 20 })Configuration
const nurev = new Nurev({
apiKey: 'your-api-key', // From dashboard → API Keys
baseURL: 'https://api.nurev.io', // Default
timeout: 30000, // Request timeout (ms)
onTokenRefresh: (token, refreshToken) => { // Called when JWT refreshes
// Persist tokens if needed
},
})Authentication
// Login (sets token automatically)
await nurev.login(email, password)
// Or set an existing token
nurev.setToken(savedToken, savedRefreshToken)API Reference
nurev.installs
Track app installs and retention.
// Install chart data for a date range
const chart = await nurev.installs.getChart('2025-01-01', '2025-01-31')
// → { labels: [...], data: [...], installsCount, uninstallsCount }
// Aggregate stats
const stats = await nurev.installs.getStats('30d')
// Retention data
const retention = await nurev.installs.getRetention('7d')nurev.earnings
Query earnings and export data.
// List earnings (paginated)
const earnings = await nurev.earnings.list({
page: 1,
limit: 20,
sort: '-createdAt',
reason: 'Self-running', // 'Self-running' | 'Referral Fee' | 'Master Fee'
})
// → { docs: [...], totalDocs, page, limit, totalPages }
// Export CSV
const csv = await nurev.earnings.exportCSV()
// Quick summary
const summary = await nurev.earnings.getSummary()nurev.sessions
Monitor live time and active sessions.
// Live time data with active users
const live = await nurev.sessions.getLiveTime({
fromDate: '2025-01-01',
toDate: '2025-01-31',
page: 1,
limit: 20,
})
// → { labels, data, current, liveTimeSum, activeUsers }
// Active users summary
const active = await nurev.sessions.getActiveUsers()
// → { current, totalSeconds, users: [...], totalActiveUsers }
// Session chart for date range
const chart = await nurev.sessions.getChart(fromDate, toDate)nurev.users
Manage app users (installs).
// List app users (paginated)
const users = await nurev.users.list({
page: 1,
limit: 20,
search: 'query',
sort: '-createdAt',
})
// → { docs: [{ appUserId, status, balance, latestDuration, createdAt }], ... }
// Get single user details
const user = await nurev.users.get('app-user-id')nurev.apiKeys
Create and manage API keys.
// List keys
const keys = await nurev.apiKeys.list()
// Create a new key
const key = await nurev.apiKeys.create('Production Key', {
expireAt: '2026-01-01T00:00:00Z', // optional
})
// Update key
await nurev.apiKeys.update(keyId, { name: 'Renamed Key' })
// Revoke key
await nurev.apiKeys.revoke(keyId)nurev.withdrawals
Request payouts and track withdrawal status.
// List withdrawals
const withdrawals = await nurev.withdrawals.list({ limit: 10 })
// → { docs: [{ amount, status, currency, address, createdAt }], ... }
// Request crypto payout
await nurev.withdrawals.requestCrypto(amount, 'BTC', 'bc1q...')
// Request fiat payout
await nurev.withdrawals.requestFiat()
// Check withdrawal status
const status = await nurev.withdrawals.getStatus()
// Available currencies
const currencies = await nurev.withdrawals.getCurrencies()
// → [{ name: 'Bitcoin', code: 'BTC' }, ...]nurev.profile
Manage publisher profile.
const profile = await nurev.profile.get()
await nurev.profile.update({ firstName: 'Jane' })
await nurev.profile.changePassword('old', 'new')
await nurev.profile.setPayoutCurrency('ETH')nurev.invites
Referral and invitation management.
// List invites
const invites = await nurev.invites.list()
// Send invite
await nurev.invites.create('[email protected]')
// Resend to pending invite
await nurev.invites.resend(inviteId)
// Cancel invite
await nurev.invites.cancel(inviteId)
// Get referral stats
const referrals = await nurev.invites.getReferrals()
// Validate invite code
const valid = await nurev.invites.checkCode('ABC123')nurev.rewards
Define rewards your users can redeem with earned points, and track redemptions.
// List reward items
const items = await nurev.rewards.list({ active: true })
// → { docs: [{ title, rewardKey, cost, durationDays, reusable, active }], ... }
// Create a reward
const reward = await nurev.rewards.create({
title: 'Remove Ads (30 days)',
rewardKey: 'no-ads-30d',
cost: 500,
durationDays: 30,
reusable: true,
description: 'Removes all ads for 30 days',
})
// Update a reward
await nurev.rewards.update(reward._id, { cost: 400, active: true })
// Delete a reward
await nurev.rewards.remove(reward._id)
// Get a single reward
const item = await nurev.rewards.get(rewardId)
// List all redemptions (who redeemed what)
const redemptions = await nurev.rewards.listRedemptions({
rewardKey: 'no-ads-30d', // optional filter
})
// → { docs: [{ rewardItemId, appUserId, rewardKey, revSpent, expiresAt }], ... }
// Earn rate stats (helps price rewards)
const stats = await nurev.rewards.getStats()
// → { avgEarnRatePerHour, totalPointsDistributed, totalRedemptions, ... }nurev.auth
Low-level authentication (use nurev.login() for convenience).
await nurev.auth.register({ email, password, firstName, lastName })
await nurev.auth.forgotPassword(email)
await nurev.auth.resetPassword(token, newPassword)
await nurev.auth.verifyEmail(userId, code)
nurev.auth.logout()Pagination
All list methods return paginated responses:
{
docs: [...], // Items for current page
totalDocs: 150, // Total matching items
page: 1, // Current page
limit: 20, // Items per page
totalPages: 8 // Total pages
}Paginate with page and limit:
const page2 = await nurev.earnings.list({ page: 2, limit: 50 })Sort with sort (prefix - for descending):
await nurev.users.list({ sort: '-createdAt' }) // newest first
await nurev.users.list({ sort: 'createdAt' }) // oldest firstIntegration Templates
See the examples/ directory for complete integration templates:
| Template | File | Description |
|----------|------|-------------|
| Pay-Per-Install | pay-per-install.js | Reward users with in-app credits for installing NUREV. Includes retention bonuses for long-term installs. |
| Session Rewards | session-rewards.js | Tiered rewards based on session duration. Bronze/Silver/Gold/Platinum tiers with multipliers. |
| Referral Program | referral-program.js | Earn from inviting other publishers. Track conversion rates, follow up on pending invites. |
| Auto-Payout | earnings-autopayout.js | Automated balance monitoring and withdrawal triggers. Supports crypto with fiat fallback. |
| Express Server | express-webhook.js | HTTP API bridge with endpoints for status, user verification, leaderboard, and earnings. |
| React Widget | react-widget.jsx | Drop-in React component showing live NUREV stats. Includes useNurev and useNurevStats hooks. |
Running an example
export [email protected]
export NUREV_PASSWORD=yourpassword
export NUREV_API_KEY=your-api-key
node examples/pay-per-install.jsError Handling
All methods throw on failure with structured errors:
try {
await nurev.withdrawals.requestCrypto(amount, 'BTC', address)
} catch (err) {
err.status // HTTP status code (e.g. 400, 401, 500)
err.code // API error code (e.g. 'NO_BALANCE', 'INVALID_PAYOUT_ADDRESS')
err.message // Human-readable message
err.data // Full response body
}Common error codes:
| Code | Meaning |
|------|---------|
| WRONG_PASSWORD | Invalid credentials |
| NO_BALANCE | Insufficient balance for withdrawal |
| INVALID_PAYOUT_ADDRESS | Bad crypto address |
| 401 | Token expired (auto-refresh attempted) |
Data Units
- REV amounts: API returns values in smallest units. Divide by 10 for display:
amount / 10 - Timestamps: ISO 8601 strings (UTC)
- Durations: Seconds (session live-time)
Environment Variables
| Variable | Description |
|----------|-------------|
| NUREV_API_KEY | Publisher API key |
| NUREV_EMAIL | Login email |
| NUREV_PASSWORD | Login password |
| NUREV_PAYOUT_ADDRESS | Default withdrawal address |
License
MIT
