以下は <URL>ine/ から、今回使う API の仕様をページごとコピーしたものです。まずこれを把握してください。In this day and age, everyone…
Private research annotation
Sign in to add a private research label or note.
- User
以下は ine/ から、今回使う API の仕様をページごとコピーしたものです。まずこれを把握してください。In this day and age, everyone and their dog has an API. So why not have an API for dogs? Shibe.online is that API.
To get some dogs, just make a GET request to the following URL:
ine/api/shibes?count=[1-100]&urls=[true/false]&httpsUrls=[true/false] And you'll get back a response of random images of shibes that looks something like this:
[ "image url 1", "image url 2", ... ] And if those options in the URL aren't self-explanatory enough, here's a simple guide:
Name Possible Values Description count integers 1-100 The number of images to be returned. Default is 1. urls true/false Should the API return URLs or filenames without extensions? URLs are the default. httpsUrls true/false Should the URLs be HTTPS or HTTP? They're HTTPS by default now.
- Assistant
このAPIは、犬の画像を取得するためのものです。以下のURLにGETリクエストを送信すると、ランダムな犬の画像が含まれたJSONレスポンスが返されます。
────────────────────────────────────────────────────────────────────
bashCopy codeine/api/shibes?count=[1-100]&urls=[true/false]&httpsUrls=[true/false]
レスポンスは以下のような形式になります。
────────────────────────────────────────────────────────────────────
jsonCopy code[ "image url 1", "image url 2", ... ]
URLのパラメータは次のように説明されています。
count: 返される画像の数を指定します。デフォルトは1です。
urls: APIがURLまたは拡張子なしのファイル名を返すかどうかを指定します。デフォルトではURLが返されます。
httpsUrls: URLがHTTPSまたはHTTPであるかどうかを指定します。デフォルトではHTTPSが使用されます。
count: 返される画像の数を指定します。デフォルトは1です。
urls: APIがURLまたは拡張子なしのファイル名を返すかどうかを指定します。デフォルトではURLが返されます。
httpsUrls: URLがHTTPSまたはHTTPであるかどうかを指定します。デフォルトではHTTPSが使用されます。
- User
ありがとうございます。それでは、この API から Node-RED の http request ノードを使ってデータを取得するフローをください。インポート可能な JSON データでください。
- Assistant
以下は、Node-REDのフローを表すインポート可能なJSONデータです。このフローは、HTTPリクエストノードを使用してshibe.online APIからデータを取得します。
────────────────────────────────────────────────────────────────────
jsonCopy code[{"id":"8c13b734.c27328","type":"http request","z":"effb3a84.95e608","name":"","method":"GET","ret":"txt","paytoqs":false,"url":,"tls":"","persist":false,"proxy":"","authType":"","x":310,"y":140,"wires":[["e832bd22.6ee538"]]},{"id":"e832bd22.6ee538","type":"json","z":"effb3a84.95e608","name":"","property":"payload","action":"","pretty":false,"x":490,"y":140,"wires":[["f0a90d4.201cfa"]]},{"id":"f0a90d4.201cfa","type":"debug","z":"effb3a84.95e608","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":140,"wires":[]},{"id":"a0e872a2.a33e18","type":"inject","z":"effb3a84.95e608","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":140,"wires":[["8c13b734.c27328"]]}]
- User
ありがとうございます!ではさらに、画像 URL のひとつを抽出して、ワークスペース上で画像を表示させてください。image-outputノードがイイです。
- Assistant
以下は、先ほどのフローに追加して画像を表示するためのimage-outputノードを含んだインポート可能なJSONデータです。
────────────────────────────────────────────────────────────────────
jsonCopy code[{"id":"8c13b734.c27328","type":"http request","z":"effb3a84.95e608","name":"","method":"GET","ret":"txt","paytoqs":false,"url":,"tls":"","persist":false,"proxy":"","authType":"","x":310,"y":140,"wires":[["e832bd22.6ee538"]]},{"id":"e832bd22.6ee538","type":"json","z":"effb3a84.95e608","name":"","property":"payload","action":"","pretty":false,"x":490,"y":140,"wires":[["f0a90d4.201cfa","6c02db71.04a77"]]},{"id":"f0a90d4.201cfa","type":"debug","z":"effb3a84.95e608","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":140,"wires":[]},{"id":"a0e872a2.a33e18","type":"inject","z":"effb3a84.95e608","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":140,"wires":[["8c13b734.c27328"]]},{"id":"6c02db71.04a77","type":"function","z":"effb3a84.95e608","name":"Extract Image URL","func":"msg.payload = msg.payload[0];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":220,"wires":[["bc12f24c.4e9e48"]]},{"id":"bc12f24c.4e9e48","type":"image","z":"effb3a84.95e608","name":"","width":"400","data":"payload","dataType":"msg","thumbnail":false,"active":true,"x":650,"y":220,"wires":[]}]