Javascript API Documentation

Javascript API Installation on External Websites

Developers interested in integrating the Evri Javascript API into their pages should be able to add the following script tag to an HTML document:

      
      

About JSONP

From the JSON article on Wikipedia:

JSONP or “JSON with padding” is a JSON extension wherein the name of a callback function is specified as an input argument of the call itself. The original proposition appears to have been made in the MacPython blog in 2005 and is now used by many Web 2.0 applications such as Dojo Toolkit Applications, Google Toolkit Applications and zanox Web Services. Further extensions of this protocol have been proposed by considering additional input arguments as, for example, is the case of JSONPP supported by S3DB web services.

Because JSONP makes use of script tags, calls are essentially open to the world. For that reason, JSONP may be inappropriate to carry sensitive data.

Including script tags from remote sites allows the remote sites to inject any content into a website. If the remote sites have vulnerabilities that allow javascript injection, the original site can also be affected.

The Evri Javascript API utilizes JSONP to make web service requests to Evri’s RESTful API. The JSONP requests are augmented with a set of callbacks similar to those used in many cross-browser Javascript libraries for handling AJAX requests. This allows the Evri Javascript API to return first class objects back to the calling Javascript code without the developer needing to parse or traverse the JSON returned by Evri’s RESTful API.

Callbacks

All of the Evri Javascript API class methods, and many of the instance methods, expect to receive an object with the following callbacks defined:

onCreate()
Called immediately after an API method is called, but prior to making the request to the Evri Servers. No arguments are required.
onLoaded()
Called once the server has responded and the JSON response has been received by the browser but before objects have been constructed from the response. No arguments required.
onComplete(responseItem)
Called once the raw JSON Response has been traversed and used to construct the resulting object. The Evri Javascript API builds up the object and passes it as the first argument to the onComplete callback. onComplete is the only callback that is required to use the Evri Javascript API.
onFailure(apiErrorObject)
Called when an error is returned by the server. An APIError object is the first argument to the onFailure callback.
Defining callbacks
      var callbacks = new Object();
      
      callbacks.onCreate = function () {
        //... For example: Show some kind of progress indicator
      };
      
      callbacks.onLoad = function () {
        //... For example: Hide some kind of progress indicator
      };
      
      callbacks.onComplete = function (graphObject) {
        for ( var i = 0 ; i < graphObject.entities.length ; i++ ) {
          //... Handle entity objects
        }
      };
      
      callbacks.onFailure = function (apiErrorObject) {
        alert(apiErrorObject.message)
      };
      
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Graph.getForURI('http://www.washingtonpost.com', callbacks);
      

About the Recipes

The Evri Javascript API recipes were written in such a way that they would be easy to test in the Firebug console within the Mozilla Firefox browser. The recipes use the console statement to output response objects that can then be inspected.

You can load the Evri Javascript API into any page by using the following code:

      var script = document.createElement('script');
      script.src = 'http://www.evri.com/jsapi/assets/javascripts/evri.api.1.js';
      document.body.appendChild(script);
      

You can also use this bookmarklet to insert the Evri Javascript API on any page.

Establishing an API Session

Note: The appId that is passed into the session constructor should be the name of your application.

Evri.API.Session

The Evri.API.Session allows a developer provide an identity and context for an application that uses the Evri API.

Instance attributes

klass
models

Recipes

Instantiating an API Session
      // appId is required and should be the name of your application
      // or the domain where your application will be running.
      
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      

Models

For convenience, all models include the following attributes:

klass
The name of the model object’s class
documentationUrl
A URL pointing to the location of the documentation for the current model object

Some models also include the following convenience attributes:

belongsTo
belongsTo is a reference bound to the a response object that points to the original calling object (when a new response object is created from a method call on an instance object rather than from a class method.)

Model Quick Links

APIError

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
message
String

Instance methods

n/a

Recipes

Coming soon

top

Article

Class methods

n/a

Instance attributes

belongsTo
An ArticleList object
documentationUrl
URL
klass
String
author
String
content
String
contentMatchedLocations
An array of MatchedLocation objects
link
An ArticleLink object
published
String
title
String
titleMatchedLocations
An array of MatchedLocation objects

Instance methods

getContentRanges()
Returns an array of ContentRange objects derived from the content attribute and contentMatchedLocations
getGraph(…callbacks…, options)
onComplete callback should expect a Graph object as its first argument.
getRelativePublicationDate()
Returns a readable age for the article
getTitleRanges()
Returns an array of ContentRange objects derived from the title attribute and titleMatchedLocations

Recipes

Highlighting and linking matched locations in Article content
      // Assumes an Article object
      var contentRanges = article.getContentRanges();
      var markedUpContent = "";
      
      for ( var i = 0 ; i < contentRanges.length ; i++ ) {
        var range = contentRanges[i];
        if ( range.matchedLocation !== undefined ) {
          var location = range.matchedLocation;
          switch(location.matchType) {
            case 'keyword':
              markedUpContent += '' + range.content + '';
              break;
            case 'queryEntity':
              // Link to an Evri Entity Detail Page
              markedUpContent += '' + range.content + '';
              break;
            case 'nonQueryEntity':
              // Link to an Evri Entity Detail Page
              markedUpContent += '' + range.content + '';
              break;
            default:
              markedUpContent += range.content
              break;
          }
        } else {
          markedUpContent += range.content;
        }
      }
      
top
top

ArticleList

Class methods

n/a

Instance attributes

belongsTo
A Media object
documentationUrl
URL
klass
String
articles
An array of Article objects

Instance methods

n/a

Recipes

Coming soon

top

ContentRange

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
content
String
matchedLocation
Will be undefined or a MatchedLocation object

Instance methods

n/a

Recipes

See recipes section of Article model
top

Entity

Class methods

findByName(name, …callbacks…)
onComplete callback should expect an EntityList object as its first argument.
findByPrefix(prefix, …callbacks…)
onComplete callback should expect an EntityList object as its first argument.
findByResource(resource, …callbacks…)
onComplete callback should expect an Entity object as its first argument.

Instance attributes

documentationUrl
URL
klass
String
description
String
facets
An array of Facet objects
href
URI
id
Integer
known
A boolean indicating whether the entity is disambiguated
media
A Media object
mediaResource
URI
name
String
portalURI
The URI that would be used to link to the Entity’s detail page on the Evri.com website
properties
An EntityPropertyList object
relatedEntitiesResource
URI
relationsResource
URI
relationsServiceURI
URI
resource
URI
type
String

Instance methods

getMentionStatistics(…callbacks…)
onComplete callback should expect an EntityHistory object as its first argument.
getRelatedEntities(…callbacks…)
onComplete callback should expect an EntityList object as its first argument.
getRelations(…callbacks…)
onComplete callback should expect an EntityRelationList object as its first argument.
getTopRelationsTargets(…callbacks…)
onComplete callback should expect a TargetList object as its first argument.
getTweetsAbout(…callbacks…)
onComplete callback should expect a TweetList object as its first argument.

Recipes

Find entities by name
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByName("Obama", {
        onComplete: function (entityList) {
          console.log(entityList);
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Find entities by prefix
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByPrefix("jeffe", {
        onComplete: function (entityList) {
          console.log(entityList);
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Find an entity by resource
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByResource("/person/barack-obama-0x16f69", {
        onComplete: function (entity) {
          console.log(entity);
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Find an entity by resource and then get related entities
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByResource("/person/barack-obama-0x16f69", {
        onComplete: function (entity) {
          console.log(entity);
      
          entity.getRelatedEntities({
            onComplete: function (entityList) {
              console.log(entityList);
            },
            onFailure: function (error) {
              console.log(error);
            }
          }, {'count':25});
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Find an entity by resource, get top relation targets for it, and then get articles for the first target relation
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByResource("/person/barack-obama-0x16f69", {
        onComplete: function (entity) {
          console.log(entity);
      
          entity.getTopRelationsTargets({
            onComplete: function (targetList) {
              console.log(targetList);
      
              targetList.targets[0].media.getArticles({
                onComplete: function (articleList) {
                  console.log(articleList);
                },
                onFailure: function (error) {
                  console.log(error);
                }
              });
            },
            onFailure: function (error) {
              console.log(error);
            }
          }, {'count':50});
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Find an entity by resource and then access its properties
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByResource("/person/barack-obama-0x16f69", {
        onComplete: function (entity) {
          console.log(entity);
          console.log(entity.description);
          console.log(entity.propertyList);
          console.log(entity.propertyList.propertyMap);
          console.log(entity.propertyList.propertyNames);
          console.log(entity.propertyList.findByName('university_attended'));
          console.log(entity.propertyList.findHavingResource());
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Find an entity by resource and then get top articles related to that entity
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByResource("/person/barack-obama-0x16f69", {
        onComplete: function (entity) {
          console.log(entity);
      
          entity.media.getArticles({
            onComplete: function (articleList) {
              console.log(articleList);
            },
            onFailure: function (error) {
              console.log(error);
            }
          });
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Find an entity by resource, get top articles related to that entity, and then get the graphs associated with each article
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByResource("/person/barack-obama-0x16f69", {
        onComplete: function (entity) {
          console.log(entity);
      
          entity.media.getArticles({
            onComplete: function (articleList) {
              console.log(articleList);
      
              for ( var i = 0 ; i < articleList.articles.length ; i++ ) {
                var article = articleList.articles[i];
                article.getGraph({
                  onComplete: function (graph) {
                    console.log(graph);
                  },
                  onFailure: function (error) {
                    console.log(error);
                  }
                });
              }
            },
            onFailure: function (error) {
              console.log(error);
            }
          });
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Find an entity by resource and then get top images related to that entity
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByResource("/person/barack-obama-0x16f69", {
        onComplete: function (entity) {
          console.log(entity);
      
          entity.media.getImages({
            onComplete: function (imageList) {
              console.log(imageList);
            },
            onFailure: function (error) {
              console.log(error);
            }
          });
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Find an entity by resource and then get top videos related to that entity
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByResource("/person/barack-obama-0x16f69", {
        onComplete: function (entity) {
          console.log(entity);
      
          entity.media.getVideos({
            onComplete: function (videoList) {
              console.log(videoList);
            },
            onFailure: function (error) {
              console.log(error);
            }
          });
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Find an entity by resource and get Twitter activity about that entity
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByResource("/person/barack-obama-0x16f69", {
        onComplete: function (entity) {
          console.log(entity);
      
          entity.getTweetsAbout({
            onComplete: function (tweetList) {
              console.log(tweetList);
      
              for ( var i = 0 ; i < tweetList.tweets.length ; i++ ) {
                var tweet = tweetList.tweets[i];
                console.log(tweet.title);
                console.log(tweet.getTitleRanges());
              }
            },
            onFailure: function (error) {
              console.log(error);
            }
          });
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
top

EntityHistories

Class methods

findByEntityResource(entityResources, …callbacks…)
The first argument, entityResources, can be either a single entity resource, or an array of resources. onComplete callback should expect an EntityHistories object as its first argument.
findForEntityList(entityList, …callbacks…)
The first argument, entityList should be an EntityList object. onComplete callback should expect an EntityHistories object as its first argument.

Instance attributes

documentationUrl
URL
klass
String
histories
An array of EntityHistory objects
historyMapByEntityResource
An object mapping the Entity href attribute to its EntityHistory object in the current result object

Instance methods

getStatisticsForEntity(entity)
Returns the corresponding EntityHistory object for the Entity object passed as the first argument

Recipes

Fetch an entity history for a single entity href
      // Assumes that you have already established an Evri.API.Session
      var entityHref = "/product/javascript-0x135202";
      
      apiSession.models.EntityHistories.findByEntityResource(entityHref, {
        onComplete: function (entityHistories) {
          console.log(entityHistories);
        },
        onFailure: function (apiError) {
          console.log(apiError);
        }
      });
      
Fetch entity histories for an array of entity hrefs
      // Assumes that you have already established an Evri.API.Session
      var entityHrefs = [
        "/product/javascript-0x135202",
        "/product/ruby-0x13b337",
        "/product/ruby-on-rails-0x13b340",
        "/product/haml-0x133efb",
        "/product/jquery-0x142e66",
        "/product/yahoo-ui-library-0x14879c"
      ];
      
      apiSession.models.EntityHistories.findByEntityResource(entityHrefs, {
        onComplete: function (entityHistories) {
          console.log(entityHistories);
        },
        onFailure: function (apiError) {
          console.log(apiError);
        }
      });
      
Fetch entity histories for an EntityList object
      // Assumes that you have already established an Evri.API.Session and an EntityList object
      
      apiSession.models.EntityHistories.findForEntityList(entityList, {
        onComplete: function (entityHistories) {
          console.log(entityHistories);
        },
        onFailure: function (apiError) {
          console.log(apiError);
        }
      });
      
top

EntityHistory

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
mentions
An array of EntityHistoryMention objects

Instance methods

n/a

Recipes

Coming soon

top

EntityHistoryMention

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
count
Integer
date
Date object

Instance methods

n/a

Recipes

Coming soon

top

EntityList

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
entities
An array of Entity objects

Instance methods

n/a

Recipes

Coming soon

top

EntityProperty

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
linkObjectName
String
linkHref
URI
portalURI
URL for Entity Detail Page on the Evri.com website if EntityProperty has a defined linkHref value
name
String
resource
URI
value
String

Instance methods

n/a

Recipes

Coming soon

top

EntityPropertyList

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
properties
An array of EntityProperty objects
propertyMap
A lookup table mapping EntityProperty name attribute to an array of EntityProperty objects
propertyNames
A sorted list of all of EntityProperty names for the current entity

Instance methods

findByName(name)
Returns an array of EntityProperty objects for the name passed in
findHavingResource
Returns an array of EntityProperty objects containing the given Entity resource

Recipes

See recipes on the Entity model

top

EntityRelation

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
href
URI
media
A media object
mediaResource
URI
resource
URI

Instance methods

getTargets(…callbacks…)
onComplete callback should expect a TargetList object as its first argument.

Recipes

Fetch and entity, then fetch its relations, and then fetch the targets for the first relation
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Entity.findByResource('/person/douglas-crockford-0x1321aa', {
        onComplete: function (entity) {
          entity.getRelations({
            onComplete: function (entityRelationList) {
              entityRelationList.relations[0].getTargets({
                onComplete: function (targetList) {
                  for ( var i = 0 ; i < targetList.targets.length ; i++ ) {
                    console.log(targetList.targets[i]);
                  }
                },
                onFailure: function (apiError) {
                  console.log(apiError);
                }
              });
            },
            onFailure: function (apiError) {
              console.log(apiError);
            }
          });
        },
        onFailure: function (apiError) {
          console.log(apiError);
        }
      });
      
top

EntityRelationList

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
relations
An array of EntityRelation objects

Instance methods

getFacets()
Returns an array of EntityRelation objects that are of the type facet
getVerbs()
Returns an array of EntityRelation objects that are of the type verb

Recipes

See recipes section for EntityRelation model

top

Facet

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
name
String

Instance methods

n/a

Recipes

Coming soon

top

Graph

Class methods

getForContent(text, …callbacks…)
The text argument should be a string and less than 1250 characters. onComplete callback should expect a Graph object as its first argument.
getForCurrentPage(…callbacks…)
Current page would need to be a publicly accessible URI. onComplete callback should expect a Graph object as its first argument.
getForURI(uri, …callbacks…)
The uri argument would need to be a publicly accessible URI. onComplete callback should expect a Graph object as its first argument.

Instance attributes

documentationUrl
URL
klass
String
entities
An array of Entity objects
media
A Entity object
pairs
An array of Pair objects
queryToken
String

Instance methods

n/a

Recipes

Get a graph for the current page
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Graph.getForCurrentPage({
        onComplete: function (graph) {
          console.log(graph);
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Get a graph for a specific URI
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Graph.getForURI('http://www.washingtonpost.com/', {
        onComplete: function (graph) {
          console.log(graph);
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Get a graph for a text string and then get the related videos
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Graph.getForContent("Barack Obama and Joseph Biden campaigned in Ohio.", {
        onComplete: function (graph) {
          console.log(graph);
      
          graph.media.getVideos({
            onComplete: function (videoList) {
              console.log(videoList);
            },
            onFailure: function (error) {
              console.log(error);
            }
          });
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
top

Image

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
belongsTo
An ImageList object
articleHref
URL
clickUrl
URL
content
String
date
String
height
Integer
mimeType
String
size
String
thumbnail
An Image object
title
String
url
URL
width
Integer

Instance methods

n/a

Recipes

Coming soon

top

ImageList

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
belongsTo
A Media object
images
An array of Image objects

Instance methods

n/a

Recipes

Coming soon

top

MatchedLocation

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
end
Integer
href
A URI that can be used to request an object
matchType
One of three values: keyword, queryEntity, nonQueryEntity
portalURI
A URI that can be used to link to an entity detail page on the Evri.com website
snippetLength
Integer
start
Integer

Instance methods

n/a

Recipes

Coming soon

top

Media

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
belongsTo
Can be one of the following objects: Entity, EntityRelation, Graph, Pair, or Target
articleLists
An array of ArticleList objects
imageLists
An array of ImageList objects
videoLists
An array of VideoList objects

Instance methods

getArticles(…callbacks…, options)
onComplete callback should expect an ArticleList object as its first argument. The options parameter is an object that can include: includeMatchedLocations:(true|false), mediaConstraint:(a MediaConstraint object), articleSnippetLength:(an integer)
getImages(…callbacks…)
onComplete callback should expect an ImageList object as its first argument.
getVideos(…callbacks…)
onComplete callback should expect a VideoList object as its first argument.

Recipes

See recipes for Entity model

top

MediaConstraint

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
excludedDomains
An array of domains
includedDomains
An array of domains

Instance methods

excludeDomain(domain)
Adds domain argument to list of excluded domains
includeDomain(domain)
Adds domain argument to list of included domains
toParams()
Returns an object

Recipes

Fetch an entity by resource, and then request articles from multiple domains
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      var constraint = new apiSession.models.MediaConstraint();
      
      constraint.includeDomain('washingtonpost.com');
      constraint.includeDomain('timesonline.co.uk');
      constraint.includeDomain('techflash.com');
      constraint.includeDomain('techcrunch.com');
      
      apiSession.models.Entity.findByResource('', {
        onComplete: function (entity) {
          entity.media.getArticles({
            onComplete: function (articleList) {
              for ( var i = 0 ; i < articleList.articles.length ; i++ ) {
                var article = articleList.articles[i];
                console.log(" - Title = ", article.title, "; Source = ", article.author);
              }
            },
            onFailure: function (apiError) {
              console.log(apiError);
            }
          }, {
            mediaConstraint: constraint
          });
        },
        onFailure: function (apiError) {
          console.log(apiError);
        }
      });
      
top

Pair

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
entity1
An Entity object
entity2
An Entity object
media
An Media object
mediaParams
Object
queryToken
String

Instance methods

n/a

Recipes

Create a pair from two entity objects
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      pair = new apiSession.models.Pair(entityObj1, entityObj2);
      
Create a pair from two entity objects and get articles connecting the two entities
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      pair = new apiSession.models.Pair(entityObj1, entityObj2);
      
      pair.media.getArticles({
        onComplete: function (articleList) {
          console.log(articleList);
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Create a pair from two entity objects and get images connecting the two entities
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      pair = new apiSession.models.Pair(entityObj1, entityObj2);
      
      pair.media.getImages({
        onComplete: function (imageList) {
          console.log(imageList);
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Create a pair from two entity objects and get videos connecting the two entities
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      pair = new apiSession.models.Pair(entityObj1, entityObj2);
      
      pair.media.getVideos({
        onComplete: function (videoList) {
          console.log(videoList);
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
top

Target

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
entity
An Entity object
href
URI
media
A Media object
mediaResource
URI
resource
URI

Instance methods

n/a

Recipes

Coming soon

top

TargetList

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
targets
An array of Target objects

Instance methods

n/a

Recipes

Coming soon

top

Tweet

Class methods

findForQuery(query, …callbacks…)
The query argument should be a string. onComplete callback should expect a TweetList object as its first argument.
findFromUsername(username, …callbacks…)
The username argument should be a string and should not include a leading ‘@’ symbol. onComplete callback should expect a TweetList object as its first argument.
findToUsername(username, …callbacks…)
The username argument should be a string and should not include a leading ‘@’ symbol. onComplete callback should expect a TweetList object as its first argument.

Instance attributes

documentationUrl
URL
klass
String
belongsTo
A TweetList object
authorName
string
authorURI
URI
content
String
entityResources
An array of URIs that can be used to request Entity objects
id
Integer
imageURI
URI
matchedLocations
An array of TweetMatchedLocation objects
permalink
URL
published
String
title
String
updated
String

Instance methods

getRelativePublicationDate
Returns a readable age for the tweet
getTitleRanges()
Returns an array of ContentRange objects

Recipes

Fetch tweets by keyword
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Tweet.findForQuery("javascript", {
        onComplete: function (tweetList) {
          for ( var i = 0 ; i < tweetList.tweets.length ; i++ ) {
            console.log(tweetList.tweets[i]);
          }
        },
        onFailure: function (apiError) {
          console.log(apiError);
        }
      });
      
Fetch tweets by hash
      // findForQuery allows you to use any query, including hashes
      
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Tweet.findForQuery("#haiku", {
        onComplete: function (tweetList) {
          for ( var i = 0 ; i < tweetList.tweets.length ; i++ ) {
            console.log(tweetList.tweets[i]);
          }
        },
        onFailure: function (apiError) {
          console.log(apiError);
        }
      });
      
Fetch tweets from user
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Tweet.findFromUsername("jeresig", {
        onComplete: function (tweetList) {
          for ( var i = 0 ; i < tweetList.tweets.length ; i++ ) {
            var tweet = tweetList.tweets[i];
            console.log(tweet.authorName);
          }
        },
        onFailure: function (apiError) {
          console.log(apiError);
        }
      });
      
Fetch tweets to user
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Tweet.findToUsername("jeresig", {
        onComplete: function (tweetList) {
          for ( var i = 0 ; i < tweetList.tweets.length ; i++ ) {
            var tweet = tweetList.tweets[i];
            console.log(tweet.title);
          }
        },
        onFailure: function (apiError) {
          console.log(apiError);
        }
      });
      
top

TweetList

Class methods

n/a

Instance attributes

tweets
An array of Tweet objects

Instance methods

n/a

Recipes

See the recipes for the Tweet object

top

TweetMatchedLocation

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
end
Integer
href
URI
portalURI
A uri that can be used to link to an Entity Detail Page on the Evri.com website.
snippetLength
Integer
start
Integer

Instance methods

n/a

Recipes

Coming soon

top

Video

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
belongsTo
A VideoList object
author
String
content
String
duration
Integer
id
Integer
medium
String
thumbnails
An array of VideoStillImage objects
title
String
type
String
url
URL

Instance methods

getSourceUrl()
Returns the URL where the video was discovered.

Recipes

See the video recipe in the Entity object documentation

top

VideoList

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
belongsTo
A Media object
videos
An array of Video objects

Instance methods

n/a

Recipes

See the video recipe in the Entity documentation

top

VideoStillImage

Class methods

n/a

Instance attributes

documentationUrl
URL
klass
String
belongsTo
A Video object
height
Integer
size
String
time
String
url
URL
width
Integer

Instance methods

n/a

Recipes

Coming soon

top

Zeitgeist

Class methods

getFallingEntitiesByType(entityType, …callbacks…)
The entityType argument currently supports the following types: person, location, product, and organization. onComplete callback should expect an EntityList object as its first argument.
getPopularEntitiesByType(entityType, …callbacks…)
The entityType argument currently supports the following types: person, location, product, and organization. onComplete callback should expect an EntityList object as its first argument.
getRisingEntitiesByType(entityType, …callbacks…)
The entityType argument currently supports the following types: person, location, product, and organization. onComplete callback should expect an EntityList object as its first argument.

Recipes

Fetch the top rising product entities
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Zeitgeist.getRisingEntitiesByType("product", {
        onComplete: function (entityList) {
          console.log(entityList);
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Fetch the top falling location entities
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Zeitgeist.getFallingEntitiesByType("location", {
        onComplete: function (entityList) {
          console.log(entityList);
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Grab the popular person entities and do a batch request for their entity histories
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Zeitgeist.getPopularEntitiesByType("person", {
        onComplete: function (entityList) {
          console.log(entityList);
      
          apiSession.models.EntityHistories.findForEntityList(entityList, {
            onComplete: function (entityHistories) {
              console.log(entityHistories);
            },
            onFailure: function (error) {
              console.log(error);
            }
          });
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
Fetch the first popular entity from zeitgeist and then fetch its entity history
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Zeitgeist.getPopularEntitiesByType("person", {
        onComplete: function (entityList) {
          console.log(entityList);
      
          apiSession.models.EntityHistories.findByEntityResource(entityList.entities[0].resource, {
            onComplete: function (entityHistories) {
              console.log(entityHistories);
            },
            onFailure: function (error) {
              console.log(error);
            }
          });
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
EntityHistories.findByEntityResource can take an array of entity resources as well
      var apiSession = new Evri.API.Session({'appId':'evri-recipe'});
      
      apiSession.models.Zeitgeist.getPopularEntitiesByType("person", {
        onComplete: function (entityList) {
          console.log(entityList);
      
          var entityResources = [];
      
          for ( var i = 0 ; i < entityList.entities.length ; i++ ) {
            entityResources.push(entityList.entities[i].resource);
          }
      
          apiSession.models.EntityHistories.findByEntityResource(entityResources, {
            onComplete: function (entityHistories) {
              console.log(entityHistories);
            },
            onFailure: function (error) {
              console.log(error);
            }
      
          });
        },
        onFailure: function (error) {
          console.log(error);
        }
      });
      
top