<?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>underdog-blog &#187; ajax</title>
	<atom:link href="http://blog.underdog-projects.net/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.underdog-projects.net</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 26 Feb 2010 20:03:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>use yahoo finance streaming api</title>
		<link>http://blog.underdog-projects.net/2008/12/use-yahoo-finance-streaming-api/</link>
		<comments>http://blog.underdog-projects.net/2008/12/use-yahoo-finance-streaming-api/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 10:23:33 +0000</pubDate>
		<dc:creator>jens</dc:creator>
				<category><![CDATA[yahoo finance]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[streaming api]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://blog.underdog-projects.net/?p=36</guid>
		<description><![CDATA[In the past I used this ruby script to poll for the current stock data and put it into a database to create a little history. Recently I saw a new feature on the yahoo finance homepage. Now it is possible to enable a streaming option and then you get a live update on certain [...]]]></description>
			<content:encoded><![CDATA[<p>In the past I used <a href="http://rubyforge.org/projects/yahoofinance/">this ruby script</a> to poll for the current stock data and put it into a database to create a little history.</p>
<p>Recently I saw a new feature on the yahoo finance homepage. Now it is possible to enable a streaming option and then you get a live update on certain values via AJAX. So I thought why not get this feature and let yahoo stream the content to the client instead of polling the server from time to time.</p>
<p>So I tried to capture the javascript request with wireshark, so that I could reproduce it. This is what it looks like:</p>
<blockquote><p>GET /streamer/1.0?s=^GDAXI,USD=X&amp;o=^N225,LHS.F,JI4.F,EEX.F,HEI.F,CBK.F,PRE.F,NDX1.F&amp;k=c10,g00,h00,l10,p20,t10&amp;j=c10,l10,p20,t10&amp;r=0&amp;marketid=us_market&amp;callback=parent.yfs_u1f&amp;mktmcb=parent.yfs_mktmcb&amp;gencallback=parent.yfs_gencb HTTP/1.1<br />
Host: streamerapi.finance.yahoo.com</p></blockquote>
<p>Here is what I got on this request so far:</p>
<p>parameter &#8216;s&#8217; -&gt; symbol on the main site (what you currently looking at)</p>
<p>parameter &#8216;o&#8217; -&gt; that is the ticker on the top</p>
<p>parameter &#8216;k&#8217; and &#8216;j&#8217; -&gt; that are the values that are transfered</p>
<p>c10 -&gt; unknown</p>
<p>g00 -&gt; day low</p>
<p>h00 -&gt; day high</p>
<p>l10 -&gt; current price</p>
<p>p20 -&gt; unknown</p>
<p>t10 -&gt; timstamp</p>
<p>a00 -&gt; ask</p>
<p>b00 -&gt; bid</p>
<p>With that data you can build a Push-Client with your own custom data. Here is a sample Request for what I needed.</p>
<pre class="prettyprint lang-sh">wget -Obla 'http://streamerapi.finance.yahoo.com/streamer/1.0?s=^GDAXI,USD=X&amp;o=BEI.F,SIE.F,PRA.F&amp;k=l10,a00,b00,g00,h00&amp;j=l10,a00,b00,g00,h00&amp;r=0&amp;marketid=us_market&amp;callback=parent.yfs_u1f&amp;mktmcb=parent.yfs_mktmcb&amp;gencallback=parent.yfs_gencb'</pre>
<p>(Streaming the current &#8216;ask&#8217;, &#8216;bid&#8217; and &#8216;price&#8217; values for the stocks &#8216;BEI.F&#8217;,'SIE.F&#8217; and &#8216;PRA.F&#8217;.)</p>
<p>The response for that looks like that:</p>
<pre class="prettyprint lang-html">&lt;html&gt;
&lt;head&gt;
&lt;script type='text/javascript'&gt; document.domain='finance.yahoo.com';&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;&lt;/body&gt;
&lt;script&gt;try{parent.yfs_mktmcb({"unixtime":1228213139,"open":1228228200,"close":1228251600});}catch(e){}&lt;/script&gt;
&lt;script&gt;try{parent.yfs_u1f({"USD=X":{l10:"1.00",a00:"1.00",b00:"1.00",g00:"0.00",h00:"0.00"}});}catch(e){}&lt;/script&gt;
&lt;script&gt;try{parent.yfs_u1f({"BEI.F":{l10:"42.31",a00:"41.70",b00:"41.53",g00:"42.31",h00:"43.95"}});}catch(e){}&lt;/script&gt;
&lt;script&gt;try{parent.yfs_u1f({"SIE.F":{l10:"44.46",a00:"44.26",b00:"44.20",g00:"44.40",h00:"47.55"}});}catch(e){}&lt;/script&gt;</pre>
<p>No you can parse that document for the requested Data. But be carefull because the html structure is never closing (at least not as lang as the streaming goes on).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.underdog-projects.net/2008/12/use-yahoo-finance-streaming-api/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
