Skip to content

Instantly share code, notes, and snippets.

@bdickason
Created July 7, 2011 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdickason/1068939 to your computer and use it in GitHub Desktop.
Save bdickason/1068939 to your computer and use it in GitHub Desktop.
Goodreads API - review_list example
var http = require('http');
var express = require('express');
var app = express.createServer();
var sys = require('sys');
app.configure(function(){
app.set('views', __dirname + '/views');
app.register('.html', require('jade'));
app.use(express.methodOverride());
app.use(express.bodyParser());
app.use(app.router);
});
// Example Output - requesting a user's shelf with 3 books
app.get('/1', function(req, res) {
json = {"Request":{"authentication":"true","key":"tmp","method":"review_list"},"books":{"@":{"start":"1","end":"3","total":"3","numpages":"1","currentpage":"1"},"book":[{"id":{"#":"9455874","@":{"type":"integer"}},"isbn":"0470929839","isbn13":"9780470929834","publication_day":{"#":"19","@":{"type":"integer"}},"publication_month":{"#":"10","@":{"type":"integer"}},"publication_year":{"#":"2010","@":{"type":"integer"}},"publisher":"Wiley","text_reviews_count":{"#":"4","@":{"type":"integer"}},"title":"Do More Faster: TechStars Lessons to Accelerate Your Startup","image_url":"http://photo.goodreads.com/books/1289178203m/9455874.jpg","small_image_url":"http://photo.goodreads.com/books/1289178203s/9455874.jpg","link":"http://www.goodreads.com/book/show/9455874-do-more-faster","num_pages":"352","average_rating":"3.86","ratings_count":"14","description":{},"authors":{"author":{"id":"4395710","name":"Brad Feld","image_url":"http://www.goodreads.com/images/nophoto/nophoto-U-200x266.jpg","small_image_url":"http://www.goodreads.com/images/nophoto/nophoto-U-50x66.jpg","link":"http://www.goodreads.com/author/show/4395710.Brad_Feld","average_rating":"3.81","ratings_count":"68","text_reviews_count":"20"}},"published":"2010"},{"id":{"#":"6828896","@":{"type":"integer"}},"isbn":"0446563048","isbn13":"9780446563048","publication_day":{"#":"7","@":{"type":"integer"}},"publication_month":{"#":"6","@":{"type":"integer"}},"publication_year":{"#":"2010","@":{"type":"integer"}},"publisher":"Business Plus","text_reviews_count":{"#":"376","@":{"type":"integer"}},"title":"Delivering Happiness: A Path to Profits, Passion, and Purpose","image_url":"http://photo.goodreads.com/books/1275732445m/6828896.jpg","small_image_url":"http://photo.goodreads.com/books/1275732445s/6828896.jpg","link":"http://www.goodreads.com/book/show/6828896-delivering-happiness","num_pages":"246","average_rating":"4.02","ratings_count":"1392","description":"You want to learn about the path that we took at Zappos to get to over $1 billion in gross merchandise sales in less than ten years. You want to learn about the path I took that eventually led me to Zappos, and the lessons I learned along the way. You want to learn from all the mistakes we made at Zappos over the years so that your business can avoid making some of the same ones. You want to figure out the right balance of profits, passion, and purpose in business and in life. You want to build a long-term, enduring business and brand. You want to create a stronger company culture, which will make your employees and coworkers happier and create more employee engagement, leading to higher productivity. You want to deliver a better customer experience, which will make your customers happier and create more customer loyalty, leading to increased profits. You want to build something special. You want to find inspiration and happiness in work and in life. You ran out of firewood for your fireplace. This book makes an excellent fire-starter.","authors":{"author":{"id":"3064249","name":"Tony Hsieh","image_url":"http://photo.goodreads.com/authors/1272394651p5/3064249.jpg","small_image_url":"http://photo.goodreads.com/authors/1272394651p2/3064249.jpg","link":"http://www.goodreads.com/author/show/3064249.Tony_Hsieh","average_rating":"4.02","ratings_count":"1392","text_reviews_count":"385"}},"published":"2010"},{"id":{"#":"7542136","@":{"type":"integer"}},"isbn":{"@":{"nil":"true"}},"isbn13":"9782839905800","publication_day":{"#":"1","@":{"type":"integer"}},"publication_month":{"#":"9","@":{"type":"integer"}},"publication_year":{"#":"2009","@":{"type":"integer"}},"publisher":"Self published","text_reviews_count":{"#":"9","@":{"type":"integer"}},"title":"Business Model Generation","image_url":"http://photo.goodreads.com/books/1263202590m/7542136.jpg","small_image_url":"http://photo.goodreads.com/books/1263202590s/7542136.jpg","link":"http://www.goodreads.com/book/show/7542136-business-model-generation","num_pages":"276","average_rating":"4.40","ratings_count":"147","description":"Disruptive new business models are emblematic of our generation. Yet they remain poorly understood, even as the transform competitive landscapes across industries. Business Model Generation offers you powerful, simple, tested tools for understanding, designing, reworking and implementing business models.\r<br/>\r<br/>Business Model Generation is a practical, inspiring handbook for everyone striving to improve a business model - or craft a new one.\r<br/>\r<br/>Change the way you think about Business Models\r<br/>Business Model Generation will teach you powerful and practical innovation techniques used today by leading companies worldwide. You will learn how to systematically understand, design, and implement a new business model - or analyze and renovate an old one.\r<br/>\r<br/>Co-Created by 470 strategy practitioners\r<br/>Business Model Generation practices what it preaches. Co-authored by 470 Business mOdel Canvas practitioners from 45 countries, the book was financed and produced independently of the traditional publishing industry. It features a tightly-integrated, visual, lie-flat design that enables immediate hands-on use.\r<br/>\r<br/>Designed for Doers\r<br/>Business Model Generation is for those ready to abandon outmoded thinking and embrace new, innovative models of value creation: executives, consultants, entrepreneurs - and leaders of all organizations.\r<br/>\r<br/>(Covertext)","authors":{"author":{"id":"3309113","name":"Alexander Osterwalder","image_url":"http://www.goodreads.com/images/nophoto/nophoto-U-200x266.jpg","small_image_url":"http://www.goodreads.com/images/nophoto/nophoto-U-50x66.jpg","link":"http://www.goodreads.com/author/show/3309113.Alexander_Osterwalder","average_rating":"4.40","ratings_count":"147","text_reviews_count":"-15"}},"published":"2009"}]}};
sys.puts('Logged request to ' + req.url);
res.render('index.jade', { json: json });
});
// Example Output - requesting a user's shelf with one book
app.get('/2', function(req, res) {
json = {"Request":{"authentication":"true","key":"tmp","method":"review_list"},"books":{"@":{"start":"1","end":"1","total":"1","numpages":"1","currentpage":"1"},"book":{"id":{"#":"6597651","@":{"type":"integer"}},"isbn":"1597801577","isbn13":"9781597801577","publication_day":{"#":"15","@":{"type":"integer"}},"publication_month":{"#":"9","@":{"type":"integer"}},"publication_year":{"#":"2009","@":{"type":"integer"}},"publisher":"Night Shade Books","text_reviews_count":{"#":"1115","@":{"type":"integer"}},"title":"The Windup Girl","image_url":"http://photo.goodreads.com/books/1278940608m/6597651.jpg","small_image_url":"http://photo.goodreads.com/books/1278940608s/6597651.jpg","link":"http://www.goodreads.com/book/show/6597651-the-windup-girl","num_pages":"359","average_rating":"3.72","ratings_count":"4335","description":"What happens when bio-terrorism becomes a tool for corporate profits? And what happens when said bio-terrorism forces humanity to the cusp of post-human evolution? In <em>The Windup Girl</em>, award-winning author Paolo Bacigalupi returns to the world of his award-winning &quot;The Calorie Man&quot; and &quot;Yellow Card Man&quot; in order to address these questions.","authors":{"author":{"id":"1226977","name":"Paolo Bacigalupi","image_url":"http://photo.goodreads.com/authors/1278742221p5/1226977.jpg","small_image_url":"http://photo.goodreads.com/authors/1278742221p2/1226977.jpg","link":"http://www.goodreads.com/author/show/1226977.Paolo_Bacigalupi","average_rating":"3.80","ratings_count":"8534","text_reviews_count":"2669"}},"published":"2009"}}};
sys.puts('Logged request to ' + req.url);
res.render('index.jade', { json: json });
});
// Start the app!
app.listen(3000);
- if (json.books.book.length)
- each book in json.books.book
.book
img(src='#{book.image_url}')
#{book.title}
- else
.book
img(src='#{json.books.book.image_url}')
#{json.books.book.title}
!!! 5
html(lang="en")
head
title Jade test
body
!= body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment