JavaScript SDK
Installation
npm install predicthq
Example Usage
Initialising the SDK
Common JS
const phq = require('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 phq.Client({access_token: 'Acc3sS-t0keN'});
ES6
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: 'Acc3sS-t0keN'});
NodeJS
You will need to bring your own fetch library
// npm install node-fetch
const nodeFetch = require('node-fetch');
const phq = require('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 phq.Client({access_token: 'Acc3sS-t0keN', fetch: nodeFetch});
Event Search
// Basic event search using title as parameter. By default, it will return the first ten events.
client.events.search({title: 'Aviation Festival'})
.then(
(results) => {
for (const event of results) {
console.info(event);
}
}
).catch(
err => console.error(err)
);
Further examples
Please browse through our use case examples on our GitHub repository.
Found a Bug?
Please log an issue on our GitHub repository.