{"id":5916,"date":"2013-03-07T00:56:28","date_gmt":"2013-03-07T00:56:28","guid":{"rendered":"http:\/\/zerokidz.com\/ideas\/?p=5916"},"modified":"2014-11-10T01:14:03","modified_gmt":"2014-11-10T06:14:03","slug":"curl-examples","status":"publish","type":"post","link":"https:\/\/reactivemusic.net\/?p=5916","title":{"rendered":"curl examples"},"content":{"rendered":"<p>update 11\/02\/2014 &#8211; in process of updating and checking examples &#8211; but we know for sure that the Twitter examples are broken.<\/p>\n<h5>notes<\/h5>\n<p>This post is a collection of many examples of using curl (from a terminal command line) to make API requests. The ones marked with* will run without passwords or api-keys. The responses will generally be in XML, JSON, or HTML<\/p>\n<p>Some of these curl examples will have API keys, user names, and passwords. To run them, you&#8217;ll need to replace the keys with your own.<\/p>\n<p>Also, when running from the command line, ampersands &#8216;&amp;&#8217; will need to be escaped by preceding them with a backslash, like \\&amp;<\/p>\n<p>Other characters may need to be escaped, like:<\/p>\n<p>%23 = #<\/p>\n<p>%40 = @<\/p>\n<p>Or you can wrap the entire URL is quotes like this:<\/p>\n<pre>curl &quot;dict:\/\/dict.org\/d:penguin&quot;<\/pre>\n<h5>tips for finding curl examples<\/h5>\n<p>Look in the address bar of your web browser. Copy the entire URL and run it in curl. It will respond with the &#8216;text&#8217; version of the web page.<\/p>\n<h4>displaying JSON on the command line<\/h4>\n<p>The respond from curl is raw data. To format JSON data, pipe the output through python, like this:<\/p>\n<pre>curl dict:\/\/dict.org\/d:dog | python -mjson.tool<\/pre>\n<h4>examples:<\/h4>\n<h5>dict.org*<\/h5>\n<pre>curl dict:\/\/dict.org\/d:antelope<\/pre>\n<h5>Twitter search (broken)<\/h5>\n<p>Twtitter API now requires authentication and will not run from a single curl command, except by using widgets. See this post:\u00a0<a href=\"https:\/\/reactivemusic.net\/?p=17428\">https:\/\/reactivemusic.net\/?p=17428<\/a><\/p>\n<h5>openweathermap.com*<\/h5>\n<pre>curl http:\/\/api.openweathermap.org\/data\/2.1\/forecast\/city\/524901\r\n\r\n<\/pre>\n<p>See this post for details:\u00a0<a href=\"https:\/\/reactivemusic.net\/?p=6265\">https:\/\/reactivemusic.net\/?p=6265<\/a><\/p>\n<h5>vine.com*<\/h5>\n<pre>curl https:\/\/api.vineapp.com\/timelines\/popular<\/pre>\n<h5>mashape.com API<\/h5>\n<p>Here&#8217;s an example of a typical API call which gets the weather in San Francisco. Note I have obscured the API-key.<\/p>\n<pre>curl -H &quot;X-Mashape-Authorization: YOUR-MASHAPE-KEY&quot; &quot;https:\/\/george-vustrey-weather.p.mashape.com\/api.php?_method=getForecasts&amp;location=San%20Francisco&quot;<\/pre>\n<p>Here&#8217;s the result:<\/p>\n<pre>[{&quot;day_of_week&quot;:&quot;Wed&quot;,&quot;high&quot;:&quot;63&quot;,&quot;low&quot;:&quot;47&quot;,&quot;condition&quot;:&quot;Mostly Clear&quot;},{&quot;day_of_week&quot;:&quot;Thu&quot;,&quot;high&quot;:&quot;66&quot;,&quot;low&quot;:&quot;50&quot;,&quot;condition&quot;:&quot;Partly Cloudy&quot;}]<\/pre>\n<p>[Note] more examples in tkzic\/mashape<\/p>\n<h5>dictionaryapi.com<\/h5>\n<p>Here is an example of a request to the Thesaurus API<\/p>\n<pre>curl http:\/\/www.dictionaryapi.com\/api\/v1\/references\/thesaurus\/xml\/cheese?key=ee2466d2-07a0-40af-b959-abcdeb125f0ca<\/pre>\n<p>&nbsp;<\/p>\n<h5>*pandorabots.com<\/h5>\n<p>Here are two examples I just got to work using curl<\/p>\n<pre>curl -X POST  --data &quot;botid=b0dafd24ee35a477&amp;input=hello&quot; http:\/\/www.pandorabots.com\/pandora\/talk-xml\r\n\r\ncurl -X POST  --data &quot;botid=b0dafd24ee35a477&amp;input=Where are you?&quot; http:\/\/www.pandorabots.com\/pandora\/talk-xml<\/pre>\n<div>Here is the result for the second question<\/div>\n<div><\/div>\n<div>\n<pre>&lt;result status=&quot;0&quot; botid=&quot;b0dafd24ee35a477&quot; custid=&quot;b3422b612633ac87&quot;&gt;&lt;input&gt;Where are you?&lt;\/input&gt;&lt;that&gt;I am in the computer at Pandorabots.com.&lt;\/that&gt;&lt;\/result&gt;<\/pre>\n<\/div>\n<h5>*more pandorabots.com<\/h5>\n<pre class=\"brush: actionscript3; gutter: true\">curl -X POST  --data &quot;botid=b0dafd24ee35a477&amp;input=hello&quot; http:\/\/www.pandorabots.com\/pandora\/talk-xml\r\n\r\ncurl -X POST  --data &quot;botid=b0dafd24ee35a477&amp;input=Where are you?&quot; http:\/\/www.pandorabots.com\/pandora\/talk-xml\r\n\r\ncurl -X POST  --data &quot;botid=b0dafd24ee35a477&amp;input=Lets play some music today.&quot; http:\/\/www.pandorabots.com\/pandora\/talk-xml<\/pre>\n<h5>Google speech API (may be broken &#8211; need to check the key)<\/h5>\n<p>This is an example of the curl command to run from the command line<\/p>\n<p>the test.flac file is located in tkzic\/speech &#8211; it contains a recording of the phrase &#8220;there are turtles wandering through the city&#8221;. If you click on the file it will play through audacity.<\/p>\n<pre>curl \\\r\n  --data-binary @test.flac \\\r\n  --header &#039;Content-type: audio\/x-flac; rate=16000&#039; \\\r\n  &#039;https:\/\/www.google.com\/speech-api\/v1\/recognize?xjerr=1&amp;client=chromium&amp;pfilter=2&amp;lang=en-US&amp;maxresults=6&#039;<\/pre>\n<h5>cosm.com (may be broken)<\/h5>\n<p>Today I was finally able to get this working. Reading a Cosm (Pachube) feed from curl and from Max. Here is an example that works in curl: (replace API-KEY with actual key)<\/p>\n<pre>curl http:\/\/api.cosm.com\/v2\/feeds\/76490\/datastreams\/Power.xml?key=API-KEY<\/pre>\n<p>You can get JSON responses by leaving off the .xml extension or replacing it with .json<\/p>\n<p>Its critical to use &#8220;key=&#8230;&#8221; not &#8220;X-ApiKey=&#8230;&#8221; like in the cosm documentation, or you will get permission errors from curl and Max.<\/p>\n<h5>Youtube.com v3 API<\/h5>\n<p>Link to documentation:\u00a0<a href=\"https:\/\/developers.google.com\/youtube\/v3\/docs\/search\/list\">https:\/\/developers.google.com\/youtube\/v3\/docs\/search\/list<\/a><\/p>\n<p>Here is an example (minus the api-key) which searches for videos about cats and returns a JSON response<\/p>\n<pre>curl &quot;https:\/\/www.googleapis.com\/youtube\/v3\/search?key=API-KEY&amp;part=snippet&amp;q=cats&quot;<\/pre>\n<div>\n<h5>google.com custom search API<\/h5>\n<p>Use this method to have a custom search which searches the whole web&#8230;<\/p>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/4082966\/google-web-search-api-deprecated-what-now\">http:\/\/stackoverflow.com\/questions\/4082966\/google-web-search-api-deprecated-what-now<\/a><\/p>\n<p>Here is an example of a search using this method with curl &#8211; note the API-KEY is removed<\/p>\n<pre>curl &quot;https:\/\/www.googleapis.com\/customsearch\/v1?key=API-KEY&amp;cx=012117491442732664551:egvalbpelhq&amp;q=lectures&quot;<\/pre>\n<h5>Twitter streaming API (broken)<\/h5>\n<\/div>\n<h5>\u00a0google.com simple search API*<\/h5>\n<p>Not really applicable to curl, but it shows something.<\/p>\n<div>\n<pre class=\"brush: actionscript3; gutter: true\">curl -A Mozilla http:\/\/www.google.com\/search?q=linux<\/pre>\n<\/div>\n<h5>coastal wind data API (broken 11\/2014)<\/h5>\n<pre class=\"brush: actionscript3; gutter: true\">with a specific lat\/lon you can get results along the west coast of us - here&#039;s san francisco. This query returns all the current time points for SF\r\n\r\ncurl http:\/\/cordc.ucsd.edu\/js\/COAMPS\/query.php?ll=37.78,-122.44\\&amp;fmt=json &gt; sf.json \r\n\r\nlets try for santa cruz\r\n\r\ncurl http:\/\/cordc.ucsd.edu\/js\/COAMPS\/query.php?ll=36.99,-122.03\\&amp;fmt=json &gt; sc.json<\/pre>\n<p>&nbsp;<\/p>\n<h5>spellout.org API*<\/h5>\n<pre class=\"brush: actionscript3; gutter: true\">very cool api that does phonetic spellings - works!!!!\r\n\r\ncurl http:\/\/api.spellout.org\/en\/convert?text=some%20text\\&amp;alphabet=int-icao\\&amp;format=json<\/pre>\n<h5>cosm.com API (PUT request)<\/h5>\n<pre class=\"brush: actionscript3; gutter: true\">This works as of 1\/28\/2013\r\n\r\ncurl -v --request PUT --data-binary @.\/abc.json --header &quot;X-ApiKey: 96PqSh4rj7HzNif3rWms3SUhwaDFGUT0g&quot; http:\/\/api.cosm.com\/v2\/feeds\/98281.json<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>update 11\/02\/2014 &#8211; in process of updating and checking examples &#8211; but we know for sure that the Twitter examples are broken. notes This post is a collection of many examples of using curl (from a terminal command line) to make API requests. The ones marked with* will run without passwords or api-keys. The responses &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/reactivemusic.net\/?p=5916\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;curl examples&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[143],"tags":[161,170,190,12],"class_list":["post-5916","post","type-post","status-publish","format-standard","hentry","category-interactive-media-art","tag-api","tag-curl","tag-portfolio","tag-web-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>curl examples - reactive music<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/reactivemusic.net\/?p=5916\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"curl examples - reactive music\" \/>\n<meta property=\"og:description\" content=\"update 11\/02\/2014 &#8211; in process of updating and checking examples &#8211; but we know for sure that the Twitter examples are broken. notes This post is a collection of many examples of using curl (from a terminal command line) to make API requests. The ones marked with* will run without passwords or api-keys. The responses &hellip; Continue reading &quot;curl examples&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/reactivemusic.net\/?p=5916\" \/>\n<meta property=\"og:site_name\" content=\"reactive music\" \/>\n<meta property=\"article:published_time\" content=\"2013-03-07T00:56:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-10T06:14:03+00:00\" \/>\n<meta name=\"author\" content=\"Tom Zicarelli\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tom Zicarelli\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=5916#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=5916\"},\"author\":{\"name\":\"Tom Zicarelli\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\"},\"headline\":\"curl examples\",\"datePublished\":\"2013-03-07T00:56:28+00:00\",\"dateModified\":\"2014-11-10T06:14:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=5916\"},\"wordCount\":550,\"keywords\":[\"API\",\"curl\",\"portfolio\",\"web development\"],\"articleSection\":[\"interactive media art\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=5916\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/?p=5916\",\"name\":\"curl examples - reactive music\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#website\"},\"datePublished\":\"2013-03-07T00:56:28+00:00\",\"dateModified\":\"2014-11-10T06:14:03+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=5916#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/reactivemusic.net\\\/?p=5916\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=5916#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/reactivemusic.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"curl examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#website\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/\",\"name\":\"reactive music\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/reactivemusic.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\",\"name\":\"Tom Zicarelli\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"caption\":\"Tom Zicarelli\"},\"sameAs\":[\"http:\\\/\\\/tomzicarelli.com\"],\"url\":\"https:\\\/\\\/reactivemusic.net\\\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"curl examples - reactive music","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/reactivemusic.net\/?p=5916","og_locale":"en_US","og_type":"article","og_title":"curl examples - reactive music","og_description":"update 11\/02\/2014 &#8211; in process of updating and checking examples &#8211; but we know for sure that the Twitter examples are broken. notes This post is a collection of many examples of using curl (from a terminal command line) to make API requests. The ones marked with* will run without passwords or api-keys. The responses &hellip; Continue reading \"curl examples\"","og_url":"https:\/\/reactivemusic.net\/?p=5916","og_site_name":"reactive music","article_published_time":"2013-03-07T00:56:28+00:00","article_modified_time":"2014-11-10T06:14:03+00:00","author":"Tom Zicarelli","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tom Zicarelli","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/reactivemusic.net\/?p=5916#article","isPartOf":{"@id":"https:\/\/reactivemusic.net\/?p=5916"},"author":{"name":"Tom Zicarelli","@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571"},"headline":"curl examples","datePublished":"2013-03-07T00:56:28+00:00","dateModified":"2014-11-10T06:14:03+00:00","mainEntityOfPage":{"@id":"https:\/\/reactivemusic.net\/?p=5916"},"wordCount":550,"keywords":["API","curl","portfolio","web development"],"articleSection":["interactive media art"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/reactivemusic.net\/?p=5916","url":"https:\/\/reactivemusic.net\/?p=5916","name":"curl examples - reactive music","isPartOf":{"@id":"https:\/\/reactivemusic.net\/#website"},"datePublished":"2013-03-07T00:56:28+00:00","dateModified":"2014-11-10T06:14:03+00:00","author":{"@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571"},"breadcrumb":{"@id":"https:\/\/reactivemusic.net\/?p=5916#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/reactivemusic.net\/?p=5916"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/reactivemusic.net\/?p=5916#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/reactivemusic.net\/"},{"@type":"ListItem","position":2,"name":"curl examples"}]},{"@type":"WebSite","@id":"https:\/\/reactivemusic.net\/#website","url":"https:\/\/reactivemusic.net\/","name":"reactive music","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/reactivemusic.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571","name":"Tom Zicarelli","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","caption":"Tom Zicarelli"},"sameAs":["http:\/\/tomzicarelli.com"],"url":"https:\/\/reactivemusic.net\/?author=2"}]}},"_links":{"self":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/5916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5916"}],"version-history":[{"count":29,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/5916\/revisions"}],"predecessor-version":[{"id":17516,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/5916\/revisions\/17516"}],"wp:attachment":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}