Skip to main content
Supported on
Snapchat

API reference

This page documents version 0.2.1 of the @snap/web-lens-api package, generated from its type declarations. Web Lens API explains how to add the API to a Lens, and the Leaderboards, Lens+, Bitmoji, and Storage guides show each capability in use.

Snapchat Web Lens API (window.snapchat) — one include for iOS, Android, and desktop development.

Put the built file in your game's zip (the one you upload to My Lenses, with index.html at its root): the Lens CSP blocks runtime fetches by design.

await snapchat.init();
if (snapchat.isSupported('leaderboards')) {
await snapchat.leaderboards.submitScore({ score: 42 });
await snapchat.leaderboards.show();
}

Variables​

errors​

const errors: WebLensAPIErrors;

Stable error codes. A rejected call's error.message is always one of these.


snapchat​

const snapchat: SnapchatWebLensAPI;

The singleton also installed as window.snapchat.

Example​

// With a bundler or native ES modules:
import snapchat from '@snap/web-lens-api';

// With a classic <script src="snap-api.js"> include, use window.snapchat directly.

Interfaces​

WebLensAPIErrors​

Stable error codes. A rejected call's error.message is always one of these; native error text never crosses the bridge.

Example​

try {
await snapchat.storage.set('replay', frames);
} catch (e) {
// The store is unchanged, so the previous save is still intact.
if (e.message !== snapchat.errors.QUOTA_EXCEEDED) throw e;
await snapchat.storage.remove('replay');
}

Properties​

PropertyModifierTypeDescription
MALFORMED_REQUESTreadonly"ERR_MALFORMED_REQUEST"The request envelope or app://<capability>/<action> URI failed validation (API bug — file it).
UNKNOWN_CAPABILITYreadonly"ERR_UNKNOWN_CAPABILITY"No handler is registered for the capability on this app version / surface. Check SnapchatWebLensAPI.isSupported first.
INVALID_PARAMSreadonly"ERR_INVALID_PARAMS"The capability rejected the params against its allowlist.
INTERNALreadonly"ERR_INTERNAL"The capability failed internally; details stay in native logs.
QUOTA_EXCEEDEDreadonly"ERR_QUOTA_EXCEEDED"A storage write would exceed the per-Lens byte or key-count quota, or too many storage calls are in flight; the store is unchanged.
STORAGE_UNAVAILABLEreadonly"ERR_STORAGE_UNAVAILABLE"storage has no durable backing on this device or session, or the Lens is closing.
UNSUPPORTED_HOSTreadonly"ERR_UNSUPPORTED_HOST"API-only: the page runs inside Snapchat, but this app version or its WebView can't serve the API (the host injected no bridge). Every call rejects with it, so hide the feature.
NOT_INITIALIZEDreadonly"ERR_NOT_INITIALIZED"API-only: a friend Bitmoji call (BitmojiAPI.getFriendAvatars, or any call passing avatar) ran before SnapchatWebLensAPI.init resolved. Await init() once at startup; nothing was sent to the host.

SubmitScoreParams​

Properties​

PropertyTypeDescription
leaderboardId?stringDeprecated Not needed; omit it.
scorenumberInteger in the safe-integer range; non-integers reject ERR_INVALID_PARAMS.
ordering?"ascending" | "descending"Lower-is-better games must send 'ascending' on every submission. Defaults to 'descending'.

SubmitScoreResult​

Properties​

PropertyTypeDescription
bestScore?numberThe player's best score on the Lens's board, as the server acknowledged it; absent when the backend omits it.

SubscriptionStatus​

Properties​

PropertyTypeDescription
eligiblebooleanWhether the user can use this Lens's Lens+ content right now (see SubscriptionAPI).

UpgradeOutcome​

Properties​

PropertyTypeDescription
subscribedbooleanWhether the user has Lens+ when the flow ends.
reason?"too_soon" | "already_in_flight" | "user_ineligible"Set when the upgrade offer didn't complete for a reason other than the user's choice. too_soon: the Lens opened moments ago, and Snapchat showed nothing; already_in_flight: another upgrade offer is on screen, and Snapchat showed nothing; user_ineligible: the user can't buy Lens+ in the app (for example, their subscription is managed elsewhere), and Snapchat tells them so itself.

AvatarTarget​

Whose Bitmoji a BitmojiAPI call serves.

Extended by​

Properties​

PropertyTypeDescription
avatar?string | nullA friend's handle from BitmojiAPI.getFriendAvatars (bitmoji v2). Omit it, or pass null, for the current user. Passing one before SnapchatWebLensAPI.init resolves rejects ERR_NOT_INITIALIZED; on a host below bitmoji v2, or from another Lens session, ERR_INVALID_PARAMS. It never falls back to the user. The target itself must be an object (or omitted): a bare string, or a non-string avatar, rejects ERR_INVALID_PARAMS.

AvatarInfo​

Properties​

PropertyTypeDescription
hasAvatarbooleanWhether the user (or the friend named by avatar) has a Bitmoji.
maxBatchCount?numberThe most handles one BitmojiAPI.getFriendAvatars call returns (host-set: 20 by default, never above 50). Set by hosts serving bitmoji v2.

FriendAvatar​

One friend from BitmojiAPI.getFriendAvatars. Pass it straight back as the target of the other Bitmoji calls: get3DAvatar(friend), or get2DAvatar({ ...friend, size: 'small' }). More fields may be added later, but never one named like a call option (size, variant, or any option added later), so spreading an entry into a call's options is always safe. Pass the entry, not its handle: a bare string target rejects ERR_INVALID_PARAMS.

Properties​

PropertyModifierTypeDescription
avatarreadonlystringOpaque handle for AvatarTarget.avatar, valid for this Lens session only. Never store or parse it.

GetFriendAvatarsParams​

Properties​

PropertyTypeDescription
countnumberHow many friends to return: a whole number ≥ 1. Larger values are clamped to maxBatchCount.

Get3DAvatarParams​

Whose Bitmoji a BitmojiAPI call serves.

Extends​

Properties​

PropertyTypeDescriptionInherited from
avatar?string | nullA friend's handle from BitmojiAPI.getFriendAvatars (bitmoji v2). Omit it, or pass null, for the current user. Passing one before SnapchatWebLensAPI.init resolves rejects ERR_NOT_INITIALIZED; on a host below bitmoji v2, or from another Lens session, ERR_INVALID_PARAMS. It never falls back to the user. The target itself must be an object (or omitted): a bare string, or a non-string avatar, rejects ERR_INVALID_PARAMS.AvatarTarget.avatar
meshQuality?AvatarQualityMesh detail. 'medium' and 'low' return a simplified mesh that needs EXT_meshopt_compression: load it with a loader that supports meshopt, such as PlayCanvas 2.24+ with pc.meshoptInitialize. 'high' never uses meshopt. Defaults to 'high'; any other value rejects ERR_INVALID_PARAMS.-
textureQuality?AvatarQualityTexture size: 'medium' and 'low' return smaller textures. Defaults to 'high'; any other value rejects ERR_INVALID_PARAMS.-

Get2DAvatarParams​

Whose Bitmoji a BitmojiAPI call serves.

Extends​

Properties​

PropertyTypeDescriptionInherited from
avatar?string | nullA friend's handle from BitmojiAPI.getFriendAvatars (bitmoji v2). Omit it, or pass null, for the current user. Passing one before SnapchatWebLensAPI.init resolves rejects ERR_NOT_INITIALIZED; on a host below bitmoji v2, or from another Lens session, ERR_INVALID_PARAMS. It never falls back to the user. The target itself must be an object (or omitted): a bare string, or a non-string avatar, rejects ERR_INVALID_PARAMS.AvatarTarget.avatar
variant?stringVariant id from BitmojiAPI.getVariants; omit for the default portrait.-
size?"small" | "medium" | "large"Defaults to 'medium'.-

MediaURL​

Properties​

PropertyTypeDescription
urlstringSame-origin, opaque and ephemeral (~5 min): fetch or render promptly, never parse, re-call on error. The shape differs between the stub and a device.

StorageInfo​

Properties​

PropertyTypeDescription
usedBytesnumberBytes the store holds now.
maxBytesnumberPer-Lens store cap, in bytes (100 KiB).
keyCountnumberKeys the store holds now.
maxKeysnumberPer-Lens key cap (256).
maxValueBytesnumberPer-value cap, in bytes of JSON (32 KiB).
persistenceMode"memory" | "disk"memory for Lens Studio previews and the desktop stub.

LeaderboardsAPI​

Native leaderboards (leaderboards capability, v1). Only Lenses configured with the leaderboard module see it in SnapchatWebLensAPI.init.

Methods​

submitScore()​
submitScore(params): Promise<SubmitScoreResult>;

Submits a score to the Lens's leaderboard.

Parameters​
ParameterType
paramsSubmitScoreParams
Returns​

Promise<SubmitScoreResult>

Example​
// A time trial: lower is better, so say so on every submission.
const { bestScore } = await snapchat.leaderboards.submitScore({
score: Math.round(lapSeconds * 1000), // integers only
ordering: 'ascending',
});
if (bestScore !== undefined) bestLabel.textContent = `Best: ${bestScore} ms`;
show()​
show(): Promise<void>;

Opens the Lens's own native leaderboard panel. Submit first so it has data; rejects ERR_INTERNAL when nothing can host it or no board data loads within the bounded wait.

Returns​

Promise<void>

Example​
await snapchat.leaderboards.submitScore({ score });
await snapchat.leaderboards.show();

SubscriptionAPI​

Lens+ content for Web Lenses (subscription capability, v1). The game checks whether the user can use its Lens+ content and asks Snapchat to show the Lens+ upgrade offer. Snapchat runs the payment: only yes-or-no answers and stable reason strings cross the bridge, never the price, plan, provider or expiry.

Snapchat decides who is eligible: on a Lens+ Lens, only users with Lens+. On any other Lens every user is eligible, and requestUpgrade() resolves { subscribed: true } at once without showing anything. Snapchat may also make a Lens+ Lens free for everyone, for example during a promotion; keep gating on eligible. A Lens you push to your phone isn't a Lens+ Lens, so test the locked path on the desktop stub.

When the submission scan finds calls, submitting a new Lens makes it a Lens+ Lens, and an update can't add them to a Lens that isn't one. The scan finds calls on anything named subscription (snapchat.subscription, this.subscription) or on a variable assigned from it, not through a property with another name or a function parameter; a Lens whose calls are all missed is never a Lens+ Lens. The Lens+ guide and the package README list the requirements.

Methods​

getStatus()​
getStatus(): Promise<SubscriptionStatus>;

Whether the user can use this Lens's Lens+ content right now. SubscriptionAPI lists when every user can.

Returns​

Promise<SubscriptionStatus>

Example​
const { eligible } = await snapchat.subscription.getStatus();
bonusLevel.locked = !eligible;
requestUpgrade()​
requestUpgrade(): Promise<UpgradeOutcome>;

Shows the Lens+ upgrade offer, then Snapchat's paywall if the user taps through, and resolves when they're done. Nothing shows to a user with Lens+, or to anyone on a Lens that isn't a Lens+ Lens: they get { subscribed: true } at once. It resolves { subscribed: false, reason } when Snapchat throttles the offer and shows nothing, or when the user can't buy Lens+ in the app. Rejects ERR_INTERNAL when nothing can show it.

Returns​

Promise<UpgradeOutcome>

Example​
unlockButton.onclick = async () => {
const { subscribed, reason } = await snapchat.subscription.requestUpgrade();
if (subscribed) startBonusLevel();
else if (reason) console.info('Upgrade offer not completed:', reason); // 'too_soon' | 'already_in_flight' | 'user_ineligible'
};
onStatusChanged()​
onStatusChanged(callback): () => void;

Fires with { eligible } whenever the user's Lens+ status changes while this Lens is open, including after subscribing in another Lens or in Settings. Not every Snapchat version sends these events, so rely on SubscriptionAPI.requestUpgrade's subscribed and SubscriptionAPI.getStatus rather than waiting for it.

Parameters​
ParameterType
callback(status) => void
Returns​

the unsubscribe function (one-shot).

() => void

Example​
const unsubscribe = snapchat.subscription.onStatusChanged(({ eligible }) => {
bonusLevel.locked = !eligible;
});

BitmojiAPI​

Bitmoji avatars (bitmoji capability). v1 serves the current user's own Bitmoji. v2 adds friends: get opaque handles from BitmojiAPI.getFriendAvatars and pass one as avatar to the other calls. No avatar id, user id or name ever crosses the bridge. participant is a reserved parameter: the calls that take avatar reject it with ERR_INVALID_PARAMS.

Always keep a default Bitmoji as a fallback: hasAvatar may be false and any media call may reject ERR_INTERNAL, and a game should never show an empty character in either case. Put the fallback GLB in your game's zip: a Lens cannot fetch it from the network at runtime.

Methods​

getAvatarInfo()​
getAvatarInfo(params?): Promise<AvatarInfo>;

Whether the current user has a Bitmoji. Check it before the media calls, which reject ERR_INTERNAL for a user without one.

Parameters​
ParameterType
params?AvatarTarget
Returns​

Promise<AvatarInfo>

Example​
const { hasAvatar } = await snapchat.bitmoji.getAvatarInfo();
if (!hasAvatar) useDefaultCharacter();
get2DAvatar()​
get2DAvatar(params?): Promise<MediaURL>;

A head-and-shoulders 2D render of the avatar: the default portrait, or one of the variants from BitmojiAPI.getVariants. Rejects ERR_INVALID_PARAMS for a variant outside the current set (variants can retire server-side — fall back to the portrait) and ERR_INTERNAL when the user has no Bitmoji.

Parameters​
ParameterType
params?Get2DAvatarParams
Returns​

Promise<MediaURL>

Example​
let image;
try {
image = await snapchat.bitmoji.get2DAvatar({
variant: savedVariant,
size: 'large',
});
} catch (e) {
if (e.message !== snapchat.errors.INVALID_PARAMS) throw e;
// The variant has retired: show the portrait instead.
image = await snapchat.bitmoji.get2DAvatar({ size: 'large' });
}
avatarImg.src = image.url; // render promptly: the URL expires after ~5 min
get3DAvatar()​
get3DAvatar(params?): Promise<MediaURL>;

The rigged avatar GLB, with no clips: bundle your own, authored on the Bitmoji rig. Rejects ERR_INTERNAL when the user has no Bitmoji or the model fetch fails; the URL is never empty.

meshQuality and textureQuality trade detail for download size, and work the same for a friend's or another player's Bitmoji. Leave them out for full quality, which every engine can load.

Older Snapchat versions (before 14.33) ignore both fields and return the full model, with no error and no way to ask whether they are supported. So a Lens that requests 'medium' or 'low' must still load a full-size GLB, and must load a meshopt one when the host sends it. Do not rely on a size or a version check.

Parameters​
ParameterType
params?Get3DAvatarParams
Returns​

Promise<MediaURL>

Examples​
// Load the full-size model everywhere; ask for less only where your engine can read meshopt.
const { url } = await snapchat.bitmoji.get3DAvatar({
meshQuality: 'medium',
textureQuality: 'low',
});
const glb = await (await fetch(url)).arrayBuffer(); // meshopt-capable loader: works for both sizes

Every Bitmoji has the same rig, and it is Snap's own, not a Mixamo-style humanoid: joints are named like L_armUpper0001_bind_JNT, and most have a child that is not a joint (L_armUpper0001_bind_JNT_SSC) between them and the next joint. Find bones by name anywhere under the root, not among a node's direct children. A clip authored on another skeleton leaves the avatar in its bind pose.

// Keep a default avatar in your game's zip for users without a Bitmoji and for failed fetches.
let url = './assets/avatar_default.glb';
try {
const { hasAvatar } = await snapchat.bitmoji.getAvatarInfo();
if (hasAvatar) url = (await snapchat.bitmoji.get3DAvatar()).url;
} catch {
// ERR_INTERNAL: keep the default.
}
const glb = await (await fetch(url)).arrayBuffer(); // hand this to your engine's GLB loader
getFriendAvatars()​
getFriendAvatars(params): Promise<{
avatars: FriendAvatar[];
}>;

Opaque handles for the user's friends who share their Bitmoji (bitmoji v2), to pass as avatar to BitmojiAPI.get2DAvatar, BitmojiAPI.get3DAvatar and BitmojiAPI.getAvatarInfo.

The host takes up to maxBatchCount of the user's most recent eligible friends (mutual, not blocked, with a Bitmoji they share in Friendmoji), shuffles them once and keeps that list for the session: every call returns the first count of it, in the same order, which carries no ranking. Ask once for the most you will show. A user with few eligible friends gets a shorter list, or an empty one; it is never padded and never includes the user. Handles are valid only in the session that got them: never store one, ask again next session.

When the host finds no eligible friends, or can't read the friend list (ERR_INTERNAL), it keeps that answer for a cooldown (30 s by default) before it looks again, so a call within the cooldown gets the same result without new work. Ask again at a natural break, such as the next round, not in a loop.

Check isSupported('bitmoji', 2) before calling, like any capability. A call made before SnapchatWebLensAPI.init resolves rejects ERR_NOT_INITIALIZED without reaching the host. ERR_INVALID_PARAMS means a bug in the call, such as a bad count; ERR_INTERNAL means "no friends right now".

Parameters​
ParameterType
paramsGetFriendAvatarsParams
Returns​

Promise<{ avatars: FriendAvatar[]; }>

Example​
let friends = [];
if (snapchat.isSupported('bitmoji', 2)) {
try {
({ avatars: friends } = await snapchat.bitmoji.getFriendAvatars({
count: 3,
}));
} catch (e) {
if (e.message !== snapchat.errors.INTERNAL) throw e; // ERR_INVALID_PARAMS: fix the call
// The friend list is unavailable right now: play solo this round.
}
}
for (const friend of friends) {
const { url } = await snapchat.bitmoji.get3DAvatar(friend);
spawnFriend(url);
}
getVariants()​
getVariants(): Promise<{
variants: string[];
}>;

The server-curated set of 2D variants: head-and-shoulders renders of the avatar, the same set the native selfie picker offers. Ids are unnamed: build a visual picker by rendering each via get2DAvatar({ variant, size: 'small' }) in small batches (~6), so the user's own avatar in each variant is its label. Or pick ids at authoring time and keep them as data, falling back to the portrait when one retires.

Returns​

Promise<{ variants: string[]; }>

Example​
const { variants } = await snapchat.bitmoji.getVariants();
for (let i = 0; i < variants.length; i += 6) {
const batch = variants.slice(i, i + 6);
const images = await Promise.all(
batch.map((variant) =>
snapchat.bitmoji.get2DAvatar({ variant, size: 'small' })
)
);
images.forEach(({ url }, j) => addVariantButton(batch[j], url));
}

StorageAPI​

Account-bound key/value persistence for this Lens (storage capability, v1). Values are JSON (≤ 32 KiB each); keys are non-empty strings (≤ 256 bytes). Writes past the store quota reject ERR_QUOTA_EXCEEDED and leave the store unchanged; ERR_STORAGE_UNAVAILABLE means no durable backing exists on this device or session, or that the Lens is closing, as when a save fires while it is swiped away. Lens Studio previews and the desktop stub persist in memory only.

The first call of a session opens the store and can take seconds on a cold start: await it rather than timing it out, and write nothing until it has answered, or the write replaces the save still being read. Write as the state changes and when the page is hidden, since a Lens is closed by a swipe with no teardown of its own.

Methods​

get()​
get(key): Promise<StorageGetResult>;

Reads one key, for the account signed in now. found tells a missing key apart from a stored null.

Parameters​
ParameterType
keystring
Returns​

Promise<StorageGetResult>

Example​
const result = await snapchat.storage.get('save');
const save = result.found ? result.value : { level: 1, coins: 0 };
set()​
set(key, value): Promise<void>;

Writes one key, replacing any previous value. Save on a change of state, not once per frame: the host bounds how many calls can be in flight, so a burst rejects ERR_QUOTA_EXCEEDED.

Parameters​
ParameterTypeDescription
keystring-
valueunknownAny JSON-serializable value.
Returns​

Promise<void>

Example​
// One chain keeps one write in flight, and the catch keeps it going after a failed save.
let pending = Promise.resolve();
const save = (state) =>
(pending = pending
.then(() => snapchat.storage.set('save', state))
.catch((e) => console.warn('Save failed:', e.message)));
remove()​
remove(key): Promise<void>;

Idempotent: removing a missing key resolves.

Parameters​
ParameterType
keystring
Returns​

Promise<void>

Example​
await snapchat.storage.remove('save');
clear()​
clear(): Promise<void>;

Deletes this Lens's whole store for the current account.

Returns​

Promise<void>

Example​
resetButton.onclick = () => snapchat.storage.clear();
keys()​
keys(): Promise<{
keys: string[];
}>;

Stored keys in byte-lexicographic order.

Returns​

Promise<{ keys: string[]; }>

Example​
const { keys } = await snapchat.storage.keys();
const slots = keys.filter((key) => key.startsWith('slot:'));
getInfo()​
getInfo(): Promise<StorageInfo>;

Usage against the store's limits, and whether it persists across sessions.

Returns​

Promise<StorageInfo>

Example​
const { usedBytes, maxBytes, persistenceMode } =
await snapchat.storage.getInfo();
if (persistenceMode === 'memory')
console.warn('Progress will not survive a restart here');

HapticsAPI​

Device vibration (haptics capability, v1). A haptic carries no data, so every Lens may use it. A device with no haptic hardware, or on Android 7 and lower, doesn't list the capability. Use haptics for moments the player causes, such as a hit, a landing or a win, not as a constant background effect.

Both calls resolve with nothing. A call within 50 ms of the last haptic, or while a pattern plays, plays nothing, and nothing plays while haptics are off in the device settings. Bad params reject ERR_INVALID_PARAMS.

Methods​

impact()​
impact(style?): Promise<void>;

One short impact.

Parameters​
ParameterTypeDescription
style?ImpactStyleDefaults to 'medium'.
Returns​

Promise<void>

Example​
ball.on('collision', () => snapchat.haptics.impact('heavy'));
pattern()​
pattern(events): Promise<void>;

A timeline of taps and buzzes: 1–16 events, t going up, no event starting before the last buzz ends, and everything over by 1000 ms.

Parameters​
ParameterType
eventsHapticEvent[]
Returns​

Promise<void>

Example​
// A success: a soft tap, then a strong one.
await snapchat.haptics.pattern([
{ t: 0, type: 'tap', intensity: 0.5 },
{ t: 80, type: 'tap' },
]);

SnapchatWebLensAPI​

The window.snapchat singleton: one include for iOS, Android, and desktop development.

Every call returns a Promise. Failures reject with an Error whose message is one of the stable codes in SnapchatWebLensAPI.errors; there is no native error text to parse. Calls never throw synchronously: a failure the API cannot classify, such as params that cannot be serialized, rejects with ERR_INTERNAL.

Methods​

init()​
init(): Promise<CapabilityMap>;

Fetches and caches the capabilities this host serves. Call once at startup, before SnapchatWebLensAPI.isSupported.

Resolves {} (nothing supported) instead of rejecting when discovery itself is unavailable: no bridge at all, or a host too old to answer sdk/getCapabilities. Genuine failures (ERR_INTERNAL, ERR_INVALID_PARAMS) still reject.

Returns​

Promise<CapabilityMap>

Example​
await snapchat.init();
leaderboardButton.hidden = !snapchat.isSupported('leaderboards');
isSupported()​
isSupported(capability, minVersion?): boolean;

Whether the host serves capability at contract version minVersion (default 1) or newer. Always false before SnapchatWebLensAPI.init resolves.

A capability's contract only grows: its version goes up when it gains actions, and a breaking change ships under a new capability name, so a minVersion check keeps working on newer hosts.

Parameters​
ParameterType
capabilityCapability
minVersion?number
Returns​

boolean

Example​
snapchat.isSupported('bitmoji'); // false: init() has not resolved yet
await snapchat.init();
snapchat.isSupported('bitmoji'); // true where the host serves bitmoji v1 or newer

Properties​

PropertyModifierTypeDescription
versionreadonlystringAPI version (semver).
errorsreadonlyWebLensAPIErrors-
isStubreadonlybooleanTrue when running against the desktop stub instead of a Snapchat host. Example // The stub's 3D avatar is an empty placeholder GLB, so show the bundled default instead. const showUserAvatar = snapchat.isSupported('bitmoji') && !snapchat.isStub;
leaderboardspublicLeaderboardsAPI-
subscriptionpublicSubscriptionAPI-
bitmojipublicBitmojiAPI-
storagepublicStorageAPI-
hapticspublicHapticsAPI-

Type Aliases​

WebLensAPIErrorCode​

type WebLensAPIErrorCode = WebLensAPIErrors[keyof WebLensAPIErrors];

Union of every ERR_* string in WebLensAPIErrors.


Capability​

type Capability =
| 'leaderboards'
| 'subscription'
| 'bitmoji'
| 'storage'
| 'haptics'
| (string & object);

Capability names, as SnapchatWebLensAPI.init reports them and SnapchatWebLensAPI.isSupported takes them.


CapabilityMap​

type CapabilityMap = Record<string, number>;

Capability name → contract version, as resolved by SnapchatWebLensAPI.init.


AvatarQuality​

type AvatarQuality = 'low' | 'medium' | 'high';

How much detail a 3D avatar keeps: 'high' is full quality and the default.


StorageGetResult​

type StorageGetResult =
| {
found: true;
value: unknown;
}
| {
found: false;
};

ImpactStyle​

type ImpactStyle = 'light' | 'medium' | 'heavy' | 'soft';

The feel of one HapticsAPI.impact.


HapticEvent​

type HapticEvent =
| {
t: number;
type: 'tap';
intensity?: number;
}
| {
t: number;
type: 'buzz';
intensity?: number;
duration: number;
};

One event of a HapticsAPI.pattern. Times and durations are integer milliseconds.

Union Members​

Type Literal​
{
t: number;
type: "tap";
intensity?: number;
}
t​
t: number;

Start time from the beginning of the pattern.

type​
type: 'tap';

A short, sharp tick.

intensity?​
optional intensity?: number;

0–1; defaults to 1.


Type Literal​
{
t: number;
type: "buzz";
intensity?: number;
duration: number;
}
t​
t: number;

Start time from the beginning of the pattern.

type​
type: 'buzz';

A sustained vibration.

intensity?​
optional intensity?: number;

0–1; defaults to 1.

duration​
duration: number;

1–500.

Was this page helpful?
Yes
No