node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


Precog Client for JavaScript

Precog is a powerful analytics platform for JSON data. This JavaScript client allows easy streaming, uploading, and querying of data.



Include precog.min.js to get a global Precog object:

<script src="precog.min.js"></script>


Install the precog library:

npm install precog

And load the library:

var precog = require('precog');

Getting Started

  1. Create a new Precog API by specifying your API key.

    var api = new Precog.api({"apiKey": "[MY API KEY]", "analyticsService" : ""});
  2. Upload or stream some JSON data into a subdirectory of your base path. Your base path starts with your Precog account ID.

    api.append({path: '/[MY ACCOUNT ID]/test', value: {age: 29, gender: 'male'}});
  3. Query your JSON data.

    api.execute({query: 'count(//[MY ACCOUNT ID]/test)'});


Visit the Precog Developer Center for documentation on the REST API and client libraries.


If you would like to made modifications to the source, you can build a distribution by running the following from the project directory:

npm install

Tests can be run from npm:

npm test

Or by loading test-api.htm under the test directory into a browser.