@strafe-fun/sdk
v0.1.1
Published
Strafe SDK: sign-in, player data, analytics, crash reports, progression, coin checkout and payouts for game developers.
Maintainers
Readme
@strafe-fun/sdk
The SDK for games on strafe.fun: sign-in, cross-device player data, analytics, crash reports, progression funnels, and taking payment.
Full documentation: https://strafe.fun/docs
In the browser
A game embedded on strafe.fun can use the script tag and skip npm entirely:
<script src="https://strafe.fun/js/strafe.js"></script>
<script>
const strafe = new Strafe({ appId: 'app_...' });
</script>From a bundler:
import { StrafeClient } from '@strafe-fun/sdk/browser';
const strafe = new StrafeClient({ appId: 'app_...' });
strafe.onChange(({ user }) => render(user));The App Id is public and belongs in a page. The App Secret never does.
On your server
const { Strafe } = require('@strafe-fun/sdk/server');
const strafe = new Strafe({
appId: process.env.STRAFE_APP_ID,
appSecret: process.env.STRAFE_APP_SECRET,
});
// Open a purchase and send the player to the URL you get back.
const { ok, url, error } = await strafe.createCheckout(player.id, {
item: '5,500 Coins',
priceCents: 499,
coins: 5500,
reference: `shop-${cartId}`,
accept: [{ currency: 'usdc' }, { currency: 'sol' }],
});Your server credits the coins itself once strafe reports the purchase paid. Strafe is the till, not the shop: it stores no catalogue, and what you sell and what it costs stay in your code.
Everything is REST underneath
Every method here is a thin wrapper over an HTTP endpoint, so nothing requires this package. If you would rather call the API directly, or you work in a language this does not ship for, the endpoints are documented at https://strafe.fun/docs/api-reference and are the same ones these methods use.
License
MIT
