【问题标题】:Is there any publicly accessible JSON data source to test with real world data? [closed]是否有任何可公开访问的 JSON 数据源来测试真实世界的数据? [关闭]
【发布时间】:2012-01-07 16:31:03
【问题描述】:

我正在开发一个 JavaScript 动态加载的树形视图用户控件。我想用真实世界的数据来测试它。

是否有人知道任何公共服务的 API 提供对 JSON 格式分层数据的访问?

【问题讨论】:

标签: javascript json testing treeview


【解决方案1】:

Twitter has a public API 返回 JSON,例如 -

GET 请求:

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

编辑:由于 twitter 用OAUTH 要求限制他们的 API 被删除...

{"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}]}

Github API 的一个简单示例替换它 - 它返回一棵树,在本例中为我的存储库...

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

我不会包含输出,因为它很长..(一次返回 30 个 repos)...但这里证明它是树形的。

【讨论】:

  • 它实际上不是一棵树,但既然它是唯一的答案,我会接受它)谢谢。
  • 嗯,我认为它是...looks like a tree,像树一样嘎嘎叫,在jsontree.com 上像树一样工作。一定是一棵树,不是吗?
  • 现在不公开... :(
  • @alexgray 只是想知道,屏幕截图是什么软?
  • @shabunc 它被称为Cocoa JSON Editor
【解决方案2】:

JSON 测试有一些

免费试用,还有其他功能。

http://www.jsontest.com/

【讨论】:

  • 从他们的主机收到“超过配额”错误。想必大家都知道了。
  • 是的。超额错误仍然存​​在。返回 503 -_-。
  • 截至 2016 年 5 月仍然存在。至少你知道你没有得到一个空白的身体,对吧?
  • 现在是 2016 年,还没有 HTTPS 支持,这是什么鬼?
  • 似乎不接受POST 请求。
【解决方案3】:

Tumblr 有一个提供 JSON 的public API。您可以使用http://puppygifs.tumblr.com/api/read/json 之类的简单网址获取帖子转储。

【讨论】:

  • 响应中有 JSON,但它们实际返回的是 JavaScript,它使用 JSON 初始化变量。他们的新 V2 API 返回“真实”JSON,但需要注册 API 密钥或 OAuth。
  • 旧 API 以通常的方式支持 JSONP —— 传递 ?callback=foo 并且你得到 foo({...}) 而不是 var tumblr_api_read={...}。 API 文档没有提到 CORS 支持,所以我强烈怀疑大多数用户无论如何都会通过 JSONP 加载内容。
【解决方案4】:

从 Flickr 找到一个不需要注册/api。

Basic sample, Fiddle 更多信息: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>

另外一个很有意思的是Star Wars Rest API

【讨论】:

  • 哎呀,对不起,我错过了你在寻找分层数据,这是一个平面源。我很难寻找没有关键注册需求的公共提要,并发现这很有趣。
【解决方案5】:

Tumbler V2 API 提供纯 JSON 响应,但需要跳过几个环节:

  1. Register an application
  2. the apps page 编辑应用程序时获取您的“OAuth 消费者密钥”
  3. 使用任何the methods 只需要一个 API 密钥进行身份验证,因为这可以在 URL 中传递,例如posts
  4. 享受您的 JSON 响应!

示例网址:http://api.tumblr.com/v2/blog/puppygifs.tumblr.com/posts/photo?api_key=YOUR_KEY_HERE

Fiddler 中显示树结构的结果:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-09
    • 1970-01-01
    • 2011-01-15
    • 2010-11-09
    • 2019-12-13
    相关资源
    最近更新 更多