XML API

API Overview - Available Calls

General Requirements

Answerbag provides all of its core question and answer data through a set of Read-Only API Calls, and it also provides Write API calls that allow the writing of content to its database. The Write APIs require that you registered and authenticate your users with Answerbag (which can also be done through APIs). Each call to the API must include your partner ID and your partner authentication key. This key is unique to your partner account, and the API will not work without it. With this key, you can access our basic read-only feeds such as category lists and question lists.

Each call must be submitted as a POST. The POST must include the following values with every request:

partner string The id of your partner account.
api_key string The API key found in your partner profile page.
CURL example:
curl -d "partner=partnername&api_key=e12345678901234678901234567890" http://www.answerbag.com/api/1/question_search/car

Read-Only Calls

  • Questions in a Category
    Returns a list of questions for a given category.
  • Answers to a Question
    Returns a list of the answers for a given question
  • Comments to an Answer
    Returns a list of the comments for a given answer
  • Subcategory List
    Returns a list of subcategories for a given category
  • Question Search
    Returns a list of questions that match a query string
  • User Profile - Coming soon.
    Returns user profile data based on a unique user identifier
  • Leaderboards
    Returns a list of leaderboard entries. A leaderboard may return a list of users or a list of questions.
  • Top Users
    Out of the top 1000 users on the site, returns the top 5 that are members of your partner site.

Register / Log In Calls

We provide functions that allow you to register and authenticate your users with Answerbag, at which point they can use the API to its full extent. You may create an account for your users on Answerbag by calling Register at any time before you submit content to the API for them. Register will return to you a username and an authkey for the user, which are required to accompany all Write Calls. If you do not wish to store the user's authkey, you may call Log In with the user's password to retrieve it at any time.

  • Register
    Create an account on Answerbag for your user
  • Log In
    Authenticate your user with Answerbag

Write Calls

Once your user is logged in to Answerbag, you can submit their content by including the user authkey in the POST request using the format below. The authkey is obtained from Log In.

authkey string The key of the current user

Change Log

7/5/2007
Added top_users call.
6/6/2007
Added leaderboard call.
Add number of questions to the subcategory call.
Added mode=answered,unanswered to questions call.
5/30/2007
Added sort option to questions api call.
Added number of pages to questions and answers api call.
5/22/2007
New Comment Submission Api Calls.
New errors added for commenting api.
5/3/2007
Registration
Added a gender field.
4/18/2007
Registration
Functionallity change Please see the Registration section for new variable names.
A full date is now required for Age certification. This replaces the age_cert_flag. The registree must be 16 years or older.
Users must agree to the the Terms of Use and Privacy policy.
3/22/2007
Answers to a question
Includes display_name along with every answer.
1/31/2007
Registration
No longer checks for duplicate user names
Returned result of nickname is deprecated
Login
Email is now used instead of nickname for login
Requires email to be passed (nickname is deprecated)
Only the authkey is required for any write pages
Returned result of nickname is deprecated
All Write pages
Username is deprecated and is not needed any more

Questions in a Category

Returns a list of questions for a given category. Includes, for each question: id, question text, the user who asked (or last answered) it, the date it was last updated, and a link to the answers.

The first 25 questions in a category are displayed. By default, the the page defaults to 1. An optional "?page=n" parameter may be passed to go to that page number.

The sorting of the questions can either be based on recency or rating. Use the ?sort parameter to choose between new and best. The default is to sort by best. (highest rated)

You can change the mode to only show unanswered or answered questions. ?mode=unanswered, ?mode=answered

URL:
http://www.answerbag.com/api/1/questions/[categoryid]
Examples:
http://www.answerbag.com/api/1/questions/24
http://www.answerbag.com/api/1/questions/24?sort=new
http://www.answerbag.com/api/1/questions/24?page=3
http://www.answerbag.com/api/1/questions/24?page=3&sort=best
http://www.answerbag.com/api/1/questions/24?page=3&mode=unanswered
http://www.answerbag.com/api/1/questions/24?mode=answered

Result

categoryid int Numeric category id.
name string Category name, used in navigation.
titlestring Title of the category.
summarystring Quick summary of a category for more context.
pagesint Number of pages in this category.
questionscontainer Container for a list of questions within the category.
question Container for a question.
idintNumeric id of the question.
questiontextstringText of the question.
submittedbyintThe user that submitted the question, or, if it has been answered, who last answered it.
display_namestringThe display name of the user that submitted the question, or, if it has been answered, who last answered it.
datedateWhen the question was posted / last answered.
answerlinkstringLink to the followup feed to get all the answers to this question.
ratingintUser rating of this question.
answersintThe number of answers to this question.
avatars Container for submitted by avatar information
64The location to the large avatar.
50The location to the medium avatar.
30The location to the small avatar.
15The location to the tiny avatar.

Answers to a Question

Returns a list of categories within a given category. Includes, for each question: id, question text, the user who asked (or last answered) it, the date it was last updated, and a link to the answers.

As of June 9, 2008, you may pass the sort option through the query string (only supporting "new" currently) to get answers with the newest listed first.

URL:
http://www.answerbag.com/api/1/answers/[questionid](?page=n)&(sort=new)
Example:
http://www.answerbag.com/api/1/answers/251

Result

questionidQuestion id.
questiontextText of the question.
submittedbyUser id who submitted the question.
partneridPartner id of the submitting site.
display_nameThe display name of the user who submitted the question.
dateDate the question was asked.
categoryidCategory id the question was posted in.
category_linkLink to the parent category.
ratingRating of the question.
pagesNumber of pages of results.
hashNumber of pages of results.
answer_countNumber of answers for this question.
hasflagged1 if the user has flagged the question already. 0 if not.
user_ratingRating given to the question by this user. 0 if nothing.
video_embedEmbed code for the video that accompanies the question, if it's a video question.
avatars Container for submitted by avatar information
64The location to the large avatar.
50The location to the medium avatar.
30The location to the small avatar.
15The location to the tiny avatar.
answers Container of answers
answerContainer for answer data
answeridNumeric id of the answer.
answertextText of the answer.
submittedbyNumeric id of the user who submitted the answer.
partneridPartner id of the submitting site.
display_nameThe display name of the user that submitted the answer.
ratingUser rating of this answer.
dateDate the answer was submitted
hasflagged1 if the user has flagged the answer already. 0 if not.
user_ratingRating given to the answer by this user. 0 if nothing.
videos(optional) - container for a list of videos that accompany an answer
sourceurlSource of the video included with this answer
images(optional) - container for a list of images that accompany an answer
sourceurlSource of the image included with this answer
avatars Container for submitted by avatar information
64The location to the large avatar.
50The location to the medium avatar.
30The location to the small avatar.
15The location to the tiny avatar.
hashHash that must be included when rating answers, as a precaution to prevent abuse.

Comments on an Answer

Returns a list of comments within to a given answer.

URL:
http://www.answerbag.com/api/1/comments/[answerid]
Example:
http://www.answerbag.com/api/1/comments/251

Result

commentidComment id.
commenttextText of the comment.
useridUser id who submitted the question.
partneridPartner id of the submitting site.
display_nameThe display name of the user who submitted the question.
dateDate the question was asked.

Post a Comment on an Answer

Returns the comment id of the new comment, or an error code.

URL:
http://www.answerbag.com/api/1/postComment

Required fields

answerid int The numeric id of the answer that the question should be comment on.
commentstring The text of the comment. Maximum 1000 characters (after character encoding)

Result

commentidComment id.

Error codes can be found at the bottom of the page.

Subcategory List

Returns a list of categories within a given category, as well as data for this category. Includes, for each question: id, question text, the user who asked (or last answered) it, the date it was last updated, and a link to the answers.

URL:
http://www.answerbag.com/api/1/categories/[categoryid]
Example:
http://www.answerbag.com/api/1/categories/251
categoryidNumeric category id of this category
nameName of the category.
titleCategory title, usually gives more context than just the name.
summaryQuick summary of a category for more context.
questionslinkLink for questions within this category
questionsTotal count of the questions in this category.
parent_categoryLink to get more information about the parent category.
parentidID of the parent category, if one exists.
parent_nameName of the parent Category.
subcategoriesCollection of subcategories of this category.
categoryidNumeric id of this subcategory.
nameName of the subcategory.
linkLink for subcategory data.
questionsCount of questions for this subcategory.

Question Search

Returns a list of questions that match given search terms, ranked by relevency.

URL:
http://www.answerbag.com/api/1/question_search/[searchterm]
Example:
http://www.answerbag.com/api/1/question_search/britney+spears

Results

results container for search results
result container for a result
questionidintID of the question
question_textstringText of the question
ratingstringRating of the question.

User Profile

Returns the activity on a user profile.

URL:
http://www.answerbag.com/api/1/profile/[userid]?options=[comma list of options](&page=n)
Example:
http://www.answerbag.com/api/1/profile/251?options=questions,answers,comments

Options

questionsQuestions this user has asked.
answersAnswers this user has submitted.
commentsComments this user has submitted.
ratingsRatings this user has submitted on other people's questions and answers. Only available for first person profile.
feedback_answersAnswers in response to questions this user submitted.
feedback_commentsComments on this users answers, as well as follow up comments to this users's comments.
feedback_ratingsRatings on this users questions and answers.

Result

questionContainer for question data
questionidNumeric id of the question.
question_textText of the question.
answeridID of the answer, if applicable. Not always set.
actionAction that was taken that caused this item to show up in the last.
useriduserid of the user that posted this item.
display_nameThe display name of the user that posted the item.

Leaderboards

Returns a list of leaderboard entries. A leaderboard may return a list of users, or a list of questions, as there are boards for both. Please check the boardtype for each api call before using the results. Currently there is only 1 board - points (1).

URL:
http://www.answerbag.com/api/1/leaderboard/[boardid]/?period=[lastweek,alltime]&page=[1-40]
Example:
http://www.answerbag.com/api/1/leaderboard/1

Result

boardidBoard id.
boardtypeType of board. The results will vary depending on the board type.
points_typeHow points should be interpreted. Possible values: (int, percent).
boardresults
useruser container
userid
display_name
levelpoints
levelnum
pointsNumber of points for this board.
ordernumRank of the user
prevpointsPrevious weeks points
prevordernumRank in the previous week
orderdiffDifference in points from this week to last
avatars Container for submitted by avatar information
64The location to the large avatar.
50The location to the medium avatar.
30The location to the small avatar.
15The location to the tiny avatar.

Post a Comment on an Answer

Returns the comment id of the new comment, or an error code.

URL:
http://www.answerbag.com/api/1/postComment

Required fields

answerid int The numeric id of the answer that the question should be comment on.
commentstring The text of the comment. Maximum 1000 characters (after character encoding)

Result

commentidComment id.

Error codes can be found at the bottom of the page.

Top Users

Out of the top 1000 users on the site, returns the top 5 that are members of your partner site.

URL:
http://www.answerbag.com/api/1/top_users
Example:
http://www.answerbag.com/api/1/top_users
useridUserid
display_nameName of the user.
pointsPoints this user obtained.
avatars Container for submitted by avatar information
64The location to the large avatar.
50The location to the medium avatar.
30The location to the small avatar.
15The location to the tiny avatar.

Register

Receives user's registration information. Returns the username and authkey or an error message.
Example:
URL:
http://www.answerbag.com/api/1/register
Data passed as POST:
partner=[partnerid]&api_key=[api_key]&username=[nickname of registrant]&email=[email of registrant]&age_cert_flag=1&password=[password of registrant]

Required fields

usernamestringThe desired username for a user. (required)
emailstringEmail address of the user. (required)
passwordstringPassword for the user.(required)
date_yearintegerBirth year of the user. (required)
date_monthintegerBirth month of the user. (required)
date_dayintegerBirth month of the user. (required)
The user needs to be 16 years or older in order to sign up with Answerbag.
genderinteger0 for Unknown, 1 for Male, 2 for Female
mailing_list_flagint1 if the user has opted in to our mailing list.
newsletter_flagint1 if the user has opted in to our newsletter list, 0 otherwise.
referrerstringReferring page - can be left blank.

Result

authkeystringAuthorization key to perform actions as this user. It must be included with all subsequent requests.
useridstringUser ID of the new account.

Log In

Receives user login information. Returns the username and authkey or an error message.
Example:
URL:
http://www.answerbag.com/api/1/login
Data passed as POST:
partner=[partnerid]&api_key=[api_key]&email=[user email]&password=[user password]

Required fields

email string The email of the user. (was username which is now deprecated)
password string The user's password.

We will return a key for this user that you should include on further requests. It is not necessary to include the user's password after the login, as we can determine by the username and the token who the user is.

Result

authkeystringAuthorization key to perform actions as this user. It must be included with all subsequent requests.
display_namestringThe display name of this user
useridintUserid of this user.

Post a Question

Receives the text of a question, with associated information. Returns the question id with a success message, or an error.
Example:
URL:
http://www.answerbag.com/api/1/postQuestion
Data passed as POST:
partner=[partnerid]&api_key=[api_key]&authkey=[user key]&categoryid=[category id]&questiontext=[url encoded text]

Required fields

categoryid int The numeric id of the category that the question should be posted in. You cannot post a question to the root category (1)
questiontextstring The text of the question. If we detect a duplicate, we will not add the question to our database. The maximum length is 255 characters, and must be at least 10 characters.

Result

number int The number of the status
status string If it is submitted or exists.
questionid int The ID of the question submitted or the existing question
video_url string For video questions, the URL of the player. If you post the entire embed code, we will strip out the URL and convert it to one of our known formats. 255 char limit on the url.

Post an Answer

Receives the text of an answer, with associated information. Returns the answer id with a success message, or an error.
Example:
URL:
http://www.answerbag.com/api/1/postAnswer
Data passed as POST:
partner=[partnerid]&api_key=[api_key]&authkey=[user key]&questionid=[question id]&answertext=[url encoded text]

Required fields

questionidint The numeric id of the question that the answer should be posted to.
answertextstring The text of the answer. Max length:

Result

number int The number of the status
status string If it is submitted or exists.
questionid int The ID of the question the answer was submitted to
answerid int The ID of the answer submitted or the existing question

Rating an Answer or Question

Returns the new rating of the question (or answer).

URL:
http://www.answerbag.com/api/1/rate
Examples:
URL:
http://www.answerbag.com/api/1/rate
Data passed as POST:
partner=[partnerid]&api_key=[api_key]&authkey=[user key]&answer=45&hash=[hash]&rating=up
partner=[partnerid]&api_key=[api_key]&authkey=[user key]&question=4&hash=[hash]&rating=down

Required Fields

questionid OR answerid int Question id OR the Answer id of the item being rated.
hash string Hash that must accompany the rating. This is requried as a security measure to curb malicious scripted rating.
rating string How to rate the question/answer. "up" or "down".

Result

rating int The new rating for this item

Error codes will be returned in xml format as well. The returned values are:

numberintegerThe number of the error
messagestringThe message of the error code

And here's the list of errors and their codes

1Invalid API Key
2Query Limit Exceeded
3Invalid User Credentials
4Both the Partner ID and API Key need to be passed
5Invalid Request
8Both the User Name and Auth Key need to be passed
9Question Submit: A Category ID must be greater than 1 and question text must be passed
10Answer Submit: A Question Id and answer text must be passed
11Question Submit: That user has exceeded their questions per hour limit.
12Question Submit: The question text needs to be less than 255 characters long.
13Question Answers: Must include a question id.
14Category List: Must include a category id
15Login: Both the email and password need to be passed
16Login: Incorrect email or password
17The user must confirm their account to continue
18That Category ID does not exist
19Comment Submit: You must include an answerid.
20Comment Submit: This comment has already been posted to this answer by this user.
21Comment Submit: An answer with this answerid does not exist.
22Comment List: Must include an answerid.
23Comment List: An answer with this answerid does not exist.
24Comment Submit: Missing comment field.
30Profile: Missing userid
31Profile: User with this id does not exist.
40Rating: Rating Limit Reached
41Rating: Hash Check Failed.
42Rating must be "up" or "down"
43User must be logged in
44Please supply a questionid or an answerid
100Registration: Nickname Exists
101Registration: Email Exists
102Registration: Username cannot start with "AB-"
103Registration: Username must be 6 characters or longer
104Registration: Username has invalid Characters
105Registration: User must be at least 16 years of age to register
106Registration: The email address must be valid
107Registration: Password must be 6 characters or longer