{"id":1908,"date":"2020-07-14T10:27:00","date_gmt":"2020-07-14T09:27:00","guid":{"rendered":"https:\/\/matthewolden.co.uk\/?p=1908"},"modified":"2023-07-14T10:30:14","modified_gmt":"2023-07-14T09:30:14","slug":"web-api-data-to-pure-data-via-python-as-programmed-by-chatgpt","status":"publish","type":"post","link":"https:\/\/matthewolden.co.uk\/?p=1908","title":{"rendered":"Web API data to Pure Data Via Python as programmed by ChatGPT"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Here is a method of getting data from a web API , into Pure Data, so the data can be used to control audio.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The API used here is open weather<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/openweathermap.org\/\">https:\/\/openweathermap.org\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">first off heres the conversation i had with the big brain&#8230;..<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">it got the program straight off with this prompt, tho i didn&#8217;t specify to osc to output the data, but it used anyway (probably as i have used it before). I have also specified before that the program outputs in text whats it is doing whilst running, so thats why it prints comments when it does something (handy for bug finding). I didnt even spell the prompt right!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/BLUDGED-TOETHER-497x1024.jpg\" alt=\"\" class=\"wp-image-1909\" width=\"865\" height=\"1782\" srcset=\"https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/BLUDGED-TOETHER-497x1024.jpg 497w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/BLUDGED-TOETHER-146x300.jpg 146w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/BLUDGED-TOETHER-768x1582.jpg 768w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/BLUDGED-TOETHER-746x1536.jpg 746w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/BLUDGED-TOETHER-994x2048.jpg 994w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/BLUDGED-TOETHER-700x1442.jpg 700w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/BLUDGED-TOETHER-332x684.jpg 332w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/BLUDGED-TOETHER.jpg 1089w\" sizes=\"auto, (max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">chat gpt also explains the code, and lets me know where to put in my API key and location of the city i want the data for.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">i then take this code and run it in <a href=\"https:\/\/realpython.com\/python-idle\/\">IDLE<\/a> (a python code compiler) and make a very quick and simple patch in Pure Data to open an OSC channel localy on port 9000, and to route out the messages for temperature, hummidity and weather description.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">heres the code<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">the python code<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-03dd4591-f643-4cea-96ff-0bacf287cb2d\" href=\"https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/weaktherscricpt.py_.zip\">weaktherscricpt.py_<\/a><a href=\"https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/weaktherscricpt.py_.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-03dd4591-f643-4cea-96ff-0bacf287cb2d\">Download<\/a><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">the pure data code<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-a269f215-ad76-49d0-8c53-eebf9ee65171\" href=\"https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/api.pd_.zip\">api.pd_<\/a><a href=\"https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/api.pd_.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-a269f215-ad76-49d0-8c53-eebf9ee65171\">Download<\/a><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">and it works!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"974\" src=\"https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/api-to-python-to-osc-1024x974.jpg\" alt=\"\" class=\"wp-image-1910\" srcset=\"https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/api-to-python-to-osc-1024x974.jpg 1024w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/api-to-python-to-osc-300x285.jpg 300w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/api-to-python-to-osc-768x731.jpg 768w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/api-to-python-to-osc-1536x1461.jpg 1536w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/api-to-python-to-osc-2048x1948.jpg 2048w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/api-to-python-to-osc-700x666.jpg 700w, https:\/\/matthewolden.co.uk\/wp-content\/uploads\/2023\/07\/api-to-python-to-osc-332x316.jpg 332w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Here is a method of getting data from a web API , into Pure Data, so the data can be used to control audio. The API used here is open weather https:\/\/openweathermap.org\/ first off heres the conversation i had with the big brain&#8230;.. it got the program straight off with &#8230;<\/p>\n","protected":false},"author":2,"featured_media":1913,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74,80,6],"tags":[],"class_list":["post-1908","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-camp-links","category-pd-on-a-pi","column","fourcol","has-thumbnail"],"_links":{"self":[{"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1908"}],"version-history":[{"count":1,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1908\/revisions"}],"predecessor-version":[{"id":1914,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1908\/revisions\/1914"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/media\/1913"}],"wp:attachment":[{"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}