Skip to content

@pitcher/js-api

Pitcher JS API allows you to interact with CatalogIQ programmatically. It provides a set of APIs that enable you to build custom applications that leverage CatalogIQ data and functionality.

Under the hood, the API uses iframe communication to interact with the CatalogIQ platform. The API encapsulates the communication logic.

Using as a package

To use the JS API, install the @pitcher/js-api NPM package.

bash
npm install @pitcher/js-api
# or
yarn add @pitcher/js-api
# or
pnpm add @pitcher/js-api

Then, you can import the API in your application.

js
import { usePitcherApi } from '@pitcher/js-api'

const api = useApi()

Using from CDN

You can also use the static JS file or CDN to include the API in your application, just like we did in the Getting Started guide.

html
<script src="https://cdn.jsdelivr.net/npm/@pitcher/js-api"></script>

In this case, the API will be available as a global variable on window.pitcher

js
const api = window.pitcher.useApi()

Initialization

To start using the API, you need to obtain an instance of the API object. There are several functions to get different parts of the API.

  • useApi(): The main function you should use. Returns appropriate API object depending on the App location making all appropriate methods from the APIs below available to the user.
  • usePitcherApi(): API to interact with the CatalogIQ platform.
  • useUi(): API to interact with the CatalogIQ UI.
  • useDsr(): API to interact with the CatalogIQ DSR.
  • useAdmin(): API to interact with the CatalogIQ Admin.

To find out more about the available methods, check out the details of each API.