API Reference
- Usage
- Result Methods
- User Methods
- Topic Methods
- Preference Methods
- THAY Methods
- Feed Methods
- Special Methods
Usage
HTTP Encoding
API calls are made over an HTTP connection using either GET or POST requests. Returned values are JSON encoded.
The base URL for requests is http://api.hunch.com/api/v1/. For example, the get-recommendations call has the URL http://api.hunch.com/api/v1/get-recommendations/.
Parameters passed in to each call must be URL-encoded. Any data being written should be sent via POST but GETs are accepted to make testing with a browser easier.
On input, lists should be comma-delimited, for
example topic_ids=list_magazine,list_movie. booleans
should be passed as one of 0, 1, t, f, true, false, True, False, YES, or
NO.
HTTP response codes have their usual meaning: 404 means a named resource was not found, 200 means a succesful response was returned, 401 means authorization failed, etc.
If a callback parameter is passed, then JSONP is
used, returning text/javascript instead of the
usual application/json.
If the boolean suppress_http_errors is true, then
even error responses will have a HTTP response code of 200. This
can be useful for JSONP and certain libraries such as jQuery. The
JSON of the responses will still identify them as errors, as
described below.
Error Responses
If a JSON response is returned, it will have an ok
field that is true if the call succeeded
and false if there was an error. An unsuccesful
response has the form:
{ "ok": false, "errors": [strings], "error_code": number }
errors are error messages and error_code is one of:
- 1 = Authentication error (
auth_token,auth_sig, orapp_idnot correct for this operation) - 2 = App configuration error (
auth_tokennot approvoved etc) - 3 = Invalid request (bad parameters)
- 4 = Exists (trying to create something that already exists)
- 5 = Not found (trying to reference an ID that doesn't exist)
- -1 = Internal error (not your fault; try again)
Result Methods
get-recommendations
get-recommendations returns the most strongly recommended results for the authenticated user or one of their friends, within a set of possible results restricted by topic, site, result id, or location. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
optional | An authorization token, authenticating your app on behalf of the user. | auth_token= |
topic_ids |
optional | List of topic ids. Only results in these topics will be returned as recommendations. | topic_ids= |
sites |
optional | List of site names. Only results from these sites will be returned as recommendations. | sites= |
result_ids |
optional | List of result ids. Only results in this list will be returned as recommendations. | result_ids= |
lat lng radius |
optional | Bounding circle, specified in degrees and miles. Only results in this bounding circle will be returned as recommendations. | lat= |
minlat maxlat minlng maxlng |
optional | Bounding rectangle, specified in degrees. Only results in this bounding rectangle will be returned as recommendations. | minlat= |
query |
optional | A string. Only results whose names or tags contain this string will be returned as recommendations. | query= |
name |
optional | A string. Only results whose names contain this string will be returned as recommendations. | name= |
tags |
optional | A string. Only results whose tags contain this string will be returned as recommendations. | tags= |
urls |
optional | A list of URLs. Only results with URLs in this list will be returned as recommendations. | urls= |
blocked_topic_ids |
optional | List of topic ids. Results in these topics will not be returned as recommendations. | blocked_topic_ids= |
blocked_sites |
optional | List of site names. Results in these sites will not be returned as recommendations. | blocked_sites= |
blocked_result_ids |
optional | List of result ids. These results will not be returned as recommendations. | blocked_result_ids= |
exclude_likes |
optional | A boolean, defaulting to false. If true, results that have been liked by the user will not be returned as recommendations. | exclude_likes= |
exclude_dislikes |
optional | A boolean, defaulting to true. If true, results that have been disliked by the user will not be returned as recommendations. | exclude_dislikes= |
minimal |
optional | A boolean, defaulting to false. If true, only result ids will be returned, without result data such as names and descriptions. | minimal= |
exclude_chains |
optional | A boolean, defaulting to false. If true, results that are known chain businesses will not be returned as recommendations. | exclude_chains= |
likes |
optional | A list of result ids. The user's tastes will temporarily incorporate their positive preference for these results. | likes= |
dislikes |
optional | A list of result ids. The user's tastes will temporarily incorporate their negative preference for these results. | dislikes= |
responses |
optional | A list of Teach Hunch About You response ids. The user's tastes will temporarily incorporate these responses. | responses= |
limit |
optional | An integer, defaulting to 10. At most this many recommendations will be returned. | limit= |
offset |
optional | An integer, defaulting to 0. This many of the top recommendations will be skipped, and only recommendations lower than these will be returned. | offset= |
wildcards |
optional | A boolean, defaulting to false. If true, some recommendations will randomly appear higher than they normally would. | wildcards= |
app_id auth_sig user_id |
optional | Application credentials, proving that the call originated from your app. user_id must be for your app, in which case it can be passed instead of an auth_token. |
app_id= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "is_personalized": boolean, "total": number, "recommendations": [recommendations] }
is_personalized will be true if and only if there was taste data available for the user. total is the total number of recommendations before limit and offset are applied.
recommendations are ordered by score, and each has the form:
{ "result_id": id, "stars": number, "is_predicted": boolean, "score": score, "name": string, "url": url, "image_url": url, "aliases": [ids], "topic_ids": [ids], "preferences": [preferences], "tags": [strings], "urls": [urls], "image_urls": [urls], ... }
Note that recommendations also include a deprecated title field for backwards-compatibility, but you should use the name field instead.
is_predicted will be false if and only if the user has actually rated the item, in which case stars will represent their given rating. aliases is a list of all result ids aliased to this result. topic_ids is a list of the topic ids the result and its aliases were found in. Many results also have other fields, including lat, lng, address, phone, and more.
preferences are ordered by date, unless the authenticated user has a preference in which case it comes first. Each has the form:
{ "user_id": id, "types": [strings], "stars": number, "created": date, "user_name": string, "user_url": url, "user_image_url": url }
get-results
get-results returns a set of results restricted by topic, site, result id, or location. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
optional | An authorization token, authenticating your app on behalf of the user. | auth_token= |
topic_ids |
optional | List of topic ids. Only results in these topics will be returned. | topic_ids= |
sites |
optional | List of site names. Only results from these sites will be returned. | sites= |
result_ids |
optional | List of result ids. Only results in this list will be returned. | result_ids= |
lat lng radius |
optional | Bounding circle, specified in degrees and miles. Only results in this bounding circle will be returned. | lat= |
minlat maxlat minlng maxlng |
optional | Bounding rectangle, specified in degrees. Only results in this bounding rectangle will be returned. | minlat= |
query |
optional | A string. Only results whose names or tags contain this string will be returned. | query= |
name |
optional | A string. Only results whose names contain this string will be returned. | name= |
tags |
optional | A string. Only results whose tags contain this string will be returned. | tags= |
urls |
optional | A list of URLs. Only results with URLs in this list will be returned. | urls= |
blocked_topic_ids |
optional | List of topic ids. Results in these topics will not be returned. | blocked_topic_ids= |
blocked_sites |
optional | List of site names. Results in these sites will not be returned. | blocked_sites= |
blocked_result_ids |
optional | List of result ids. These results will not be returned. | blocked_result_ids= |
minimal |
optional | A boolean, defaulting to false. If true, only result ids will be returned, without result data such as names and descriptions. | minimal= |
limit |
optional | An integer, defaulting to 10. At most this many results will be returned. | limit= |
offset |
optional | An integer, defaulting to 0. This many results will be skipped, and only results after these will be returned. | offset= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "total": number, "results": [results] }
total is the total number of results before limit and offset are applied.
Each result has the form:
{ "result_id": id, "name": string, "url": url, "image_url": url, "aliases": [ids], "topic_ids": [ids], "preferences": [preferences], "tags": [strings], "urls": [urls], "image_urls": [urls], ... }
Note that results also include a deprecated title field for backwards-compatibility, but you should use the name field instead.
aliases is a list of all result ids aliased to this result. topic_ids is a list of the topic ids the result and its aliases were found in. Many results also have other fields, including lat, lng, address, phone, and more.
preferences are ordered by date, unless the authenticated user has a preference in which case it comes first. Each has the form:
{ "user_id": id, "types": [strings], "stars": number, "created": date, "user_name": string, "user_url": url, "user_image_url": url }
get-similar-results
get-similar-results returns the most similar results to a given result, within a set of results restricted by topic, site, result id, or location. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
result_id |
required | A result id. Results will be ranked by their similarity to this result. | result_id= |
topic_ids |
optional | List of topic ids. Only results in these topics will be returned. | topic_ids= |
sites |
optional | List of site names. Only results from these sites will be returned. | sites= |
result_ids |
optional | List of result ids. Only results in this list will be returned. | result_ids= |
lat lng radius |
optional | Bounding circle, specified in degrees and miles. Only results in this bounding circle will be returned. | lat= |
minlat maxlat minlng maxlng |
optional | Bounding rectangle, specified in degrees. Only results in this bounding rectangle will be returned. | minlat= |
query |
optional | A string. Only results whose names or tags contain this string will be returned. | query= |
name |
optional | A string. Only results whose names contain this string will be returned. | name= |
tags |
optional | A string. Only results whose tags contain this string will be returned. | tags= |
urls |
optional | A list of URLs. Only results with URLs in this list will be returned. | urls= |
blocked_topic_ids |
optional | List of topic ids. Results in these topics will not be returned. | blocked_topic_ids= |
blocked_sites |
optional | List of site names. Results in these sites will not be returned. | blocked_sites= |
blocked_result_ids |
optional | List of result ids. These results will not be returned. | blocked_result_ids= |
limit |
optional | An integer, defaulting to 10. At most this many results will be returned. | limit= |
offset |
optional | An integer, defaulting to 0. This many results will be skipped, and only results after these will be returned. | offset= |
wildcards |
optional | A boolean, defaulting to false. If true, some results will randomly appear higher than they normally would. | wildcards= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "results": [results] }
results are ordered by score, and each has the form:
{ "score": number, "result_id": id, "name": string, "url": url, "image_url": url }
flag-result
flag-result flags a result for review, in the context of a given topic. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
result_id |
required | Result id, identifying the result to flag. | result_id= |
topic_id |
required | Topic id, identifying the topic in which the result should be flagged. | topic_id= |
message |
optional | String describing the reason for the flag. | message= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true }
User Methods
get-auth-token
get-auth-token returns an authentication token for the authentication token key received after the user is redirected from http://hunch.com/authorize/. Alternatively, trusted apps can authenticate using another auth_token or basic_auth. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
app_id auth_sig |
required | Application credentials, proving that the call originated from your app. | app_id= |
auth_token_key |
optional | An authorization token key, received in the redirect url from http://hunch.com/authorize/. | auth_token_key= |
auth_token |
optional | An authorization token, authenticating your app on behalf of the user. | auth_token= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "user_id": id, "auth_token": token }
get-token-status
get-token-status returns the status of the given authentication token, indicating whether the token has been accepted or rejected by the user. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
app_id auth_sig |
required | Application credentials, proving that the call originated from your app. | app_id= |
token |
required | An authorization token, received from get-auth-token. |
token= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "status": string }
status is either 'pending', 'accepted', or 'rejected'.
get-user
get-user returns information about the authenticated user, or another specified Hunch user. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
optional | An authorization token, authenticating your app on behalf of the user. | auth_token= |
user_id |
optional | A Hunch user id. If provided, this user's information will be returned. Otherwise, the authenticated user's information will be returned. | user_id= |
limit |
optional | An integer, defaulting to 0. At most this many of the user's feed recommendations will be returned. | limit= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "username": string, "url": string, "image_url": string, "rating_count": number, "save_count": number, "followee_count": number, "follower_count": number, "feed_recommendation_count": number, "feed_recommendations": [results], "name": string, "first_name": string, "about": string, "website": string, "address": string, "lat": number, "lng": number, "tags": [strings]}
get-friends
get-friends returns the friends of the authenticated user. This includes their mutual Hunch followers, mutual Twitter followers if they are Twitter-connected, and Facebook friends if they are Facebook-connected. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
sites |
optional | List of site names. Only friends from these sites will be returned. | sites= |
friend_ids |
optional | List of user ids. Only friends in this list will be returned. | friend_ids= |
sort |
optional | A string, identifying a key to sort friends by. Friends will be returned in order of this key, or randomly if 'random' is passed. | sort= |
reverse |
optional | A boolean, defaulting to false. Reverses the order in which friends are returned. | reverse= |
limit |
optional | An integer, defaulting to 10. At most this many friends will be returned. | limit= |
offset |
optional | An integer, defaulting to 0. This many friends will be skipped, and only friends after that will be returned. | offset= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "total": number, "friends": [friends] }
total is the total number of friends before limit and offset are applied.
Each friend has the form:
{ "user_id": id, ... }
Most friends will have several additional fields, including name, first_name, last_name, birthday, gender, and more.
get-tastemates
get-tastemates returns the most similar friends of the authenticated user, in terms of their affinity to a set of results restricted by topic, site, result id, or location. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
topic_ids |
optional | List of topic ids. Only results in these topics will affect similarities. | topic_ids= |
sites |
optional | List of site names. Only results from these sites will affect similarities. | sites= |
result_ids |
optional | List of result ids. Only results in this list will affect similarities. | result_ids= |
lat lng radius |
optional | Bounding circle, specified in degrees and miles. Only results in this bounding circle will affect similarities. | lat= |
minlat maxlat minlng maxlng |
optional | Bounding rectangle, specified in degrees. Only results in this bounding rectangle will affect similarities. | minlat= |
query |
optional | A string. Only results whose names or tags contain this string will affect similarities. | query= |
name |
optional | A string. Only results whose names contain this string will affect similarities. | name= |
tags |
optional | A string. Only results whose tags contain this string will affect similarities. | tags= |
urls |
optional | A list of URLs. Only results with URLs in this list will affect similarities. | urls= |
blocked_topic_ids |
optional | List of topic ids. Results in these topics will not affect similarities. | blocked_topic_ids= |
blocked_sites |
optional | List of site names. Results in these sites will not affect similarities. | blocked_sites= |
blocked_result_ids |
optional | List of result ids. These results will not affect similarities. | blocked_result_ids= |
limit |
optional | An integer, defaulting to 10. At most this many tastemates will be returned. | limit= |
offset |
optional | An integer, defaulting to 0. This many tastemates will be skipped, and only tastemates after these will be returned. | offset= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "tastemates": [tastemates] }
tastemates are ordered by score, and each has the form:
{ "user_id": id, "score": number, ... }
Most tastemates will have several additional fields, including name, first_name, last_name, birthday, gender, and more.
get-recommendees
get-recommendees returns the authenticated user's friends for whom the given item is most strongly recommended. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
result_id |
required | A result id. Users will be ranked by their affinity for this result. | result_id= |
limit |
optional | An integer, defaulting to 10. At most this many users will be returned. | limit= |
offset |
optional | An integer, defaulting to 0. This many users will be skipped, and only users after these will be returned. | offset= |
wildcards |
optional | A boolean, defaulting to false. If true, some users will randomly appear higher than they normally would. | wildcards= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "recommendees": [recommendees] }
recommendees are ordered by score, and each has the form:
{ "user_id": id, "score": number, ... }
Most recommendees will have several additional fields, including name, first_name, last_name, birthday, gender, and more.
Topic Methods
get-result-topics
get-result-topics searches within the same set of possible results as get-results, returning all topics containing those results. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
topic_ids |
optional | List of topic ids. Only results in these topics will be searched. | topic_ids= |
sites |
optional | List of site names. Only results from these sites will be searched. | sites= |
result_ids |
optional | List of result ids. Only results in this list will be searched. | result_ids= |
lat lng radius |
optional | Bounding circle, specified in degrees and miles. Only results in this bounding circle will be searched. | lat= |
minlat maxlat minlng maxlng |
optional | Bounding rectangle, specified in degrees. Only results in this bounding rectangle will be searched. | minlat= |
query |
optional | A string. Only results whose names or tags contain this string will be searched. | query= |
name |
optional | A string. Only results whose names contain this string will be searched. | name= |
tags |
optional | A string. Only results whose tags contain this string will be searched. | tags= |
urls |
optional | A list of URLs. Only results with URLs in this list will be searched. | urls= |
blocked_topic_ids |
optional | List of topic ids. Results in these topics will not be searched. | blocked_topic_ids= |
blocked_sites |
optional | List of site names. Results in these sites will not be searched. | blocked_sites= |
blocked_result_ids |
optional | List of result ids. These results will not be searched. | blocked_result_ids= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "topics": [topics] }
Each topic has the form:
{ "topic_id": id, "name": string, ... }
Topics may also have other fields, such as tags, url, and more.
get-topics
get-topics returns information about topics and their subtopics. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
topic_ids |
optional | List of topic ids. Data will be returned for these topics and their subtopics. | topic_ids= |
sites |
optional | List of site names. Only topics from these sites will be returned. | sites= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "topics": [topics] }
Each topic has the form:
{ "topic_id": id, "name": string, "subtopics": [topics], ... }
Topics may also have other fields, such as tags, url, and more.
Preference Methods
get-activity
get-activity returns recent Hunch API activity, optionally restricted to a particular set of results. This activity includes preferences of the authenticated user, likes of their friends, and favorites of all API users. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
user_ids |
optional | List of user ids. Only activity of users in this list will be returned. | user_ids= |
topic_ids |
optional | List of topic ids. Only activity for results in these topics will be returned. | topic_ids= |
sites |
optional | List of site names. Only activity for results from these sites will be returned. | sites= |
result_ids |
optional | List of result ids. Only activity for results in this list will be returned. | result_ids= |
lat lng radius |
optional | Bounding circle, specified in degrees and miles. Only activity for results in this bounding circle will be returned. | lat= |
minlat maxlat minlng maxlng |
optional | Bounding rectangle, specified in degrees. Only activity for results in this bounding rectangle will be returned. | minlat= |
query |
optional | A string. Only activity for results whose names or tags contain this string will be returned. | query= |
name |
optional | A string. Only activity for results whose names contain this string will be returned. | name= |
tags |
optional | A string. Only activity for results whose tags contain this string will be returned. | tags= |
urls |
optional | A list of URLs. Only activity for results with URLs in this list will be returned. | urls= |
blocked_topic_ids |
optional | List of topic ids. Activity for results in these topics will not be returned. | blocked_topic_ids= |
blocked_sites |
optional | List of site names. Activity for results in these sites will not be returned. | blocked_sites= |
blocked_result_ids |
optional | List of result ids. Activity for these results will not be returned. | blocked_result_ids= |
limit |
optional | An integer, defaulting to 10. At most this many preferences will be returned. | limit= |
offset |
optional | An integer, defaulting to 0. This many preferences will be skipped. | offset= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "activity": [preferences] }
activity is ordered by date.
Each preference has the form:
{ "user_id": id, "types": [strings], "preference": number, "confidence": number, "created": date, "user_name": string, "user_url": url, "user_image_url": url }
get-preferences
get-preferences returns the preferences of the authenticated user. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
result_ids |
optional | List of result ids. Only preferences for these results will be returned. | result_ids= |
sites |
optional | List of site names. Only preferences for results from these sites will be returned. | sites= |
types |
optional | A list of preference types from 'like', 'dislike', 'favorite', 'checkin', 'purchase', 'return', 'click', 'share', 'rate', 'guess-like', 'guess-dislike', '*hate', '*dislike', '*okay', '*like', '*love', or 'not-interested'. Only preferences set with these types will be returned. | types= |
user_id |
optional | A user id. This user's preferences will be returned instead of the authenticated user's. | user_id= |
before |
optional | A datetime in ISO format. Only preferences expressed before this time will be returned. | before= |
after |
optional | A datetime in ISO format. Only preferences expressed after this time will be returned. | after= |
limit |
optional | An integer, defaulting to 10. At most this many predictions will be returned. | limit= |
offset |
optional | An integer, defaulting to 0. This many of the top predictions will be skipped, and only predictions lower than these will be returned. | offset= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "preferences": [preferences] }
preferences are ordered by date, and each has the form:
{ "result_id": id, "types": [strings], "preference": number, "confidence": number, "created": date, "result_name": string, "result_url": url, "result_image_url": url }
set-preference
set-preference records a preference for the authenticated user, or a guess preference for a friend of the authenticated user. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
optional | An authorization token, authenticating your app on behalf of the user. | auth_token= |
result_id |
required | Result id, identifying the result the preference applies to. | result_id= |
types |
required | A list of preference types. Each type must be one of 'favorite', 'like', 'dislike', 'checkin', 'purchase', 'return', 'click', 'share', 'rate', '*hate', '*dislike', '*okay', '*like', '*love', or 'not-interested'. Types beginning with '*' correspond to star ratings on hunch.com. If friend_id is passed, each type must be one of 'guess-like' or 'guess-dislike'. |
types= |
rating |
optional | A number between 0 and 1, representing the user's rating of the item, where 0 denotes dislike and 1 denotes like. Use if and only if the 'rate' type is given. | rating= |
friend_id |
optional | A user id, which must refer to a friend of the authenticated user. A guess preference type must be passed, and will be recorded for this user. | friend_id= |
app_id auth_sig user_id |
optional | Application credentials, proving that the call originated from your app. user_id must be for your app, in which case it can be passed instead of an auth_token. |
app_id= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true }
delete-preference
delete-preference removes a preference for the authenticated user, or a guess preference for a friend of the authenticated user. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
optional | An authorization token, authenticating your app on behalf of the user. | auth_token= |
result_id |
required | Result id, identifying the result whose preferences should be deleted. | result_id= |
topic_ids |
optional | List of topic ids. If specified, only preferences in these topics will be deleted. | topic_ids= |
types |
optional | A list of preference types. If specified, only preferences of these types will be deleted. Each type must be one of 'favorite', 'like', 'dislike', 'checkin', 'purchase', 'return', 'click', 'share', 'rate', '*hate', '*dislike', '*okay', '*like', '*love', or 'not-interested'. Types beginning with '*' correspond to star ratings on hunch.com. If friend_id is passed, each type must be one of 'guess-like' or 'guess-dislike'. |
types= |
friend_id |
optional | A user id, which must refer to a friend of the authenticated user. Guess preference types must be passed. | friend_id= |
app_id auth_sig user_id |
optional | Application credentials, proving that the call originated from your app. user_id must be for your app, in which case it can be passed instead of an auth_token. |
app_id= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true }
THAY Methods
get-predictions
get-predictions returns the most strongly predicted Teach Hunch About You responses for the authenticated user, potentially restricted to a set of possible responses. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
optional | An authorization token, authenticating your app on behalf of the user. | auth_token= |
allowed_qids |
optional | List of question ids. Only responses to these questions will be returned as predictions. | allowed_qids= |
blocked_qids |
optional | List of question ids. Responses to these questions will not be returned as predictions. | blocked_qids= |
blocked_rids |
optional | List of response ids. These responses will not be returned as predictions. | blocked_rids= |
avoid_rids |
optional | List of response ids. Responses which are highly-correlated to any of these responses will not be returned as predictions. | avoid_rids= |
likes |
optional | A list of result ids. The user's tastes will temporarily incorporate their positive preference for these results. | likes= |
dislikes |
optional | A list of result ids. The user's tastes will temporarily incorporate their negative preference for these results. | dislikes= |
responses |
optional | A list of Teach Hunch About You response ids. The user's tastes will temporarily incorporate these responses. | responses= |
limit |
optional | An integer, defaulting to 10. At most this many predictions will be returned. | limit= |
offset |
optional | An integer, defaulting to 0. This many of the top predictions will be skipped, and only predictions lower than these will be returned. | offset= |
app_id auth_sig user_id |
optional | Application credentials, proving that the call originated from your app. user_id must be for your app, in which case it can be passed instead of an auth_token. |
app_id= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "is_personalized": boolean, "total": number, "predictions": [predictions] }
is_personalized will be true if and only if there was taste data available for the user. total is the total number of predictions before limit and offset are applied.
predictions are ordered by score, and each has the form:
{ "question_id": id, "response_id": id, "score": number, "question_text": string, "question_image_url": url, "response_text": string, "response_image_url": url, "response_popularity": number, "responses": [responses] }
responses contains all possible responses to the question, each of which has the form:
{ "response_id": id, "response_text": string, "response_image_url": url, "response_popularity": number }
get-questions
get-questions returns data for given Teach Hunch About You questions, or returns the next questions to be asked to the authenticated user. Also, if the authenticated user has responded to any of the returned questions, their responses will be returned. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
optional | An authorization token, authenticating your app on behalf of the user. | auth_token= |
question_ids |
optional | A list of question ids, identifying the questions to be returned. | question_ids= |
limit |
optional | An integer, defaulting to the numer of question_ids, or 10 if no question_ids are provided. At most this many questions will be returned. | limit= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, questions: [questions] }
Each question has the form:
{ "question_id": id, "question_text": string, "question_image_url": url, "responses": [responses], ... }
If the authenticated user has responded to the question, their chosen response will also be included in the question object, as response_id.
responses contains all responses to the question, each of which has the form:
{ "response_id": id, "response_text": string, "response_image_url": url }
teach-hunch-about-you
teach-hunch-about-you records the authenticated user's response to a Teach Hunch About You question. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
question_id |
required | A question id, identifying the question the user answered. | question_id= |
response_id |
optional | A response id, identifying the response the user chose. If not provided, then the user is recorded as having 'skipped' the given question. | response_id= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, questions: [questions] }
Each question has the form:
{ "question_id": id, "question_text": string, "question_image_url": url, "responses": [responses] }
responses contains all responses to the question, each of which has the form:
{ "response_id": id, "response_text": string, "response_image_url": url }
Feed Methods
save-result
save-result saves a result in the authenticated user's Hunch Feed. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
result_id |
required | Result id, identifying the result to be saved. | result_id= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true }
recommend-result
recommend-result recommends a result in the authenticated user's Hunch Feed. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
result_id |
required | Result id, identifying the result to be recommended. | result_id= |
recommendation |
required | A string, providing the text of the user's recommendation. | recommendation= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true }
delete-save
delete-save removes the authenticated user's save of a result they've previously saved in the Hunch Feed. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
result_id |
required | Result id, identifying the result whose save should be deleted. | result_id= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true }
delete-recommendation
delete-recommendation removes the authenticated user's recommendation from a result they've previously recommended in the Hunch Feed. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
auth_token |
required | An authorization token, authenticating your app on behalf of the user. | auth_token= |
result_id |
required | Result id, identifying the result whose recommendation should be deleted. | result_id= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true }
Special Methods
batch
batch combines multiple API calls into one. This can be useful for reducing latency, especially in mobile applications. Calls are executed in the order they are given; if a call fails then no calls after it are executed. (view in console)
Input Parameters (show)
| Name | Required | Description | Example |
|---|---|---|---|
calls |
required | A JSON array, listing the desired method calls. | calls= |
callback |
optional | A JSONP callback. This will be prepended to the parenthesized response, which will be returned as text/javascript. | callback= |
suppress_http_errors |
optional | A boolean, defaulting to false. If true, even error responses will have an HTTP response code of 200. | suppress_http_errors= |
Response Structure (show)
A successful response has the form:
{ "ok": true, "responses": [responses] }
responses are the responses, in the same order, to each call in the calls parameter.
An unsuccesful response has the form:
{ "ok": false, "errors": [strings], "error_code": number, "responses": [responses] }
responses are the responses, in the same order, to each call in the calls parameter, up to and including the call which failed. All responses after the failed call are null.