Skip to content

Latest commit

 

History

History
125 lines (100 loc) · 2.69 KB

meta.md

File metadata and controls

125 lines (100 loc) · 2.69 KB

Access Meta Data

All collections

Retrieve schemas for all collections in a project

var client = new Keen({
  projectId: "YOUR_PROJECT_ID",
  masterKey: "YOUR_MASTER_KEY"
});

var url = client.url("/events");
// returns https://api.keen.io/3.0/projects/YOUR_PROJECT_ID/events

client.get(url, null, client.masterKey(), function(err, res){
  // if (err) handle the error
  console.log("Returned schema info for " + res.length + " collections");
});

Each collection will return a result that looks like this:

{
  "name": "pageview",
  "properties": {
    "keen.created_at": "datetime",
    "keen.id": "string",
    "keen.timestamp": "datetime",
    "another_property": "string",
    "etc": "string"
  },
  "url": "/3.0/projects/<YOUR_PROJECT_ID>/events/<COLLECTION_NAME>"
}

Single collection

var client = new Keen({
  projectId: "YOUR_PROJECT_ID",
  masterKey: "YOUR_MASTER_KEY"
});
var url = client.get("/events/purchases");
// returns https://api.keen.io/3.0/projects/YOUR_PROJECT_ID/events/purchases

client.get(url, null, client.masterKey(), function(err, res){
  // if (err) handle the error
  console.log(res);
});

The response will look like this:

{
  "properties": {
    "keen.created_at": "datetime",
    "keen.id": "string",
    "keen.timestamp": "datetime",
    "another_property": "string",
    "etc": "string"
  }

}

All properties from a collection

var client = new Keen({
  projectId: "YOUR_PROJECT_ID",
  masterKey: "YOUR_MASTER_KEY"
});
var url = client.get("/events/purchases/properties");
// returns https://api.keen.io/3.0/projects/YOUR_PROJECT_ID/events/purchases/properties

client.get(url, null, client.masterKey(), function(err, res){
  // if (err) handle the error
  console.log("Returned property info for " + res.length + " properties");
});

The response will include an array of objects that look like this:

[
  {
    "property_name": "keen.id",
    "type": "string",
    "url": "/3.0/projects/YOUR_PROJECT_ID/events/purchases/properties/keen.id"
  },
  {},
  {}
]

Single property from a collection

var client = new Keen({
  projectId: "YOUR_PROJECT_ID",
  masterKey: "YOUR_MASTER_KEY"
});
var url = client.get("/events/purchases/properties/keen.id");
// returns https://api.keen.io/3.0/projects/YOUR_PROJECT_ID/events/purchases/properties

client.get(url, null, client.masterKey(), function(err, res){
  // if (err) handle the error
  console.log(res);
});

The response will look like this (same as a single result from the previous example):

{
  "property_name": "keen.id",
  "type": "string",
  "url": "/3.0/projects/YOUR_PROJECT_ID/events/purchases/properties/keen.id"
}