
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>daniel shiffman &#187; book</title>
	<atom:link href="http://www.shiffman.net/category/book/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shiffman.net</link>
	<description></description>
	<lastBuildDate>Tue, 24 Jan 2012 03:41:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>The Economics of Self-Publishing via Kickstarter (so far)</title>
		<link>http://www.shiffman.net/2011/01/28/the-economics-of-self-publishing-via-kickstarter-so-far/</link>
		<comments>http://www.shiffman.net/2011/01/28/the-economics-of-self-publishing-via-kickstarter-so-far/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 19:23:37 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[kickstarter]]></category>
		<category><![CDATA[nature of code]]></category>
		<category><![CDATA[self-publishing]]></category>

		<guid isPermaLink="false">http://www.shiffman.net/?p=712</guid>
		<description><![CDATA[Ever since I launched the Nature of Code kickstarter page I&#8217;ve been getting a ton of questions about the economics of this book project. Though I hate to take any precious moments away from the actual writing of the book, &#8230; <a href="http://www.shiffman.net/2011/01/28/the-economics-of-self-publishing-via-kickstarter-so-far/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ever since I launched the <a href="https://www.kickstarter.com/projects/shiffman/the-nature-of-code-book-project">Nature of Code kickstarter page</a> I&#8217;ve been getting a ton of questions about the economics of this book project.   Though I hate to take any precious moments away from the actual writing of the book, I thought I&#8217;d take some time to lay out some thoughts.  This is all an experiment, and one that I hope will help future authors with evaluating the pros and cons of self-publishing.   So in the interest of transparency here is where I sit at the moment.  Admittedly I&#8217;m flying by the seat of my pants.</p>
<p>Originally I had planned to raise approximately $5,000.  My thought was as follows.  I want to hire an editor (done! the wonderful <a href="http://shannonhunt.com/">Shannon Hunt</a>).   I want to hire a designer.  I want to hire an illustrator.  I want to hire some technical reviewers.  I haven&#8217;t worked out the exact costs, but I was planning on spending somewhere between one and three thousand dollars on each of the above, depending on the scope of work, etc.  I had always planned to fork out some cash out of pocket, but figured kickstarter would ease the burden.  Let&#8217;s just say, as a rough wild guess estimate, I&#8217;m going to spend $6,000 on any labor associated with production (editing, design, technical review, proofreading, etc.)  Come to think of it, that might be a bit low, but that&#8217;s the number I&#8217;m sticking with for now.</p>
<p>Next, there&#8217;s the matter of printing the book itself.   I haven&#8217;t sorted this out either, but I&#8217;m planning on using a print-on-demand service (such as <a href="http://www.lulu.com">lulu</a>).  Let&#8217;s say the book ends up around 350 pages and costs $15 to print each copy (might be less, might be more, depending on quality, etc.).   As of this writing I have 283 pre-orders on kickstarter for the print book.  That&#8217;s $4,245.   Then I&#8217;ll probably want to send out some free copies, review copies for teachers, review copies for bloggers, press, etc. Let&#8217;s say I send out 50 free copies.   There&#8217;s another $750.   Oh right, and shipping and handling.  Let&#8217;s say it&#8217;s $3 per book.  (Once the book is out, shipping and handling will be passed onto the customer, but I&#8217;ll be handling it for all kickstarter &#8220;pre-orders&#8221;.)    So another $999 for shipping.</p>
<p>So now (with some rounding) we have $6,000 (fees + labor) + $5,000 (first round of printing) + $1,000 (shipping). A total of $12,000.  </p>
<p>Kickstarter money to date: $12,167.</p>
<p>Total profit: $167</p>
<p>(Note I&#8217;ve ignored some important details like Kickstarter&#8217;s 5%, but this is close enough).</p>
<p>Here&#8217;s the thing.  That might not seem so great.  But it is. It&#8217;s fantastic. It&#8217;s amazing.  What it means for me is that I&#8217;ve written a book (and published it).  It also means that I own (exclusively) all of the content in the book.  It means that if I continue to sell the book as a PDF, I keep 100% of the price (minus any transaction fees).    Let&#8217;s take my first book <a href="http://www.learningprocessing">Learning Processing</a>, published by MKP/Elsevier.  I think for a kindle version, I barely end up with a dollar (I need to check this, maybe it&#8217;s more like 2, but in any case, it&#8217;s something quite small).</p>
<p>Regarding print copies, with Learning Processing (which retails at the somewhat ridiculous price of $50), I receive approximately $3 per copy sold (very rough estimate).  This self-published book could theoretically reach the customer for $25 (half the price!) and I would receive ~$10 for that copy.  </p>
<p>And if I want to put all the content online for free as tutorials, I can.  </p>
<p>So, this is where I stand as far as today.  Really though, what I care about the most is just writing the darn thing.  So back to that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shiffman.net/2011/01/28/the-economics-of-self-publishing-via-kickstarter-so-far/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Nature of Code Book Chapter 1 Draft Available</title>
		<link>http://www.shiffman.net/2009/06/02/nature-of-code-book-2/</link>
		<comments>http://www.shiffman.net/2009/06/02/nature-of-code-book-2/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 20:41:20 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[nature of code]]></category>
		<category><![CDATA[print on demand]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[publishing]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[vectors]]></category>

		<guid isPermaLink="false">http://www.shiffman.net/?p=429</guid>
		<description><![CDATA[Ok, so I may very well be one of the slowest writers ever, but I am pleased to finally announce that I have completed a draft chapter for what I hope will become my next book: The Nature of Code. &#8230; <a href="http://www.shiffman.net/2009/06/02/nature-of-code-book-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ok, so I may very well be one of the slowest writers ever, but I am pleased to finally announce that I have completed a draft chapter for what I hope will become my next book: <a href="http://www.learningprocessing.com/noc/">The Nature of Code</a>.  Based on my experience getting <a href="http://www.learningprocessing.com">Learning Processing</a> out into the world I&#8217;ve decided to go ahead and experiment with self-publishing.  I&#8217;m not sure what service I&#8217;ll ultimately use or exactly how I&#8217;ll distribute the text (most likely as a PDF for sale online as well as print-on-demand physical book) so feel free to write me with suggestions, etc.  </p>
<p>Let&#8217;s take a moment to go over some of the finer points as to why I am doing this.</p>
<h2>Dollars and cents</h2>
<p><a href="http://www.learningprocessing.com">Learning Processing</a> retails for $49.95 (amazon&#8217;s discount is 10%: $44.95).  When the publisher sells a copy of the book, I get some money (yay for me!).  Based on my first royalty statement, this works out to approximately $3.73 per copy.  Sure, I&#8217;m not writing books about programming with <a href="http://www.processing.org">Processing</a> to get rich, but I did spend a couple years working hard on the project and every little bit counts.  </p>
<p>Let&#8217;s assume for the moment that I could sell the same exact book via <a href="http://www.lulu.com">lulu.com</a>.   The actual cost for printing the book would be ~$14.00.  Ok, so let&#8217;s say I choose to sell the book at $25.00 (half the actual current cost.)   That&#8217;s $11 of profit for every book sold, lulu takes 20%, leaving me with ~$8.80 per book sold.  The book costs half as much and I get more than double the revenue!  Now, this is just one scenario.  I haven&#8217;t decided what service to use, how much of a mark-up is appropriate, etc.  But you get the idea.   There&#8217;s no reason a no color, no frills, beginner programming text needs to be $50.00.</p>
<h2>Release early, Release often</h2>
<p>As an author, it&#8217;s just nice to have a lot of flexibility with the process.  With self-publishing, I can do things like release early drafts of PDFs online for feedback (see below).  This is not something I could have easily done with a traditional publishing house.  Instead of spending months or years writing a book before anyone sees anything, the idea is that I can just put stuff out there (for cheap) as I type and then iterate.  And there are no limits of how I choose to distribute the book (excerpts published as tutorials on Processing.org? Free on my site? PDF for a million dollars?  Audio book? It&#8217;s all fair game.). </p>
<p>Once the book is done, I can easily continue to make changes and update.  Now, Processing has a fairly stable API, one that is not going to undergo massive changes anytime soon.  And sure, how gravity works, the formula for the mandelbrot set, these aren&#8217;t concepts that are going to change that often.  Nevertheless, anytime you write a technical book, technology changes faster than you can write, and no matter how careful you are, there&#8217;s no way to avoid making a serious amount of mistakes.  With self-publishing and print-on-demand, I don&#8217;t have to wait (possibly years) for a print run to finish selling in order to make changes.   I could make them <b><i>daily</i></b> if I wanted to.  And that Chapter on PHP that I realized I really should have included in Learning Processing, well, I could just add it whenever I so choose.</p>
<h2>Downfalls</h2>
<p>There are certainly some pitfalls to self-publishing.  One major issue, of course, is deadlines.  Without a publisher I&#8217;ve got very little pushing me forward other than myself.  In fact, getting this first chapter done took me twice as long as I intended.  And other projects are getting in the way, I&#8217;m not sure how fast I will actually get to chapter #2.  </p>
<p>The other main issue is distribution.  I don&#8217;t care if I don&#8217;t get my book in Barnes and Noble, I mean who is really buying Processing books at Barnes and Noble?!   I do need Amazon.com, but looks like there are plenty of print-on-demand options that can be distributed via Amazon.  The major question for me is university bookstores.  I don&#8217;t have any numbers, but it does seem to me that Learning Processing gets stocked in a lot of school bookstores because it is being used as a text for classes.  So this is something I need to figure out, how can I get a self-published book to stores.</p>
<p>Oh yeah, an index.  The publisher made an index for me.  There&#8217;s got to be a way I don&#8217;t need them for that, though.</p>
<p>In the end, I could be wrong.  This could be a failed experiment.  Maybe no one will buy it, maybe I won&#8217;t finish it.  The nice thing, however, is that if I&#8217;m really headed in the wrong direction here, I can always change my mind and start sending out proposals to a publisher.  But the other way around, going from a publisher to self-published, well, that wouldn&#8217;t be so easy.</p>
<p>So, if you&#8217;re interested in checking out what I&#8217;ve started so far, for now (subject to change), you can purchase the PDF on lulu.com.  I&#8217;m selling draft chapters for small amounts with the idea that I could raise a little bit of money to pay for design, typesetting, technical editing, etc. once I&#8217;ve got a more finished draft.</p>
<p><a href="http://stores.lulu.com/dshiffman">http://stores.lulu.com/dshiffman</a></p>
<p>UPDATE: I&#8217;m also looking for a service that would let users buy early drafts of a book and then upgrade to the final version at a discount or for free.  Suggestions for how to do this welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shiffman.net/2009/06/02/nature-of-code-book-2/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Path Following Dot Product Tutorial</title>
		<link>http://www.shiffman.net/2009/03/02/path-following-dot-product-tutorial/</link>
		<comments>http://www.shiffman.net/2009/03/02/path-following-dot-product-tutorial/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 03:49:06 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[dot product]]></category>
		<category><![CDATA[draft]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[nature of code]]></category>
		<category><![CDATA[path following]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[Teaching]]></category>

		<guid isPermaLink="false">http://www.shiffman.net/?p=388</guid>
		<description><![CDATA[As an addendum to the previous post, here&#8217;s an early draft excerpt from Chapter 7 on steering behaviors, more specifically a tutorial related to my new path following examples. Also an excuse to cover the dot product in more detail. &#8230; <a href="http://www.shiffman.net/2009/03/02/path-following-dot-product-tutorial/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shiffman.net/teaching/nature/path-following/"><br />
<img src="http://www.shiffman.net/itp/classes/nature/pathimages/pathfollow.jpg"/></a></p>
<p>As an addendum to the previous post, here&#8217;s <a href="http://www.shiffman.net/teaching/nature/path-following/">an early draft excerpt from Chapter 7 on steering behaviors</a>, more specifically a tutorial related to my new <a href="http://www.shiffman.net/teaching/nature/steering">path following examples</a>.   Also an excuse to cover the <a href="http://en.wikipedia.org/wiki/Dot_product">dot product</a> in more detail.  All based on <a href="http://www.red3d.com/cwr/steer/">Craig Reynolds</a> of course.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shiffman.net/2009/03/02/path-following-dot-product-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nature of Code Book</title>
		<link>http://www.shiffman.net/2009/03/02/nature-of-code-book/</link>
		<comments>http://www.shiffman.net/2009/03/02/nature-of-code-book/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 03:35:43 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[nature of code]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[Teaching]]></category>

		<guid isPermaLink="false">http://www.shiffman.net/?p=378</guid>
		<description><![CDATA[This semester, I&#8217;ve started working on expanding my nature of code tutorials into a book. My plan is to self-publish (looking into a few options) and have drafts available for download / purchase as early as this summer. I&#8217;ll also &#8230; <a href="http://www.shiffman.net/2009/03/02/nature-of-code-book/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.shiffman.net/images/noc/1.jpg"/> <img src="http://www.shiffman.net/images/noc/3.jpg"/><img src="http://www.shiffman.net/images/noc/2.jpg"/> <img src="http://www.shiffman.net/images/noc/5.jpg"/> <img src="http://www.shiffman.net/images/noc/8.jpg"/> </p>
<p>This semester, I&#8217;ve started working on expanding my <a href="http://www.shiffman.net/teaching/nature">nature of code tutorials</a> into a book.  My plan is to self-publish (looking into a few options) and have drafts available for download / purchase as early as this summer.  I&#8217;ll also be publishing excerpts from the book as tutorials on <a href="http://www.processing.org/learning/tutorials/">processing.org</a> (the first will be a PVector tutorial) and on this site as well.</p>
<p><a href="http://www.learningprocessing.com/noc/">sign up for e-mail updates about the book</a></p>
<p>Here is a <a href="http://www.learningprocessing.com/noc/table_of_contents.pdf">PDF of the draft table of contents</a> for those who are curious.   Feedback is welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shiffman.net/2009/03/02/nature-of-code-book/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Learning Processing Available Now</title>
		<link>http://www.shiffman.net/2008/08/28/learning-processing-available-now/</link>
		<comments>http://www.shiffman.net/2008/08/28/learning-processing-available-now/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 03:18:30 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[teaching_]]></category>
		<category><![CDATA[learning processing]]></category>

		<guid isPermaLink="false">http://www.shiffman.net/?p=237</guid>
		<description><![CDATA[Just a quick note to let you know that my book, Learning Processing, is now available for purchase. If you are local to NYC, you can buy the book at the NYU bookstore. Amazon says &#8220;out of stock&#8221;, but I&#8217;m &#8230; <a href="http://www.shiffman.net/2008/08/28/learning-processing-available-now/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.learningprocessing.com" title="nyu bookstore by shiffman, on Flickr"><img src="http://farm4.static.flickr.com/3168/2803989977_564460fcd0_m.jpg" width="240" height="180" alt="nyu bookstore" /></a></p>
<p>Just a quick note to let you know that my book, <a href="http://www.learningprocessing.com">Learning Processing</a>, is now available for purchase.  If you are local to NYC, you can buy the book at the <a href="http://www.bookstores.nyu.edu/">NYU bookstore</a>. </p>
<p><a href="http://www.amazon.com/Learning-Processing-Beginners-Programming-Interaction/dp/0123736021/">Amazon says &#8220;out of stock&#8221;</a>, but I&#8217;m told by the publisher that this is an error and they do, in fact, have copies. Also, <a href="http://search.a1books.com/cgi-bin/mktSearch?act=showDesc&#038;code=gbase&#038;rel=1&#038;ITEM_CODE=0123736021#minPrice">at $37.00, this seems to be the cheapest option online</a> that I can find.</p>
<p>All the example code will be available live online at <a href="http://www.learningprocessing.com">learningprocessing.com</a> by early next week.  Feel free to contact me with comments, questions, feedback!</p>
<p>Who is this book for?  Check out <a href="http://www.shiffman.net/2008/07/31/book-release-learning-processing/">my earlier post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shiffman.net/2008/08/28/learning-processing-available-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Book Release: Learning Processing</title>
		<link>http://www.shiffman.net/2008/07/31/book-release-learning-processing/</link>
		<comments>http://www.shiffman.net/2008/07/31/book-release-learning-processing/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 20:38:18 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[p5]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[teaching_]]></category>

		<guid isPermaLink="false">http://www.shiffman.net/?p=216</guid>
		<description><![CDATA[I&#8217;m pleased to announce that my new programming with Processing book will be released this August (by the end of the month). You can pre-order the book from Amazon, download a sample chapter from the web site, and, yes, even &#8230; <a href="http://www.shiffman.net/2008/07/31/book-release-learning-processing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.learningprocessing.com"><img src="http://farm4.static.flickr.com/3284/2672959056_695f5e8258.jpg" width="500" height="324" alt="Learning Processing" /></a></p>
<p>I&#8217;m pleased to announce that my new programming with <a href="http://www.processing.org"> Processing</a> book will be released this August (by the end of the month).  You can <a href="http://www.amazon.com/Learning-Processing-Beginners-Programming-Interaction/dp/0123736021/">pre-order the book from Amazon</a>, <a href="http://www.learningprocessing.com">download a sample chapter from the web site</a>, and, yes, even <a href="http://www.facebook.com/pages/Learning-Processing/18113426918">become a fan</a> of the book on facebook (since that&#8217;s what all the 35 year olds are doing these days.)</p>
<p>A few things I&#8217;d like to say about the book:   </p>
<p>My goal for &#8220;Learning Processing&#8221; was to write something for the complete and total programming beginner.  If you&#8217;ve never written a line of code before in your life, but want to get started creating your own digital media tools then I wrote this book for you.   There are <a href="http://processing.org/learning/books/index.html">several other wonderful Processing</a> books out there and I hope mine will complement them nicely.  A special thanks to Casey, Ben, and Ira who kept encouraging and inspiring me as their books were being published.</p>
<p>The book is also geared towards the teacher.  It&#8217;s not my belief that such a person will necessarily learn any new skills from the book (assuming they have a programming background), however, my hope is that the book will encourage and help facilitate the teaching of programming.   It is structured with 10 lessons (complete with examples and exercises) and can act as a ready-made syllabus for a beginner interactive media / programming class.  In fact, the book is modeled exactly on ITP&#8217;s <a href="http://itp.nyu.edu/varwiki/Syllabus/ICM-All-F07">Introduction to Computational Media</a> course. </p>
<p>The first half of the book is all fundamentals:  pixels, variables, conditionals, loops, functions, objects, arrays.  The second half is an introduction to select advanced topics:  3D, images, video, data, sound, etc. (<a href="http://www.learningprocessing.com/samples/table_of_contents.pdf">download full table of contents</a>).   And although the web site is currently just a splash page, it&#8217;s my intention to make available all the examples (and exercise answers) at the site.  The full site should launch in the next few weeks (a big thanks to <a href="http://www.mandalatv.net/">Rich Hauck</a> who is helping to build the site.)</p>
<p>If anyone is interested in teaching with the book come this fall, please feel free to drop me a line and I&#8217;d be happy to answer any questions.  It&#8217;s also my hope that this book can teach programming to high school students, however, I don&#8217;t have as much experience in this area. . . but if anyone is looking to try it out with younger students, please let me know and I would love to help.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shiffman.net/2008/07/31/book-release-learning-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing Yahoo Search Library</title>
		<link>http://www.shiffman.net/2007/08/05/processing-yahoo-search-library/</link>
		<comments>http://www.shiffman.net/2007/08/05/processing-yahoo-search-library/#comments</comments>
		<pubDate>Mon, 06 Aug 2007 02:51:22 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[p5]]></category>
		<category><![CDATA[processing.org]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://www.shiffman.net/2007/08/05/processing-yahoo-search-library/</guid>
		<description><![CDATA[2011 Update: While this library may still work, I am deprecating it as Yahoo does not support the Java Search API any longer as far as I can tell Now, I am rather overdue for an update on my upcoming &#8230; <a href="http://www.shiffman.net/2007/08/05/processing-yahoo-search-library/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>2011 Update: While this library may still work, I am deprecating it as Yahoo does not support the Java Search API any longer as far as I can tell</strong></p>
<p><img src="http://www.shiffman.net/p5/pyahoo_files/names.jpg"/></p>
<p>Now, I am rather overdue for an update on <a href="http://book.shiffman.net">my upcoming book</a>.  I&#8217;ll be posting details soon.   However, in the course of finishing up a chapter on String parsing, I discovered that my good friend, the <a href="http://code.google.com/apis/soapsearch/">Google SOAP API</a> is no longer being supported (obviously, I&#8217;m a little late on the ball here.) </p>
<p>So, I quickly whipped up a <a href="http://www.processing.org">Processing</a> library to make use of the Yahoo Search API.  Now, you can access the Yahoo! API directly in Processing.  There&#8217;s <a href="http://processing.org/learning/libraries/yahoosearch.html">even an example here</a>.  However, you would have to write your own thread if you wanted to search asynchronously.  In addition, if you&#8217;re not comfortable diving into outside Java APIs, you might struggle to figure out the syntax.   (<a href="http://www.realtimeart.com/switchboard/">Switchboard</a> also provides an interface to the Yahoo! API.)</p>
<p>So I set out (as an example for my book) to make a quick and easy bridge to the Yahoo API.    </p>
<li class="arrow"><a href="http://www.shiffman.net/p5/pyahoo_files/pyahoo.zip">Download the library here</a></li>
<li class="arrow"><a href="http://developer.yahoo.com">Go and get a developer ID</a></li>
<li class="arrow"><a href="http://developer.yahoo.com/download">Download the Yahoo! Search SDK</a>  Find the file: yahoo_search-2.X.X.jar and put it in the library folder (along with the above download).</li>
<p>Finally, take a peek at this example code.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Import the library</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">pyahoo.*</span><span style="color: #339933;">;</span>
&nbsp;
YahooSearch yahoo<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">400</span>,<span style="color: #cc66cc;">400</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Make a search object</span>
  yahoo <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> YahooSearch<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>,<span style="color: #0000ff;">&quot;YOUR API KEY HERE&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> mousePressed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  yahoo.<span style="color: #006633;">search</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;processing.org&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// You can request more results like so (the default is 10):</span>
  <span style="color: #666666; font-style: italic;">// yahoo.search(&quot;processing.org&quot;,30);</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  noLoop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// The searches will come in one at a time to here when finished</span>
<span style="color: #000066; font-weight: bold;">void</span> searchEvent<span style="color: #009900;">&#40;</span>YahooSearch yahoo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// You can get the titles, URLs, or Summaries back as an array of Strings</span>
  <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> titles <span style="color: #339933;">=</span> yahoo.<span style="color: #006633;">getTitles</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> urls <span style="color: #339933;">=</span> yahoo.<span style="color: #006633;">getUrls</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>I searched for &quot;</span> <span style="color: #339933;">+</span> yahoo.<span style="color: #006633;">getSearchString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;There are a total of &quot;</span> <span style="color: #339933;">+</span> yahoo.<span style="color: #006633;">getTotalResultsAvailable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; results available&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Here are the first &quot;</span> <span style="color: #339933;">+</span> yahoo.<span style="color: #006633;">getNumberRequested</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> titles.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;___________&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Item # &quot;</span> <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    println<span style="color: #009900;">&#40;</span>titles<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    println<span style="color: #009900;">&#40;</span>urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// You can also access the Yahoo API Directly by asking for the WebSearchResult object:</span>
  <span style="color: #666666; font-style: italic;">// WebSearchResults results = yahoo.getResults();</span>
  <span style="color: #666666; font-style: italic;">// WebSearchResult[] results = yahoo.getResultsArray();</span>
  <span style="color: #666666; font-style: italic;">// In this mode, make sure to import the Yahoo library up topl</span>
  <span style="color: #666666; font-style: italic;">// import com.yahoo.search.WebSearchResults;</span>
  <span style="color: #666666; font-style: italic;">// See Yahoo API documentation for more</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>There&#8217;s also a fancier example (mostly uncommented, sorry) that produced the image at the top of this post <a href="http://www.shiffman.net/p5/pyahoo_files/names.zip">here</a>.  </p>
<p>Thoughts?  Helpful?  Useful?  </pre>
]]></content:encoded>
			<wfw:commentRss>http://www.shiffman.net/2007/08/05/processing-yahoo-search-library/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

