Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

JavaScript SDK

The official PredictHQ JavaScript Client provides a consistent JavaScript interface to our API.

Example

Installation

Install the SDK from npm:

npm install predicthq

Setup the SDK

Import the client and initialize it with your access token:

import Client from 'predicthq'

// Initialises PredictHQ client library using your access token
// Note: You can find/create your access token at https://control.predicthq.com/clients
const client = new Client({access_token: '$API_TOKEN'})

Search events

Perform a basic search of events using the title parameter:

client.events.search({title: 'Aviation Festival'})
    .then(
        (results) => {
            for (const event of results) {
                console.info(event);
            }
        }
    ).catch(
        err => console.error(err)
    )

Further examples

Browse through our use case examples on our GitHub repository.

Found an issue?

Log an issue on our GitHub repository.

Last updated

Was this helpful?