Skip to content

Instantly share code, notes, and snippets.

@whichlight
Last active August 29, 2015 13:57
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 whichlight/9686078 to your computer and use it in GitHub Desktop.
Save whichlight/9686078 to your computer and use it in GitHub Desktop.
Getting started with Stream

Quick Intro to Embedly Stream

This will be a few quick steps to get started with Stream. Learn more about Stream here.

A few details on using Stream

Note that Stream is free for non commercial purposes, but if you want to use it in something you sell, email support@embed.ly and we'll work something out. We want to encourage awesome projects with Stream, but please use good judgement. The data from Stream may not be redistributed, i.e. you can't reshare Stream as it is.

Get a key

First get an Embedly key. You can sign up for one here. After you sign up, send me a message at kawandeep@embed.ly with your key and org letting me know you'd like to use Stream. I'll go ahead and turn it on for your key.

Your first Curl

Query the stream from the following URL, replacing your-key-here with your key.

http://stream.embed.ly?key=your-key-here

Open up your terminal and type

curl http://stream.embed.ly?key=your-key-here

and that will open up the stream in your terminal. Here is some example output from Stream.

{
"country":"US",
"url":"http://www.businessoffashion.com/2014/03/japans-cross-company-launch-ethical-mega-chain-counterpoint-fast-fashion.html",
"embed":{
  "provider_url":"http://www.businessoffashion.com",
  "description":"TOKYO, Japan - One of Japan's leading fashion retailers, Cross Company, will launch a new chain of fashion stores this Autumn, specifically targeting the US and European markets, as well as Japan.",
  "title":"Cross Company to Launch Ethical Mega-Chain, Counterpoint to Fast Fashion",
  "url":"http://www.businessoffashion.com/2014/03/japans-cross-company-launch-ethical-mega-chain-counterpoint-fast-fashion.html",
  "author_name":"",
  "height":0,
  "thumbnail_width":655,
  "width":0,
  "html":null,
  "author_url":"",
  "version":"1.0",
  "provider_name":"Businessoffashion",
  "thumbnail_url":"http://cdn.businessoffashion.com/wp-content/uploads/2014/03/7ds.jpg",
  "type":"link",
  "thumbnail_height":430
  }
}

This is a single line from stream. Stream returns new line separated JSON objects of URLs that are going through the Embedly API. You can see more details on how that data is pre-processed here. Note the attributes which include the Embed response for the URL as well as the country. You can compute trending and top embedded URLs by country or filter by domain for example.

If you want Stream URLs with Extract data instead, include &format=extract to your call.

Out-of-Band Messages

You may receive a response that is not of a URL, but of something else. These messages will be a dict of two fields: code and message. The only message like this right now is posted if your app is not keeping up with the stream and URLs have been dropped. These messages do not stop the flow of the Stream. Here is an example:

{"code": "QUEUEING", "message": "Your message queue is full -- to avoid losing data increase your processing rate"}

Example Projects

  • Stream Test. A simple project just to test out the stream from a Node app.
  • Thumbnail River. A visualization of the stream. This uses Display to resize the thumbnails of the media coming through the stream and animate them across the screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment