API仕様
URLには変換したいXMLのURLを指定します。JSONPとして使う場合は、コールバック関数名を指定すればOKです。
http://pipes.yahoo.com/pipes/pipe.run?_id=DJEg41Ac3BG8IAI2E5PZnA&_callback=コールバック関数名&_render=json&path=パス&url=XMLのURL (GET)
path (optional)
特定のXML要素以下を抜き出すためのパス(xPath)を指定する。未指定の場合はすべてを対象とする。例えば、RSS(例)の<channel>要素以下を取得したい場合は、"channel"と指定する(たぶんルートノードは含めない)。
_callback (optional)
JSONPの場合のみコールバック関数名を指定する。
レスポンス例
以下は、Livedoorが提供するWeather HacksのRSSフィードをJSON変換してみた例です。Yahoo Pipes特有のヘッダーが付くので value.items 以下がメインのデータになります。
{
"count": 1,
"value": {
"callback": "",
"description": "Pipes Output",
"generator": "http://pipes.yahoo.com/pipes/",
"items": [
{
"author": "livedoor Weather Team.",
"category": "天気情報",
"copyright": "(C) NHN Japan Corp. All rights reserved.",
"description": "[ 福岡県の天気概況 ] 九州北部地方は、気圧の谷や寒気の影響で概ね曇りとなっています。
九州北部地方の14日は、はじめ気圧の谷や寒気の影響で曇りとなります
が、高気圧に覆われて次第に晴れるでしょう。
15日は、高気圧に覆われて晴れるでしょう。
波の高さは、九州北部地方の沿岸の海域では14日は3メートル、15日...",
"generator": "http://weather.livedoor.com/",
"guid": {
"content": "http://weather.livedoor.com/area/forecast/400010?r=rss",
"isPermaLink": "true"
},
"image": {
"height": "26",
"link": "http://weather.livedoor.com/",
"title": "livedoor 天気情報",
"url": "http://weather.livedoor.com/img/cmn/livedoor.gif",
"width": "118"
},
"item": [
{
"category": "PR",
"description": "livedoor 天気情報「Weather Hacks」では一般のブロガーの皆さん向けにブログでお天気を表示できる、お天気プラグインを公開しました。使い方はとってもカンタン!手順に沿って作成したHTMLソースを自分のブログに貼り付けるだけです!",
"image": {
"height": "50",
"link": "http://weather.livedoor.com/weather_hacks/plugin.html?pref=40",
"title": "お天気プラグイン - livedoor 天気情報",
"url": "http://weather.livedoor.com/img/weather_hacks/news_title.gif",
"width": "151"
},
"link": "http://weather.livedoor.com/weather_hacks/plugin.html?pref=40",
"pubDate": "Thu, 14 Mar 2013 05:00:00 +0900",
"title": "[ PR ] ブログで福岡県のお天気を簡単ゲット!"
},
{
"category": "天気予報",
"day": "Thursday",
"description": "14日(木)の天気は曇のち晴、最高気温は12℃ でしょう。",
"image": {
"height": "31",
"link": "http://weather.livedoor.com/area/forecast/400010?r=rss20130314",
"title": null,
"url": "http://weather.livedoor.com/img/icon/12.gif",
"width": "50"
},
"link": "http://weather.livedoor.com/area/forecast/400010?r=rss20130314",
"pubDate": "Thu, 14 Mar 2013 05:00:00 +0900",
"title": "[ 14日(木)の天気 ] 福岡 - 曇のち晴 - 最高気温12℃ - 3月14日(木)"
},
...
],
"language": "ja",
"lastBuildDate": "Thu, 14 Mar 2013 05:00:00 +0900",
"ldWeather:lwws": {
"id": "400010"
},
"ldWeather:provider": [
{
"link": "http://www.halex.co.jp/halexbrain/weather/",
"name": "(株)ハレックス"
},
{
"link": "http://tenki.jp/",
"name": "日本気象協会"
}
],
"link": "http://weather.livedoor.com/area/forecast/400010?r=rss",
"pubDate": "Thu, 14 Mar 2013 05:00:00 +0900",
"title": "福岡県 - 福岡の天気 - livedoor 天気情報"
}
],
"link": "http://pipes.yahoo.com/pipes/pipe.info?_id=DJEg41Ac3BG8IAI2E5PZnA",
"pubDate": "Thu, 14 Mar 2013 01:31:23 +0000",
"title": "XML 2 JSON"
}
}
まとめ
ちなみに、このAPIですがタグの属性値はどのように取得できるんでしょうかね... 。時間があったら誰か試してみてください。
0 件のコメント:
コメントを投稿