XML API
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
-
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.
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
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 |
- 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
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
| categoryid |
int |
Numeric category id.
|
| name |
string |
Category name, used in navigation.
|
| title | string |
Title of the category.
|
| summary | string |
Quick summary of a category for more context.
|
| pages | int |
Number of pages in this category.
|
| questions | container |
Container for a list of questions within the category.
| question |
Container for a question.
| id | int | Numeric id of the question. |
| questiontext | string | Text of the question. |
| submittedby | int | The user that submitted the question, or, if it has been answered, who last answered it. |
| display_name | string | The display name of the user that submitted the question, or, if it has been answered, who last answered it. |
| date | date | When the question was posted / last answered. |
| answerlink | string | Link to the followup feed to get all the answers to this question. |
| rating | int | User rating of this question. |
| answers | int | The number of answers to this question. |
| avatars |
Container for submitted by avatar information
| 64 | The location to the large avatar. |
| 50 | The location to the medium avatar. |
| 30 | The location to the small avatar. |
| 15 | The location to the tiny avatar. |
|
|
|
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
| questionid | Question id. |
| questiontext | Text of the question. |
| submittedby | User id who submitted the question. |
| partnerid | Partner id of the submitting site. |
| display_name | The display name of the user who submitted the question. |
| date | Date the question was asked. |
| categoryid | Category id the question was posted in. |
| category_link | Link to the parent category. |
| rating | Rating of the question. |
| pages | Number of pages of results. |
| hash | Number of pages of results. |
| answer_count | Number of answers for this question. |
| hasflagged | 1 if the user has flagged the question already. 0 if not. |
| user_rating | Rating given to the question by this user. 0 if nothing. |
| video_embed | Embed code for the video that accompanies the question, if it's a video question. |
| avatars |
Container for submitted by avatar information
| 64 | The location to the large avatar. |
| 50 | The location to the medium avatar. |
| 30 | The location to the small avatar. |
| 15 | The location to the tiny avatar. |
|
| answers |
Container of answers
| answer | Container for answer data
| answerid | Numeric id of the answer. |
| answertext | Text of the answer. |
| submittedby | Numeric id of the user who submitted the answer. |
| partnerid | Partner id of the submitting site. |
| display_name | The display name of the user that submitted the answer. |
| rating | User rating of this answer. |
| date | Date the answer was submitted |
| hasflagged | 1 if the user has flagged the answer already. 0 if not. |
| user_rating | Rating given to the answer by this user. 0 if nothing. |
| videos | (optional) - container for a list of videos that accompany an answer
| sourceurl | Source of the video included with this answer |
|
| images | (optional) - container for a list of images that accompany an answer
| sourceurl | Source of the image included with this answer |
|
| avatars |
Container for submitted by avatar information
| 64 | The location to the large avatar. |
| 50 | The location to the medium avatar. |
| 30 | The location to the small avatar. |
| 15 | The location to the tiny avatar. |
|
| hash | Hash that must be included when rating answers, as a precaution to prevent abuse. |
|
|
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
| commentid | Comment id. |
| commenttext | Text of the comment. |
| userid | User id who submitted the question. |
| partnerid | Partner id of the submitting site. |
| display_name | The display name of the user who submitted the question. |
| date | Date the question was asked. |
Returns the comment id of the new comment, or an error code.
- URL:
- http://www.answerbag.com/api/1/postComment
| answerid |
int |
The numeric id of the answer that the question should be comment on. |
| comment | string |
The text of the comment. Maximum 1000 characters (after character encoding)
|
Error codes can be found at the bottom of the page.
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
| categoryid | Numeric category id of this category |
| name | Name of the category. |
| title | Category title, usually gives more context than just the name. |
| summary | Quick summary of a category for more context. |
| questionslink | Link for questions within this category |
| questions | Total count of the questions in this category. |
| parent_category | Link to get more information about the parent category. |
| parentid | ID of the parent category, if one exists. |
| parent_name | Name of the parent Category. |
| subcategories | Collection of subcategories of this category.
| categoryid | Numeric id of this subcategory. |
| name | Name of the subcategory. |
| link | Link for subcategory data. |
| questions | Count of questions for this subcategory. |
|
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 |
container for search results
| result |
container for a result
| questionid | int | ID of the question |
| question_text | string | Text of the question |
| rating | string | Rating of the question. |
|
|
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
| questions | Questions this user has asked. |
| answers | Answers this user has submitted. |
| comments | Comments this user has submitted. |
| ratings | Ratings this user has submitted on other people's questions and answers.
Only available for first person profile. |
| feedback_answers | Answers in response to questions this user submitted. |
| feedback_comments | Comments on this users answers,
as well as follow up comments to this users's comments. |
| feedback_ratings | Ratings on this users questions and answers. |
| question | Container for question data
| questionid | Numeric id of the question. |
| question_text | Text of the question. |
| answerid | ID of the answer, if applicable. Not always set. |
| action | Action that was taken that caused this item to show up in the last. |
| userid | userid of the user that posted this item. |
| display_name | The display name of the user that posted the item. |
|
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
| boardid | Board id. |
| boardtype | Type of board. The results will vary depending on the board type. |
| points_type | How points should be interpreted. Possible values: (int, percent). |
| boardresults |
| user | user container |
|
| userid | |
| display_name | |
| levelpoints | |
| levelnum | |
| points | Number of points for this board. |
| ordernum | Rank of the user |
| prevpoints | Previous weeks points |
| prevordernum | Rank in the previous week |
| orderdiff | Difference in points from this week to last |
| avatars |
Container for submitted by avatar information
| 64 | The location to the large avatar. |
| 50 | The location to the medium avatar. |
| 30 | The location to the small avatar. |
| 15 | The location to the tiny avatar. |
|
|
|
Returns the comment id of the new comment, or an error code.
- URL:
- http://www.answerbag.com/api/1/postComment
| answerid |
int |
The numeric id of the answer that the question should be comment on. |
| comment | string |
The text of the comment. Maximum 1000 characters (after character encoding)
|
Error codes can be found at the bottom of the page.
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
| userid | Userid |
| display_name | Name of the user. |
| points | Points this user obtained. |
| avatars |
Container for submitted by avatar information
| 64 | The location to the large avatar. |
| 50 | The location to the medium avatar. |
| 30 | The location to the small avatar. |
| 15 | The location to the tiny avatar. |
|
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]
| username | string | The desired username for a user. (required) |
| email | string | Email address of the user. (required) |
| password | string | Password for the user.(required) |
| date_year | integer | Birth year of the user. (required) |
| date_month | integer | Birth month of the user. (required) |
| date_day | integer | Birth month of the user. (required) |
| | The user needs to be 16 years or older in order to sign up with Answerbag. |
| gender | integer | 0 for Unknown, 1 for Male, 2 for Female |
| mailing_list_flag | int | 1 if the user has opted in to our mailing list. |
| newsletter_flag | int | 1 if the user has opted in to our newsletter list, 0 otherwise. |
| referrer | string | Referring page - can be left blank. |
| authkey | string | Authorization key to perform actions as this user. It must be included with all subsequent requests. |
| userid | string | User ID of the new account. |
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]
| 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.
| authkey | string | Authorization key to perform actions as this user. It must be included with all subsequent requests. |
| display_name | string | The display name of this user |
| userid | int | Userid of this user. |
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]
| 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) |
| questiontext | string |
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.
|
| 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. |
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]
| questionid | int |
The numeric id of the question that the answer should be posted to. |
| answertext | string |
The text of the answer. Max length: |
| 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 |
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
| 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". |
| rating |
int |
The new rating for this item |
| number | integer | The number of the error |
| message | string | The message of the error code |
| 1 | Invalid API Key |
| 2 | Query Limit Exceeded |
| 3 | Invalid User Credentials |
| 4 | Both the Partner ID and API Key need to be passed |
| 5 | Invalid Request |
| 8 | Both the User Name and Auth Key need to be passed |
| 9 | Question Submit: A Category ID must be greater than 1 and question text must be passed |
| 10 | Answer Submit: A Question Id and answer text must be passed |
| 11 | Question Submit: That user has exceeded their questions per hour limit. |
| 12 | Question Submit: The question text needs to be less than 255 characters long. |
| 13 | Question Answers: Must include a question id. |
| 14 | Category List: Must include a category id |
| 15 | Login: Both the email and password need to be passed |
| 16 | Login: Incorrect email or password |
| 17 | The user must confirm their account to continue |
| 18 | That Category ID does not exist |
| 19 | Comment Submit: You must include an answerid. |
| 20 | Comment Submit: This comment has already been posted to this answer by this user. |
| 21 | Comment Submit: An answer with this answerid does not exist. |
| 22 | Comment List: Must include an answerid. |
| 23 | Comment List: An answer with this answerid does not exist. |
| 24 | Comment Submit: Missing comment field. |
| 30 | Profile: Missing userid |
| 31 | Profile: User with this id does not exist. |
| 40 | Rating: Rating Limit Reached |
| 41 | Rating: Hash Check Failed. |
| 42 | Rating must be "up" or "down" |
| 43 | User must be logged in |
| 44 | Please supply a questionid or an answerid |
| 100 | Registration: Nickname Exists |
| 101 | Registration: Email Exists |
| 102 | Registration: Username cannot start with "AB-" |
| 103 | Registration: Username must be 6 characters or longer |
| 104 | Registration: Username has invalid Characters |
| 105 | Registration: User must be at least 16 years of age to register |
| 106 | Registration: The email address must be valid |
| 107 | Registration: Password must be 6 characters or longer |