ChaCha API Documentation
Contents:
- Quick ChaCha Answer API Request
- Sample Quick ChaCha Answer API Response
- Sample Quick ChaCha Answer API Response - Groovy Example
- ChaCha Trends API Request
- Sample ChaCha Trends API Response
- Sample ChaCha Trends API Response - Groovy Example
- Top ChaCha Answers
- Error Codes
Quick ChaCha Answer API Request
| Description | Search Questions and Answers |
| URL | http://query.chacha.com/answer/search.json |
| Protocol | HTTP |
| Method | GET |
| HTTP Header | apikey -- your API key |
| URL Parameters |
|
Sample Quick ChaCha Answer API Response
{
"qvpResults":
[
{
"answer": {
"id":-1,
"category":"",
"hits":-1,
"source":"http://chacha.com",
"created":"",
"updated":"",
"answer":"answer text",
"score":"1",
"guideRating":""
},
"question": {
"id":-1,
"hits":-1,
"score":"1",
"suggestion":"world"
},
"type":"autoguide"
}
...
],
"success":true,
"path":"/answer/search.json"
}
Groovy Example
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
def apiUri = "http://query.chacha.com"
def searchPath = "/answer/search.json"
def apiKey = "your api key"
def queryString = 'How old is Brad Pitt?'
def http = new HTTPBuilder( apiUri )
http.request( GET, JSON )
{
uri.path = searchPath
uri.query = [ v:'1.0', query: queryString ]
headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4'
headers.'apikey' = apiKey
response.success =
{
resp, json ->
if((json.success==true) && (json.qvpResults.answer))
{
println 'Answer: ' + json.qvpResults.answer.answer.get(0)
println 'Category: ' + json.qvpResults.answer.category.get(0)
println 'Source: ' + json.qvpResults.answer.source.get(0)
} else
{
println json
}
}
response.failure =
{
resp ->
println "Unexpected error: ${resp.statusLine.statusCode} : ${resp.statusLine.reasonPhrase}"
}
}
Sample ChaCha Trends API Request
| Description | Get trends |
| URL | http://query.chacha.com/trends/getTrends.json |
| Protocol | HTTP |
| Method | GET |
| HTTP Header | apikey -- your API key |
| URL Parameter |
|
Sample ChaCha Trends API Response
{
"request": {
"date": "2009-12-08 12:00:00",
"count": "1000",
"prettyOutput": "true",
"source": "RawQuery"
},
"success": true,
"trends": [
"trending keywords 1",
"trending keywords 2",
...
]
}
Groovy Example
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
def apiUri = "http://query.chacha.com"
def trendsPath = "/trends/getTrends.json"
def apiKey = "your api key"
def source = 'RawQuery'
def date = '2010-02-15 00:00:00'
def count = '30'
def prettyOutput = 'true'
def http = new HTTPBuilder( apiUri )
http.request( GET, JSON )
{
uri.path = trendsPath
uri.query = [ v:'1.0', source: source, date: date, count: count, prettyOutput: prettyOutput ]
headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4'
headers.'apikey' = apiKey
response.success =
{
resp, json ->
if((json.success==true) && (json.trends))
{
json.trends.each{trend->
println "Trend = ${trend}"
}
}
else
{
println json
}
}
response.failure =
{
resp ->
println "Unexpected error: ${resp.statusLine.statusCode} : ${resp.statusLine.reasonPhrase}"
}
}
Top ChaCha Answers
Our Top ChaCha Answers is a call to our RSS feeds. You can create any custom feed for just about everything we have.
The URL to generate your custom feed is:
- http://www.chacha.com/search/feed.rss2?query=your-custom-keyword
Some examples might be:
- http://www.chacha.com/search/feed.rss2?query=haiti+earthquake
- http://www.chacha.com/search/feed.rss2?query=coupon
- http://www.chacha.com/search/feed.rss2?query=indianapolis
- http://www.chacha.com/search/feed.rss2?query=barack+obama
- http://www.chacha.com/search/feed.rss2?query=lil+wayne+lyrics
The URL to get the latest questions and answers is:
- http://www.chacha.com/answers.rss2
There are a number of ways to integrate RSS feeds into your web site or application depending on what you are coding in. Here are a few resources for adding an RSS feed into your site.
- ASP RSS Aggregator
- ASP.NET RSS Aggregator
- Coldfusion RSS Aggregator
- Java RSS Aggregator
- Perl RSS Aggregator
- PHP RSS Aggregator
- Python RSS Aggregator
Error Codes
Here are the error codes you may see as you are testing your application:
400 Bad Request
403 Not Authorized
403 Developer Inactive
403 Over Queries Per Second Limit
403 Over Rate Limit
403 Unknown Referer
403 Service over QPS Limit
503 API Maintentance/Service Unavailable
504 Gateway Timeout