@nanorail/sdk
v0.1.2
Published
MPP-native metering SDK: turn data-nanorail-* attributes into agent-readable, policy-bounded paid content chunks with discovery, receipts, and Tempo settlement.
Downloads
448
Maintainers
Readme
@nanorail/sdk
The MPP-native metering SDK for priced digital units. Mark content with
data-nanorail-* attributes and NanoRail generates the agent-readable manifest, a
discovery API, policy-bounded unlocks, receipts, and Tempo settlement — for humans
and autonomous agents alike.
Install
npm i @nanorail/sdkUse
import { initNanoRail } from '@nanorail/sdk';
const nr = initNanoRail({
gatewayUrl: 'https://gateway.yoursite.com',
articleId: 'your-article-id',
autoUnlockOnScroll: true, // humans: meter eligible chunks open as they read
});Mark any element:
<p
data-nanorail-chunk="para-3"
data-nanorail-price="0.005"
data-nanorail-type="text"
data-nanorail-title="The micropayment thesis"
data-nanorail-teaser="Why metering beats blocking for machine readers."
data-nanorail-tags="MPP, micropayments, metering"
>
Premium content…
</p>Script tag (no bundler)
<script>
window.NANORAIL_CONFIG = { gatewayUrl: 'http://localhost:4020', articleId: 'your-article-id' };
</script>
<script src="https://cdn.yoursite.com/nanorail.js"></script>API
initNanoRail(config) returns an instance:
client—NanoRailClient: sessions, policy, unlocks, receiptsmanifest— the auto-generatedArticleManifestrescan()— re-scan + lock any newly added chunksrunAgent(opts)— discovery → plan → buy → summarizeunlockTempoSnippet()— the real Tempo MPP settlement path
Policy is enforced both client-side (before signing) and server-side (independently). Chunks that are over budget or of a blocked type stay gated. Unlocks emit lifecycle events and receipts.
License
MIT
