Skip to content

Instantly share code, notes, and snippets.

Created Apr 21, 2010
What would you like to do?
<!DOCTYPE html>
<title>Get Satisfaction API</title>
<style type="text/css">
#transferUrl {
display: block;
width: 100%;
<script src=""></script>
var gsApiUrl = '',
couchUrl = '';
//Saves data to the couch. Assumes the data as a _id property
//that sets the URL for it in the couch, and it also assumes
//there is not a document of that name already in the couch.
function saveDoc(data, method) {
type: method || "POST",
url: couchUrl,
dataType: 'json',
processData: 'false',
data: JSON.stringify(data),
success: function (result, textStatus, xhr) {
error: function (xhr, textStatus, error) {
* Top level method to do the data transfer.
* @param {String} gsPath a path for the Get Satisfaction URL.
* Do not include the part.
function transfer(gsPath) {
//Fetch the API. Use JSONP version of the API.
var url = gsApiUrl + gsPath;
url += (url.indexOf("?") === -1 ? "?" : "&") + 'callback=?';
$.getJSON(url, function (data) {
//data is the JSON data
//Now inject it into the couch.
//Set the ID/url for this document in the couch.
data._id = gsPath;
//Make sure the document does not already exist. If it does,
//then grab its rev so we can update it.
url: couchUrl + '/' + encodeURIComponent(gsPath),
dataType: 'json',
success: function (result, textStatus, xhr) {
if (result._rev) {
data._rev = result._rev;
} else {
error: function (xhr, textStatus, error) {
if (xhr.status === 404) {
} else {
$(function () {
$("#transferForm").bind("submit", function (evt) {
var url = $.trim(document.getElementById("transferUrl").value);
if (url) {
Transfers data from Get Satisfaction into a CouchDB database. To get this to work:
<li>Go to <a href=""></a> and create a new database called "gsdata".</li>
<li>Create a new document in that database, call it "ui".</li>
<li>Save that document.</li>
<li>Click the <b>Upload Attachment</b> button to upload this file to that <b>ui</b> document.</li>
<li>Then go to this URL to run it: <a href=""></a>
<form id="transferForm">
<div>Enter in Get Satisfaction URL to fetch:</div>
<input id="transferUrl" type="text" value="products/mozilla_thunderbird/topics.json?sort=recently_active&page=1&limit=30">
<input type="submit" name="Go" value="Go">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment