JavaScript SDK

GitHub version Version Build Status Coverage

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

Installation

npm install predicthq

Example Usage

Common JS

var Client = require('predicthq')

var phq = new Client({access_token: "ACCESS_TOKEN"})

phq.events.search({q: 'Madonna', rank_level: 5, country:'AU', 'start.gte' : '2016-01-01'})
    .then(function(results){
        var events = results.toArray()
        for(var i=0; i < events.length; i++)
            console.info(events[i].rank, events[i].category, events[i].title, events[i].start, events[i].location )
    })

ES6

import Client from 'predicthq'

let phq = new Client({access_token=:"ACCESS_TOKEN"})

phq.events.search()
    .then((results)=>{
        for (let event of results)
            console.info(event.title)
    })

Found a Bug?

Please log an issue on our GitHub repository.