Appetize Docs
HomeDemoUploadPricing
  • Introduction
  • Platform
    • App Management
      • Uploading Apps
        • Android
        • iOS
      • App Dashboard
      • Running Apps
      • App Permissions
    • Device Sandbox
    • Embedding
    • Sharing
    • Session Inactivity Timeout
    • Query Params Reference
  • Features
    • Devices & OS Versions
    • Network Traffic Monitor
    • Debug Logs
    • UI Automation
    • Proxy
    • Language & Locale
    • Mock Location
    • Deep links
    • Launch Params
    • Media
    • Auto-grant Permissions
    • Custom Branding
    • Custom Launch Pages
    • Advanced Features
      • Android
        • ADB tunnel
        • Hide Password Visibility
      • Reserved Devices
  • Account
    • Invite your team
    • Single Sign-On
      • OpenID Connect
      • SAML
      • Azure Active Directory
      • Google Workspace (GSuite)
    • Reporting
      • Session History
      • Usage Summary
  • Infrastructure
    • Configure Network Access
    • Enterprise Hosting Options
  • JavaScript SDK
    • Configuration
    • Automation
      • Device commands
      • Touch interactions
    • API reference
      • Initialization
      • Client
      • Session
      • Types
        • AdbConnectionInfo
        • AppetizeApp
        • AndroidElementAttributes
        • Coordinates
        • DeviceInfo
        • Element
        • ElementBounds
        • IOSAccessibilityElement
        • IOSElementAttributes
        • NetworkRequest
        • NetworkResponse
        • SessionConfig
        • SwipeMove
        • RecordedAction
        • RecordedSwipeAction
        • RecordedKeypressAction
        • RecordedPosition
        • RecordedTapAction
        • RecordedTouchAction
        • UserInteraction
  • Testing
    • Getting Started
    • Writing Tests
    • Running Tests
    • Test Configuration
    • Continuous Integration
    • Record Tests (experimental)
    • Trace Viewer
    • Web Tests on Mobile Browsers
  • REST API
    • Create new app
    • Update existing app
    • Direct file uploads
    • Delete app
    • List apps
    • Usage summary
    • Devices & OS Versions
      • v1
    • IP Blocks
      • v1
    • Sample code
  • Guides & Samples
    • Impersonation
    • Automate Sign-in Flow
    • Screenshot Automation
    • Unlock Device
    • Validate Analytics Events
    • Lock Your Device to One App
    • Test Accessibility Font Sizes
    • Common testing scenarios
    • Samples Repository
  • Deprecated
    • Cross-document messages
  • Changelog
  • Additional Support
    • Knowledge Base
    • Support Request
Powered by GitBook
On this page
  • Installation
  • Embed your app
  • Get the Client
  • Starting a Session

JavaScript SDK

Our JavaScript SDK offers an API to programmatically interact with Appetize devices. This allows you to automate interactions with the device, verify app behavior, and more.

PreviousEnterprise Hosting OptionsNextConfiguration

Last updated 4 months ago

Installation

First, load the JavaScript SDK by adding the following snippet to the head section of your page:

<script>
(function () {const n = window,i = document,o = i.getElementsByTagName("script")[0],t = i.createElement("script");
(t.src = "https://js.appetize.io/embed.js"), (t.async = 1), o.parentNode.insertBefore(t, o);
const s = new Promise(function (e) {t.onload = function () {e();};});n.appetize = {getClient: function (...e) {
return s.then(() => n.appetize.getClient(...e));},};})();
</script>

Embed your app

Add an iframe with an :

<iframe
    id="appetize"
    src="https://appetize.io/embed/<BuildId|PublicKey>"
    width="378px" 
    height="800px" 
    frameborder="0" 
    scrolling="no"></iframe>

We gave the iframe an id of appetize, but it can be anything you wish.

Get the Client

This will return an Appetize client instance for the embed e.g.

const client = await window.appetize.getClient("#appetize")
const client = await window.appetize.getClient("#appetize", {    
    buildId: '{buildId|publicKey}',
    device: 'iphone13pro',
    osVersion: '15.0'
    ...
})

The base URL can be changed with a data-appetize-url attribute, e.g. data-appetize-url="https://sampledomain.appetize.io"

Starting a Session

You can start a session programmatically:

const session = await client.startSession()
console.log('session started!')

or wait for the user to click "Tap to Play":

client.on("session", session => {
    console.log('session started!')
})

Next we'll cover various ways you can configure the embed, such as the device or OS version.

The easiest way to get the client is by calling .

We also support getting the client with an initial - for scenarios where the initial embed link might not be known on launching of the page (no src specified on the iframe) by making use of .

This will return an Appetize client instance with the initial applied e.g.

Appetize embed URL
configuration
configuration
window.appetize.getClient(selector)
window.appetize.getClient(selector, config)