---
title: "API Overview"
url: "https://help.productfruits.com/en/article/javascript-api-overview"
language: "en"
last_updated: "2024-10-01T10:11:39.454Z"
---

# API Overview

The JavaScript API is accessible through the `window.productFruits.api` global variable. The information found below is more for developers looking to use the API. Check out the left menu to get more details on the JS methods for particular tools.

## Ready events

The API functions asynchronously. Before you use it, you have to check if Product Fruits is initialized. You have 3 ways, choose the method that suits your use case best.

**Option 1: Global variable check**

You can check to see if `window.productFruitsIsReady` is equal to`true`. 

**Option 2: Listen to the ready event**

You can also listen to the `productfruits_ready` event. **Don't forget to attach this handler before you run the Product Fruits snippet.** For instance:

```javascript
window.addEventListener('productfruits_ready', function() { 
    console.log('Product Fruits is ready!');
});

// here comes the Product Fruits snippet
```

**Option 3: Ready callback**

You can also provide the `window.productFruitsReady` function callback. **Don't forget to set this before you run the Product Fruits snippet.** For instance:

```javascript
window.productFruitsReady = function() {
    console.log('Product Fruits is ready!');
};

// here comes the Product Fruits snippet
```
