Skip to main content

Peekaboo SDK API Reference

This section provides a comprehensive reference for all the functions and methods available in the Peekaboo SDK. Use this guide to understand how to interact with the SDK programmatically.


Table of Contents

  1. Initialization
  2. Creating Interactive Wait Experiences (IWE)
  3. Event Handling
  4. Customization
  5. Analytics
  6. Error Handling

Initialization

Initialize the SDK

To use the Peekaboo SDK, you must first initialize it with your API key and project ID.

  • JavaScript:

    const Peekaboo = require('peekaboo-sdk');

    const peekaboo = new Peekaboo({
    apiKey: 'YOUR_API_KEY',
    projectId: 'YOUR_PROJECT_ID'
    });
  • Java:

    import com.peekaboo.sdk.Peekaboo;

    Peekaboo peekaboo = new Peekaboo("YOUR_API_KEY", "YOUR_PROJECT_ID");
  • Python:

    import peekaboo_sdk as peekaboo

    peekaboo.initialize(api_key='YOUR_API_KEY', project_id='YOUR_PROJECT_ID')

Creating Interactive Wait Experiences (IWE)

createIWE

Creates an Interactive Wait Experience (IWE) with specified parameters.

Parameters

  • options (Object): Configuration options for the IWE.
    • message (String): The message to display.
    • theme (String): The visual theme of the IWE.
    • interactivity (Object): Interactive elements configuration (optional).

Example

  • JavaScript:

    peekaboo.createIWE({
    message: 'Hang tight! Great things are coming your way!',
    theme: 'default',
    interactivity: {
    type: 'quiz',
    questions: [
    {
    question: 'What is your favorite color?',
    options: ['Red', 'Blue', 'Green', 'Yellow']
    }
    ]
    }
    });
  • Java:

    peekaboo.createIWE("Hang tight! Great things are coming your way!", "default", new QuizInteractivity(...));
  • Python:

    peekaboo.create_iwe(
    message='Hang tight! Great things are coming your way!',
    theme='default',
    interactivity={
    'type': 'quiz',
    'questions': [
    {
    'question': 'What is your favorite color?',
    'options': ['Red', 'Blue', 'Green', 'Yellow']
    }
    ]
    }
    )

Event Handling

on

Registers an event listener for specific events.

Parameters

  • event (String): The name of the event.
  • callback (Function): The function to call when the event occurs.

Example

  • JavaScript:

    peekaboo.on('userInteraction', (event) => {
    console.log('User interacted:', event);
    });
  • Java:

    peekaboo.setEventListener(new PeekabooEventListener() {
    @Override
    public void onUserInteraction(Event event) {
    System.out.println("User interacted: " + event);
    }
    });
  • Python:

    def on_user_interaction(event):
    print('User interacted:', event)

    peekaboo.on('user_interaction', on_user_interaction)

Customization

setTheme

Sets a custom theme for the IWEs.

Parameters

  • theme (String): The name of the theme.

Example

  • JavaScript:

    peekaboo.setTheme('customTheme');
  • Java:

    peekaboo.setTheme("customTheme");
  • Python:

    peekaboo.set_theme('customTheme')

setInteractivity

Configures the interactive elements of the IWEs.

Parameters

  • interactivity (Object): Configuration for interactivity.

Example

  • JavaScript:

    peekaboo.setInteractivity({
    type: 'game',
    config: { ... }
    });
  • Java:

    peekaboo.setInteractivity(new GameInteractivity(...));
  • Python:

    peekaboo.set_interactivity({
    'type': 'game',
    'config': { ... }
    })

Analytics

getAnalytics

Fetches real-time analytics data.

Returns

  • Promise (JavaScript): Resolves with analytics data.
  • AnalyticsData (Java): Returns analytics data.
  • dict (Python): Returns analytics data.

Example

  • JavaScript:

    peekaboo.getAnalytics().then((data) => {
    console.log('Real-time analytics:', data);
    });
  • Java:

    AnalyticsData data = peekaboo.getAnalytics();
    System.out.println("Real-time analytics: " + data);
  • Python:

    data = peekaboo.get_analytics()
    print('Real-time analytics:', data)

Error Handling

onError

Registers an error handler to capture and handle errors.

Parameters

  • callback (Function): The function to call when an error occurs.

Example

  • JavaScript:

    peekaboo.onError((error) => {
    console.error('An error occurred:', error);
    });
  • Java:

    peekaboo.setErrorListener(new PeekabooErrorListener() {
    @Override
    public void onError(Error error) {
    System.err.println("An error occurred: " + error);
    }
    });
  • Python:

    def on_error(error):
    print('An error occurred:', error)

    peekaboo.on_error(on_error)

Peekaboo SDK - Transforming wait times into delightful experiences.