JavaScript + PHP = Real-time Stock Quote API

0 MIN READ • Oct 30, 2013

Have you ever wanted to build a stock quote app that updates in real time? Or more generally speaking, maybe you want to create an app that streams information and presents it on a real-time user interface on an HTML5 web browser. Well, it's easy with PubNub.

We built a real-time stock streaming app with JavaScript, PHP, and PubNub to show you just how easy it is. You can check out the live working stock quote API demo, or go straight to the GitHub Repository to get started. We'll supply the code you need.

stock quote APIThe app sends data from a PHP Server Process to an HTML5 JavaScript app in real-time. Stock quotes are broadcast from the PHP server into the PubNub network where the HTML5 JavaScript app receives the WebSockets data and displays it in real-time. A full stock quote API walk through is available here.

Note: Our data stream of stock prices is live data, but the numbers are randomized (so don't make any financial decisions based on them.)

Get Started
Sign up for free and use PubNub to power real-time stock quotes

Jan 12, 2015

Publish vs Subscribe and Real-Time Data Streams

This blog post gives an overview of real-time data streams and the pubsub, publish/subscribe paradigm, including use cases and how to do it yourself.
Michael Carroll
Michael Carroll
Jan 3, 2017

Real-time Global Currency Exchange Rate: Xignite

How to stream live-updating global currency exchange rates in real time using the Xignite block and PubNub.
Michael Carroll
Michael Carroll
Real-Time
Oct 25, 2026

PubNub DataSync vs. real-time databases: Where your app's live state belongs

When to keep live app state in PubNub DataSync, when you still need a real-time database, and how a marathon app splits its data between them.
Dawid Urbas
Dawid Urbas