108

I'm working on a JavaScript dynamically loaded tree view user control. I'd like to test it with real world data.

Does anybody know any public service with an API that provides access to hierarchical data in JSON format?

סטנלי גרונן
  • 2,740
  • 21
  • 43
  • 62
ILya
  • 2,552
  • 4
  • 25
  • 40

5 Answers5

62

Twitter has a public API which returns JSON, for example -

A GET request to:

https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=mralexgray&count=1,

EDIT: Removed due to twitter restricting their API with OAUTH requirements...

{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}

Replacing it with a simple example of the Github API - that returns a tree, of in this case, my repositories...

https://api.github.com/users/mralexgray/repos

I won't include the output, as it's long.. (returns 30 repos at a time) ... But here is proof of it's tree-ed-ness.

enter image description here

dreftymac
  • 27,818
  • 25
  • 108
  • 169
Alex Gray
  • 14,784
  • 6
  • 90
  • 114
  • It's not actually a tree, but since it's the only answer, i'm going to accept it) Thanks. – ILya Apr 10 '12 at 00:11
  • 6
    Umm, I think it is... [looks like a tree](http://f.cl.ly/items/3v0v0Q0B2W233g371w15/Google%20Chrome.png), quacks like a tree, and works like a tree on http://jsontree.com/. Must be a tree, no? – Alex Gray Nov 30 '12 at 12:00
  • 5
    This is not public now... :( – chanchal1987 Jun 22 '13 at 06:56
  • I'm using Rotten Tomatoes movies json feed, but you will need to register and get a key (is free) http://developer.rottentomatoes.com/docs/read/JSON – Braulio Nov 22 '13 at 09:48
  • Another movies feed (needs as well free registration and ip key attached on each request) http://docs.themoviedb.apiary.io/ I used the rotten tomates, and planning to use this one for educational purposes. – Braulio Nov 22 '13 at 10:04
  • 1
    @alexgray just wonder, what kind of soft it is on screenshot? – shabunc Feb 10 '14 at 10:55
  • 3
    @shabunc it is called [Cocoa JSON Editor](http://www.cocoajsoneditor.com). – Alex Gray Feb 10 '14 at 19:37
  • Even better, you can use Mockable.io for free to return whatever response you want. Example: http://demo4083160.mockable.io/getstuff – Patrick Nov 13 '15 at 03:06
  • Reddit also has a public JSON api. just append ".json" to the end of any subreddit. Example: https://www.reddit.com/r/iosprogramming.json – joey Aug 16 '19 at 05:35
33

JSON Test has some

try its free and has other features too.

http://www.jsontest.com/

Venusdharan
  • 355
  • 3
  • 4
11

Tumblr has a public API that provides JSON. You can get a dump of posts using a simple url like http://puppygifs.tumblr.com/api/read/json.

Coderer
  • 21,290
  • 22
  • 71
  • 124
  • There is JSON in the response, but what they actually return is JavaScript that initializes a variable with JSON. Their new V2 API returns "true" JSON but it requires signing up for an API Key or OAuth. – Alex Angas Sep 28 '13 at 06:46
  • The old API supports JSONP in The Usual Way -- pass `?callback=foo` and you get `foo({...})` instead of `var tumblr_api_read={...}`. The API docs don't mention CORS support so I strongly suspect most users would be loading the content via JSONP anyway. – Coderer Sep 28 '13 at 11:50
10

Found one from Flickr that doesn't need registration / api.

Basic sample, Fiddle More info: post

// Querystring, "tags" search term, comma delimited
const query = "https://www.flickr.com/services/feeds/photos_public.gne?tags=soccer&format=json&jsoncallback=?";


// This function is called once the call is satisfied
// http://stackoverflow.com/questions/13854250/understanding-cross-domain-xhr-and-xml-data
let mycallback = function(data) {
  // Start putting together the HTML string
  let htmlString = "";

  // Now start cycling through our array of Flickr photo details
  $.each(data.items, function(i, item) {
    // I only want the ickle square thumbnails
    let sourceSquare = (item.media.m).replace("_m.jpg", "_s.jpg");

    // Here's where we piece together the HTML
    htmlString += '<li><a href="' + item.link + '" target="_blank">';
    htmlString += '<img title="' + item.title + '" src="' + sourceSquare;
    htmlString += '" alt="';
    htmlString += item.title + '" />';
    htmlString += '</a></li>';

  });

  // Pop our HTML in the #images DIV
  $('#images').html(htmlString);
};


// Ajax call to retrieve data
$.getJSON(query, mycallback);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="images"></div>

Another very interesting is Star Wars Rest API

Teocci
  • 4,348
  • 1
  • 34
  • 36
Braulio
  • 1,668
  • 14
  • 20
  • OOps, sorry I missed you were looking for hierarchical data, this is a flat source. I'm was having a hard time looking for public feeds without key registration needs and found this interesting to share. – Braulio Nov 22 '13 at 18:08
2

The Tumbler V2 API provides a pure JSON response but requires jumping through a few hoops:

  1. Register an application
  2. Get your "OAuth Consumer Key" which you'll find when editing your application from the apps page
  3. Use any of the methods that only require an API Key for authentication as this can be passed in the URL, e.g. posts
  4. Enjoy your JSON response!

Example URL: http://api.tumblr.com/v2/blog/puppygifs.tumblr.com/posts/photo?api_key=YOUR_KEY_HERE

Result showing tree structure in Fiddler:

Screenshot

Alex Angas
  • 56,458
  • 39
  • 130
  • 203