is everything ok now?

17
ForSight API Documentation Updated 9/12/11 Contents Introduction 2 Setup .................................................... 2 Basics .................................................... 2 Endpoints .................................................. 3 Example ................................................... 3 Errors .................................................... 3 API Methods 4 Monitor List ................................................ 4 Monitor Detail ............................................... 5 Monitor Results .............................................. 6 Monitor Content Sources ......................................... 8 Monitor Posts ................................................ 9 Word Cloud ................................................. 12 Monitor Authors .............................................. 12 Monitor Training .............................................. 14 Content Upload ............................................... 15 ForSight API Proprietary and Confidential 1

Upload: dreammalar

Post on 15-Jan-2015

355 views

Category:

Documents


0 download

DESCRIPTION

time to go live

TRANSCRIPT

Page 1: Is everything ok now?

ForSight API Documentation

Updated 9/12/11

Contents

Introduction 2Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Endpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

API Methods 4Monitor List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Monitor Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Monitor Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Monitor Content Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Monitor Posts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Word Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Monitor Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Monitor Training . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Content Upload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

ForSight API Proprietary and Confidential 1

Page 2: Is everything ok now?

Introduction

Crimson Hexagon’s ForSight platform has an API allowing programmatic access to some of its analysiscapabilities. There are two main functions of the API:

Retrieving Results You can use the API to access the analysis results computed by the system, forexample to retrieve the number of posts found per day, the percentage of posts in each category, etc.

• Intended use: To integrate ForSight data into third-party systems, such as custom dashboards orportals, or to programmatically extract data for offline analysis.

• Alternatives: If you just need to export per-monitor results in an Excel-compatible format, youcan do so directly from the ForSight web interface, without using this API.

Uploading Content You can also use the API to upload content (posts, documents, etc.) for analysis. Allcontent uploaded with the API will be accessible only to your company, not other Crimson Hexagoncustomers.

• Intended use: To analyze content from offline sources (e.g. customer surveys), content fromprotected online sources (e.g. password-protected forums), or content that you’ve collected orprocessed in some special way.

• Alternatives: If the content you want to analyze resides in a publically-accessible blog, RSS feed,or forum site, then using the content API is probably not necessary, as we either have the contentin our system already or can easily register it so that it’s included.

Setup

Before you use the API, Crimson Hexagon will provision an API account username and password that areseparate from the credentials you use on our website. These credentials can then be used to call any of theAPI’s described in this document.

If you’d like to use the content upload or monitor training API methods, we’ll also create one or morenew ”content types” for your use. Each post or document that you upload with the API will be tagged withone of these customer-specific types. If you upload documents using the content upload API, these typeswill appear in our user interface as checkboxes, alongside the existing checkboxes for Blogs, Forums, Twitter,etc. You can then set up a monitor to include content from one or more of your custom types, either aloneor in combination with blogs, Twitter, and other existing types. Other Crimson Hexagon customers will notsee the checkboxes for your content types, of course.

Basics

The API consists of REST-style HTTPS endpoints located at https://forsight.crimsonhexagon.com/api/*,where the * is replaced by a specific path (described below).

• Authentication: HTTP Basic Authentication is used to validate your API username and password,and an HTTP 401 or 403 response will be returned if the credentials are missing or invalid (see theErrors section below).

• Input: All endpoints require one or more query string parameters. The one parameter required inall cases is version, which must be set to 1 currently. Additional endpoint-specific parameters aredescribed below.

• Response: HTTP 200 is returned upon success; other status codes are returned for various error casesas specified in the Errors section below. The response body will consist of UTF-8 encoded JSON datacontaining various parameters described below.

ForSight API Proprietary and Confidential 2

Page 3: Is everything ok now?

Endpoints

The following API endpoints are available. Each of these is documented in detail in the following sections.

• Monitor List (https://forsight.crimsonhexagon.com/api/monitor/list): returns a list of moni-tors visible to the specified user.

• Monitor Detail (https://forsight.crimsonhexagon.com/api/monitor/detail): returns detailedinformation about the specified monitor, including information about each of the mointor’s categories,if any.

• Monitor Results (https://forsight.crimsonhexagon.com/api/monitor/results): returns analysisresults for the specified monitor and range of dates.

• Monitor Content Sources (https://forsight.crimsonhexagon.com/api/monitor/sources): returnsdata about volume from specific content sources for the specified monitor and range of dates.

• Monitor Posts (http://forsight.crimsonhexagon.com/api/monitor/posts): returns posts fromthe specified monitor and range of dates.

• Word Cloud (http://forsight.crimsonhexagon.com/api/monitor/wordcloud): returns data thatcan be used to generate a word cloud based on this monitor’s posts from the specified range of dates.

• Monitor Authors (http://forsight.crimsonhexagon.com/api/monitor/authors): returns Twitterauthor data for the specified monitor and range of dates.

• Monitor Training (https://forsight.crimsonhexagon.com/api/monitor/training): adds the in-cluded document as a training document for the specified category and monitor.

• Content Upload (https://forsight.crimsonhexagon.com/api/content/upload): uploads contentinto ForSight for later analysis.

Example

For example, from the Linux or OSX command line, you can use the wget program to get a list of yourmonitors as follows:

wget --no-check-certificate --http-user=myusername --http-password=mypassword

--auth-no-challenge "https://forsight.crimsonhexagon.com/api/monitor/list?

username=myusername&version=1"

Errors

If the API call was successful, an HTTP 200 status code is returned, along with a JSON response as describedabove. If an error occurred, one of the following status codes will be returned:

• HTTP 401: Returned if the caller did not supply HTTP authentication credentials, or if the credentialswere not of the expected type.

• HTTP 403: Returned if the username and password were not found in the ForSight system, or if theForSight user does not have access to the requested data (for example, attempting to access a usernameor monitor id that you’re not allowed to see).

• HTTP 500: Returned if a required query string parameter was missing or invalid, the requested datawas not found (i.e. the username or monitor id was bogus), or an internal error occurred.

For HTTP 403 and 500 errors, a JSON response is returned, containing a message explaining the error. Forexample:

{

"status": "error",

"message": "The required parameter ’id’ was missing",

}

ForSight API Proprietary and Confidential 3

Page 4: Is everything ok now?

Testing

As you develop your code to use the API, please inform Crimson Hexagon support so that our technicalstaff is aware of your intended use cases. This will help us identify potential errors and recommend the mosteffective use of the API.

Since the content upload API adds data to the system, special care should be taken to ensure that thedata that’s uploaded is valid and will work as desired. Upon request, Crimson Hexagon can make availableour QA system on a limited basis, to allow you to upload content without it being added to our productionsystem. This will help you ensure that your content is correctly formatted, and allow Crimson Hexagonto examine your content files by hand if necessary before you start uploading content into the productionsystem.

If you have any other questions using the API, please contact Crimson Hexagon support and we’ll behappy to connect you to the right member of our development team.

API Methods

Monitor List

The monitor list API endpoint is accessed at https://forsight.crimsonhexagon.com/api/monitor/list.The query-string parameters are:

• version: Required; must be equal to 1.

• username: Required; specifies which ForSight user’s monitors should be returned. Note that thisusername is not necessarily the same as the username used for API authentication; typically the APIuser has access to multiple ForSight users (e.g. all users for your company).

The result is a JSON-formatted list of monitor information. Example request:

https://forsight.crimsonhexagon.com/api/monitor/list?version=1&username=fred

Example response:

{

"status": "success",

"version": 1,

"monitors": [{

"id": 123,

"name": "My monitor",

"type": "buzz",

"resultsStart": "2010-01-01",

"resultsEnd": "2010-02-01",

},{

"id": 234,

"name": "Another monitor",

"type": "opinion"

}]

}

The top-level JSON object has three attributes:

• status is the API status, either success or error. See the Errors section above.

• version is the API version, currently always 1.

• monitors is a JSON array of zero or more monitors that are visible to the specified user.

ForSight API Proprietary and Confidential 4

Page 5: Is everything ok now?

Each monitor has a number of attributes:

• id is the internal identifier of the monitor in the ForSight system. This value can be used later to trainor gather more information about the monitor (see below).

• name is the name of the monitor, as entered by the user that created it.

• type is the monitor’s type, either buzz or opinion.

• resultsStart and resultsEnd are the start and end dates (both inclusive) of available monitor results.These attributes are not present if no results are available for the monitor.

Monitor Detail

The monitor detail API endpoint is accessed at https://forsight.crimsonhexagon.com/api/monitor/detail.It provides information about the monitor’s categories. The query-string parameters are:

• version: Required; must be equal to 1.

• id: Required, must be the id of an opinion monitor; specifies which monitor’s details should be returned.This id can be obtained from the monitor list API method.

The result is a JSON-formatted list of monitor information. Example request:

https://forsight.crimsonhexagon.com/api/monitor/detail?version=1&id=11235813

Example response:

{

"status": "success",

"version": 1,

"name":"My monitor"

"description":"Trying to find out about our product"

"resultsStart": "2010-01-01",

"resultsEnd": "2010-02-01",

"categories": [{

"id": 123,

"name":"Loves Product",

"group":"Positive",

"trainingDocs":8,

"status":"red",

"hidden":false

},{

"id":456,

"name":"Hates Product",

"group":"Negative",

"trainingDocs":13,

"status":"yellow",

"hidden":false

},{

"id":789,

"name":"Irrelevant",

"group":"Irrelevant",

"trainingDocs":97,

"status":"green",

"hidden":true

}]

}

ForSight API Proprietary and Confidential 5

Page 6: Is everything ok now?

The top-level JSON object has several attributes:

• status is the API status, either success or error. See the Errors section above.

• version is the API version, currently always 1.

• name is the name of the monitor, as entered by the user that created it.

• group is the name of the group the category is associated with, as entered by the user that created it.

• description is the description of the monitor, as entered by the user that created it. This attributeis not present if no description has been entered.

• resultsStart and resultsEnd are the start and end dates (both inclusive) of available monitor results.These attributes are not present if no results are available for the monitor.

• categories is a JSON array of the categories of the specified monitor.

Each category has a number of attributes:

• id is the internal identifier of the category in the ForSight system.

• name is the name of the category, as entered by the user that created it.

• trainingDocs is the number of training documents that have been added to the category.

• status represents the quality of the current training for this category. green indicates an excellentamount of training, yellow indicates an acceptable amount of training, and red indicates too littletraining.

• hidden is a boolean value representing whether or not the category will be hidden in the final results.Hidden categories usually correspond to ”not relevant” or ”junk” content.

Monitor Results

The monitor results API endpoint is accessed at https://forsight.crimsonhexagon.com/api/monitor/results.The query-string parameters are:

• version: Required; must be equal to 1.

• id: Required; specifies which ForSight monitor’s results should be returned. This id can be obtainedfrom the monitor list API.

• start and/or end: Optional; specifies start and/or end dates in YYYY-MM-DD format. If either orboth are included, the returned results will be limited to those on or after the start date and/or thosebefore the end date (i.e. the end date is exclusive).

The result is a JSON-formatted list of monitor results. Example request:

https://forsight.crimsonhexagon.com/api/monitor/results?version=1&id=123&start=2010-01-01

&end=2010-01-02

Example response for a buzz monitor:

{

"status": "success",

"version": 1,

"results": [{

"numberOfDocuments": 576,

"startDate": "2010-01-01",

ForSight API Proprietary and Confidential 6

Page 7: Is everything ok now?

"endDate": "2010-01-02",

"creationDate":"2010-03-15 00:14:05",

"topics": [{

"topic": "Volkswagen",

"totalCount": 276,

"positiveCount": 50,

"neutralCount": 200,

"negativeCount": 26,

"voxScore": 63,

},{

"topic": "Subaru",

"totalCount": 300,

"positiveCount": 100,

"neutralCount": 200,

"negativeCount": 0,

"voxScore": 79,

}]

}]

}

The top-level JSON object has three attributes:

• status is the API status, either success or error. See the Errors section above.

• version is the API version, currently always 1.

• results is a JSON array of zero or more results for the monitor. Typically there will be one resultper day for the selected day range, though sometimes for opinion monitors each result will include arange of days if the daily post volume is low.

Each result has several attributes:

• numberOfDocuments is the total number of posts analyzed for all topics (for buzz monitors) or allcategories (for opinion monitors).

• startDate is the starting date (inclusive) for this result, in YYYY-MM-DD format.

• endDate is ending date (exclusive) for this result, in YYYY-MM-DD format. For example, a range of2010-01-01 to 2010-01-04 means a result for three days (for the 1st, 2nd, and 3rd of January).

• creationDate is the datetime that this result was created, in GMT, in YYYY-MM-DDThh:mm:ssformat.

• topics (for buzz monitors) or categories (for opinion monitors) are JSON arrays of the results foreach buzz topic or opinion category, respectively.

Buzz monitor topics each contain the following attributes:

• topic is the user-entered name of the topic being monitored. There are typically 1-5 topics per buzzmonitor.

• totalCount is total number of posts found for this topic’s keywords for the specified day. Note thatthe total and other counts have been adjusted to remove spam and irrelevant posts.

• positiveCount, negativeCount, and neutralCount are the number of posts classified by sentimentcategory by ForSight’s algorithms.

• voxScore is ForSight’s proprietary 1-100 score, taking into account the number of posts, the sentimentof the posts, and the ranking and influences of the posts and authors. Higher scores indicate that thetopic is relatively prominent and positive on the social web.

ForSight API Proprietary and Confidential 7

Page 8: Is everything ok now?

Opinion monitor categories each contain the following attributes:

• category is the user-entered name of the opinion category. There are typically 2-8 categories peropinion monitor.

• proportion is the percentage of posts in this category, based on ForSight’s algorithms. The sum ofthe proportions for all categories will be 100%.

• hidden is either true or false, based on whether the user intended the category’s results to bevisible. ForSight’s web interface normally does not display the hidden categories, and renormalizes theproportions of the non-hidden categories to sum to 100%.

Monitor Content Sources

The monitor content sources API can be accessed at https://forsight.crimsonhexagon.com/api/monitor/sources.The query-string parameters are:

• version: Required; must be equal to 1.

• id: Required, must be the id of an opinion monitor; specifies which ForSight monitor’s results shouldbe returned. This id can be obtained from the monitor list API.

• start and/or end: Optional; specifies start and/or end dates in YYYY-MM-DD format. If either orboth are included, the returned results will be limited to those on or after the start date and/or thosebefore the end date (i.e. the end date is exclusive).

The result is a JSON-formatted list of results, included content source data. Example request:

https://forsight.crimsonhexagon.com/api/monitor/sources?version=1&id=123

&start=2010-01-01&end=2010-01-03

Example response:

{

"status": "success",

"version": 1,

"sources": [{

"date": "2010-01-01",

"Blogs": 512,

"Forums": 256,

"topSites": {

"cnet.com": 15,

"gizmodo.com": 9,

...

}

},{

"date": "2010-01-02",

"Blogs": 191,

"Forums": 56,

"topSites": {

"cnet.com": 17,

"engadget.com": 6,

...

}

}]

}

ForSight API Proprietary and Confidential 8

Page 9: Is everything ok now?

The top-level JSON object has three attributes:

• status is the API status, either success or error. See the Errors section above.

• version is the API version, currently always 1.

• sources is a JSON array of zero or more pieces of content source data for the monitor. Source data iscollected every day, whether the opinion monitor has run or not.

Each object has several attributes:

• date is the day the content was published, in YYYY-MM-DD format.

• sources is a JSON object containing the content sources enabled for the monitor and the number ofdocuments this monitor gathered from each source for the specified date. Content sources may includeblogs, forums, news, Twitter, or custom content sources.

• topSites is a JSON object containing a list of the sites with the largest numbers of posts for thismonitor for this day. This list will contain up to 10 sites. Note that our count is based on domainname, not the entire URL of a post. That is, blog1.blogspot.com and blog2.blogspot.com willcontribute their posts to the blogspot.com count and will not appear in the list.

Monitor Posts

The posts API endpoint is accessed at https://forsight.crimsonhexagon.com/api/monitor/posts. Thequery-string parameters are:

• version: Required; must be equal to 1.

• id: Required, must be id of an opinion monitor; specifies which monitor’s posts should be returned.This id can be obtained from the monitor list API.

• start and/or end: Optional; specifies start and/or end dates in YYY-MM-DD format. If either orboth are included, the returned posts will be limited to those published on or after the start dateand/or those before the end date (i.e. the end date is exclusive).

• filter: Optional; used to narrow in on the type of posts you want. The filter should be a pipe-separated list of field:value pairs, where the value can be a comma-separated list of values. Thefollowing are valid filter strings:

– type:Twitter

– authorRank:10|category:123456,987654

– site:blogspot.com,wordpress.com|keywords:android

There are a limited number of available fields that can be used for filtering. Below we describe thepurpose of each and the possible values it can have.

– author corresponds to Twitter username of the person that wrote a post. Currently this field isnot available for any content source other than Twitter. More than one username can be suppliedin a comma-separated list.

∗ author:joeschmo

∗ author:joeschmo,jane,jack

– authorRank corresponds to the rank of a particular Twitter user. Currently this field is notavailable for any content source other than Twitter. Author rank is a ForSight metric thatdescribes a Twitter user’s reach and authority. Ranks range from 0 to 100, with higher numbersindicating more influential users. Posts returned will be from authors of rank equal to or higherthan the supplied rank. For instance, the filter authorRank:20 will return Twitter posts fromauthors with rank greater than or equal to 20. Only one rank can be supplied.

ForSight API Proprietary and Confidential 9

Page 10: Is everything ok now?

– category corresponds to the id of the monitor’s categories, which can be obtained via the monitordetail API. The posts returned will be those most likely to be in the given categories. If no categoryfilter is provided, this field defaults to the set of unhidden categories.

∗ category:443349

∗ category:3894843,3488229

– keywords corresponds to words that appear in the body of the post. Returned posts will be limitedto those that contain all the required keywords. Phrases should be surrounded by commas.

∗ keywords:android,iphone

∗ keywords:android,"apple iphone"

– site corresponds to the site that published the post. Only top-level websites are valid values forthis field. For instance, wordpress.com is valid, but myblog.wordpress.com and wordpress.com/myblog

are not. Sites should not be preceded by ”www.” or ”http://”.

∗ site:cnn.com

∗ site:nytimes.com,blogspot.com,cnn.com

– type corresponds to the content source of a post. The available types here match those seem onthe Content Sources tab on our web interface and those that appear in Monitor Content SourcesAPI results. For this field, you can supply a comma-separated list of the following strings: Blogs,Forums, News, Facebook, Twitter, Comments. Note that these values are case sensitive.

∗ type:Twitter

∗ type:Blogs,Forums,Comments

The result is a JSON-formatted list of up to 500 sample posts. Example request:

https://forsight.crimsonhexagon.com/api/monitor/posts?version=1&id=123&start=2010-01-01

&end=2010-01-02&filter=type:Blogs|category:3485732

Example response:

{

"status": "success",

"version": 1,

"posts": [{

"title": "New puppy!",

"url": "http://myblog.wordpress.com/?p=234",

"date": "2010-01-01",

"author": "Joe",

"language":"en",

"type":"Blogs",

"contents": "I just got a new puppy! ... ",

"assignedCategoryId": 1234,

"assignedCategoryName": "Likes dogs",

"categoryScores": [{

"categoryId":1234,

"categoryName":"Likes dogs",

"score":1.0

},{

"categoryId":5678,

"categoryName":"Likes cats",

"score":.456

},{

"categoryId":2468,

"categoryName":"Irrelevant",

ForSight API Proprietary and Confidential 10

Page 11: Is everything ok now?

"score":.138

}]

}]

}

The top-level JSON object has three attributes:

• status is the API status, either success or error. See the Errors section above.

• version is the API version, currently always 1.

• posts is a JSON array of zero or more sample posts for the monitor. This includes training documentsand posts shown on the Sample Posts tab in our online interface.

Each post has several attributes:

• title is the title of the post.

• url is the post’s original URL.

• date is the date the post was published, in YYYY-MM-DDThh:mm:ss format.

• location is the location of the person that authored the post. Note that this information is onlyavailable for a subset of posts from twitter.com.

• author is an identifier associated with the person who published the post.

• language is an ISO 639-1 code describing the language the post is written in. These classifications areprovided by our content partners and are sometimes absent or incorrect.

• type is the content type of this post. Possible values are: Blogs, Forums, News, Facebook, Twitter,Comments, Flickr, YouTube, and Custom.

• contents is the body of the post. For longer posts, we may only include the beginning of the body.

• assignedCategoryId is the internal ForSight identifier of the monitor category to which the postbelongs, if any. A post will have an assigned category only if a human has read it and added it to acategory.

• assignedCategoryName is the name of the monitor category to which the post belongs, if any. Thisname is chosen by the user who created the monitor. A post will have an assigned category only if ahuman has read it and added it to a category.

• categoryScores is a JSON array containing the scores of this post relative to each of the monitor’scategories. The array contains a JSON object for each category. categoryScores may not be present ifthis document was assigned a category during the monitor training process (before analysis) as opposedto from the sample posts tab (after analysis).

Each category score object has three attributes:

• categoryId is the internal ForSight identifier of this category.

• categoryName is the name of this category, chosen by the user that created the monitor.

• score is a string representation of a float between 0 and 1.0, with a higher score representing a higherlikelihood that this post belongs in this category. If a human has assigned this post to this category(the assignedCategory attributes are present), the score will be 1.0.

ForSight API Proprietary and Confidential 11

Page 12: Is everything ok now?

Word Cloud

The word cloud API endpoint is accessed at https://forsight.crimsonhexagon.com/api/monitor/wordcloud.The query-string parameters are:

• version: Required; must be equal to 1.

• id: Required, must be id of an opinion monitor; specifies which monitor’s posts should be returned.This id can be obtained from the monitor list API.

• start and/or end: Optional; specifies start and/or end dates in YYY-MM-DD format. If either orboth are included, the returned posts will be limited to those published on or after the start dateand/or those before the end date (i.e. the end date is exclusive).

• filter: Optional; used to narrow in on the type of posts you want. The filter should be a pipe-separated list of field:value pairs as described above.

The result is JSON-formatted data that can be used to generate a word cloud. Example request:

https://forsight.crimsonhexagon.com/api/monitor/wordcloud?version=1&id=123&start=2010-01-01

&end=2010-01-02

Example response:

{

"status": "success",

"version": 1,

"data": {

"microsoft": 56.35983,

"apple":78.987844,

"computer":93.482872,

"processor":14.934588,

...

}

}

The top-level JSON object has three attributes:

• status is the API status, either success or error. See the Errors section above.

• version is the API version, currently always 1.

• data is a JSON object containing 100 pairs of one term and one floating point number between 0 and100 representing how frequently the term occurs. This number has been scaled to make it useful forfont size determination. This data is generated using 300 documents randomly selected from the pooldefined by the submitted start, end, and filter parameters. The words included in the response arethe 100 words most frequently used in the documents, excluding common English words. Note that weare counting the total number of times each word appears in the documents, not the number of postsin which each word appears.

Monitor Authors

ForSight’s author analysis capability is only available for Twitter data, so this method should only be calledfor monitors that include Twitter data. The monitor authors API can be accessed athttps://forsight.crimsonhexagon.com/api/monitor/authors. The query-string parameters are:

• version: Required; must be equal to 1.

ForSight API Proprietary and Confidential 12

Page 13: Is everything ok now?

• id: Required, must be the id of an opinion monitor; specifies which ForSight monitor’s results shouldbe returned. This id can be obtained from the monitor list API. This monitor must analyze Twitterdata.

• start and/or end: Optional; specifies start and/or end dates in YYYY-MM-DD format. If either orboth are included, the returned results will be limited to those on or after the start date and/or thosebefore the end date (i.e. the end date is exclusive).

The result is a JSON-formatted list of results, including author data. Example request:

https://forsight.crimsonhexagon.com/api/monitor/authors?version=1&id=123

&start=2010-01-01&end=2010-01-03

Example response:

{

"status": "success",

"version": 1,

"authors": [{

"date": "2010-01-01",

"countsByAuthor": {

"twitterJoe": 5,

"plain_jane": 3,

...

}

"authorRanks": {

"mahtweets": 79,

"jennyp": 53,

...

}

"numberOfAuthors": 512,

"docsPerAuthor": 1.567,

},

...

}]

}

The top-level JSON object has three attributes:

• status is the API status, either success or error. See the Errors section above.

• version is the API version, currently always 1.

• authors is a JSON array of zero or more pieces of author data for the monitor. Author data is collectedevery day, whether the opinion monitor has run or not.

Each post has several attributes:

• date is the day the content was published, in YYYY-MM-DD format.

• countsByAuthor is a JSON object containing the Twitter usernames of the ten most prolific authorsfor this day, and the number of posts attributed to each of them. The posts included in these countsare those published on date that match this monitor’s keywords.

• authorRanks is a JSON object containing the Twitter usernames of the ten highest-ranked authors forthis day, and their rank scores. These authors may or may not include those in the countsByAuthor

object. Scores are numbers between 1 and 100 with higher numbers indicating Twitter users with moreinfluence.

ForSight API Proprietary and Confidential 13

Page 14: Is everything ok now?

• numberOfAuthors is the total number of unique Twitter users who published tweets matching thismonitor’s keywords on this day.

• docsPerAuthor is the average number of Tweets published on this day per unique author. Only Tweetsmatching this monitor’s keywords are included in this calculation.

Monitor Training

The monitor training API endpoint is accessed at https://forsight.crimsonhexagon.com/api/monitor/train.The query-string parameters are:

• version: Required; must be equal to 1.

• id: Required, must be the id of an opinion monitor; specifies which monitor this training documentshould be added to. This id can be obtained from the monitor list API method.

The monitor training API requires an HTTP POST, not a GET. The posted data will consist of the documentyou want to upload and the ids of the relevant monitor and category, in JSON format as described below.Uploading posts using this method will allow you to use them as training documents for a specific monitor.The post will not appear in your search results or be available as a training document for other monitors.

Example usage:

wget --no-check-certificate --http-user=myusername --http-password=mypassword

--auth-no-challenge --post-file=document.json "https://forsight.crimsonhexagon.com/

api/monitor/train?version=1&id=1234"

The posted data must be UTF8-encoded JSON data, constructed like so:

{

"monitorid":123456,

"categoryid":6779843,

"document": {

"title": "My day at the fair",

"date": "2010-04-19T23:14:00",

"author": "me",

"url": "http://www.blog.com/2010/04/19/my-day-at-the-fair",

"contents": "Today I went to the fair and..."

"language": "en"

}

}

The single top-level JSON object has several attributes:

• monitorid is the identifier of the monitor for which you are uploading a training document. This idcan be obtained from the monitor list API method.

• categoryid is the identifier of the category for which you are uploading a training document. Thisid can be obtained from the monitor detail API method. It must correspond to a category associatedwith the monitor specified by monitorid.

• document is the document you want to upload.

Each document has several attributes:

• title is the title of the post, article, message, etc. It is used for analysis and displayed in the ForSightuser interface when showing lists of posts. If the post doesn’t have a title, you may want to extract itsfirst few words and use those.

ForSight API Proprietary and Confidential 14

Page 15: Is everything ok now?

• date is the date the post was created (not the date it was uploaded to ForSight), in ISO 8601 formatwith combined data and time but without a time zone (the time zone is assumed to be GMT).

• author can be a username, actual name, link to a blog or profile page, etc. The author is not used foranalysis but is displayed to the user in the ForSight user interface, so you can synthesize a reasonablevalue (e.g. ”Anonymous poster #56789”) if a real author name is not available.

• url is the URL of the specific post, so the ForSight user can navigate to original source site and seethe post in context.

• contents is the text of the post to be analyzed. It should be no more than 16k characters long.Non-ASCII text is acceptable (accent marks, symbols, multi-byte international characters, etc.); justremember that the entire JSON payload should always be UTF-8 encoded.

• language is a two-letter ISO 639-1 language code. If you don’t know the language of your posts, orit’s not relevant to your analysis (e.g. everything is presumed to be English), just use en for all posts.

Upon successful upload, the API returns an HTTP 200 response code with a JSON-formatted response bodylike the following:

{

"status": "success",

"version": 1

}

The JSON response object normally has two attributes:

• status is the API status, either success or error. Possible sources of HTTP 500 errors are missingparameters, malformed dates or URLs, garbled JSON formatting, etc. If an error occurs, the messageattribute will indicate the problem.

• version is the API version, currently always 1.

Content Upload

The content upload API endpoint is accessed at https://forsight.crimsonhexagon.com/api/content/upload.The only query string parameter is the required version=1.

The content upload API requires an HTTP POST, not a GET. The posted data will consist of thedocuments you want to upload, in JSON format as described below. Once uploaded, the content willavailable to your monitor for analysis (see the Setup section above), but note that it may take up to 6 hoursfor this to happen.

Example usage:

wget --no-check-certificate --http-user=myusername --http-password=mypassword

--auth-no-challenge --post-file=content.json "https://qa.crimsonhexagon.com/

api/content/upload?version=1"

The posted data must be UTF8-encoded JSON data. It’s easiest to look at an example first:

{

"items": [{

"title": "Test title",

"date": "2010-01-26T16:14:00",

"author": "me",

"url": "http://www.crimsonhexagon.com",

"contents": "blah blah blah",

"language": "en",

"type": "TYPE1"

}]

}

ForSight API Proprietary and Confidential 15

Page 16: Is everything ok now?

The top-level JSON object has one attribute, items, a JSON array of one or more content items to addto the system. No more than 1,000 items can be uploaded at a time (though for practical purposes it maybe better to use a much smaller number, for example to make debugging easier in case there are errors inthe data). There are 6 required attributes of each item:

• title is the title of the post, article, message, etc. It is included in analysis and displayed in theForSight user interface when showing lists of posts. If your data doesn’t have actual titles, then supplysomething equivalent that will be meaningful to the user. (For example, a Twitter status update couldbe titled ”Post from @somebody”.)

• date is the date the post was created (not the date is was uploaded to ForSight), in ISO 8601 formatwith combined data and time but without a time zone (the time zone is assumed to be GMT). ForSightalways analyzes content within a specific date range (typically one day at a time, or longer periods forlower-volume content), so correct dates are required to be able to analyze posts over time.

• author can be a username, actual name, link to a blog or profile page, etc. The author is not used foranalysis but is displayed to the user in the ForSight user interface, so you can synthesize a reasonablevalue (e.g. ”Anonymous poster #56789”) if a real author name is not available.

• url is the URL of the specific post, so the ForSight user can navigate to original source site andsee the post in context. Each document must have a unique URL. It’s likely that posts uploadedwith the content API will not have URL’s at all (for offline content or processed content) or haveURL’s that aren’t navigable (for private content). Since a syntactically-valid URL is required for eachpost, Crimson Hexagon recommends synthesizing a unique URL’s in these cases, based on some logicalstructure of your content. For example, if you’re uploading responses to multiple customer surveys, youmight use URL’s like http://mycompany.com/surveys/ survey1/post12345. The URL’s would notactually exist at mycompany.com, but would simply serve to partition your uploaded content. Whensetting up a monitor in the ForSight user interface, you could then include keyword terms to limitanalysis to only some of your posts, e.g. url:survey1 to only find posts from the first survey.

• contents is the text of the post to be analyzed. It should be no more than 16k characters long.Non-ASCII text is acceptable (accent marks, symbols, multi-byte international characters, etc.); justremember that the entire JSON payload should always be UTF-8 encoded.

• language is a two-letter ISO 639-1 language code. If you don’t know the language of your posts, orit’s not relevant to your analysis (e.g. everything is presumed to be English), just use en for all posts.

• type must be one of the type codes supplied to you by Crimson Hexagon when your API accesswas provisioned. As described above, each type code is one-to-one associated with a checkbox in theForSight user interface, and can be used only by your company.

Upon successful upload, the API returns an HTTP 200 response code with a JSON-formatted responsebody like the following:

{

"status": "success",

"version": 1

"uploadCount": 123

}

The JSON response object normally has three attributes:

• status is the API status, either success or error. See the Errors section above. Possible sources ofHTTP 500 errors are missing parameters, malformed dates or URLs, garbled JSON formatting, etc. Ifan error occurs, the message attribute will indicate the problem and where possible the specific itemnumber.

• version is the API version, currently always 1.

ForSight API Proprietary and Confidential 16

Page 17: Is everything ok now?

• uploadCount is the number of items uploaded, and is a simple way to confirm that the API understoodyour request.

ForSight API Proprietary and Confidential 17