{"id":159888,"date":"2024-07-11T12:41:22","date_gmt":"2024-07-11T12:41:22","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=159888"},"modified":"2024-07-11T12:58:57","modified_gmt":"2024-07-11T12:58:57","slug":"raspberry-pi-pico-w-http-requests-micropython","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-http-requests-micropython\/","title":{"rendered":"Raspberry Pi Pico W: Getting Started with HTTP GET Requests (MicroPython)"},"content":{"rendered":"\n<p>This tutorial is a getting started guide to HTTP GET requests with the Raspberry Pi Pico W. HTTP Requests are fundamental to interact with web services to retrieve data from external sources, integrate with web APIs to access third-party services, and much more.<\/p>\n\n\n\n<p>In this guide, you&#8217;ll learn the basic concepts of HTTP GET requests and test some simple examples to get data from the internet.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-HTTP-GET-Requests-MicroPython.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico W Getting Started with HTTP GET Requests MicroPython\" class=\"wp-image-159935\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-HTTP-GET-Requests-MicroPython.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-HTTP-GET-Requests-MicroPython.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-HTTP-GET-Requests-MicroPython.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-HTTP-GET-Requests-MicroPython.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-HTTP-GET-Requests-MicroPython.jpg?resize=1536%2C864&amp;quality=100&amp;strip=all&amp;ssl=1 1536w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p>When it comes to IoT projects, HTTP requests are fundamental to interact with web services to retrieve data from external sources, integrate with Web APIs to access web services, or even remote control your Pico using external third-party platforms.<\/p>\n\n\n\n<p class=\"rntbox rntclgreen\"><strong>New to the Raspberry Pi Pico?<\/strong>&nbsp;Read the following guide:&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/getting-started-raspberry-pi-pico-w\/\">Getting Started with Raspberry Pi Pico (and Pico W)<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<p>Throughout this tutorial, we&#8217;ll cover the following topics.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#http-requests-intro\" title=\"\">What are HTTP Requests?<\/a><\/li>\n\n\n\n<li><a href=\"#http-requests-technical-overview\" title=\"\">Technical Overview of HTTP Requests<\/a><\/li>\n\n\n\n<li><a href=\"#http-requests-technical-overview\" title=\"\">Technical Overview of HTTP Requests<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#http-requests\" title=\"\">HTTP Requests<\/a><\/li>\n\n\n\n<li><a href=\"#http-request-methods\" title=\"\">HTTP Request Methods<\/a><\/li>\n\n\n\n<li><a href=\"#http-status-codes\" title=\"\">HTTP Status Codes<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#http-requests-raspberry-pi-pico\" title=\"\">HTTP Requests with the Raspberry Pi Pico<\/a><\/li>\n\n\n\n<li><a href=\"#get-data-from-web\" title=\"\">Getting Data from the Web Using HTTP GET Requests<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#weather-forecaster\" title=\"\">Example 1: Weather Forecaster<\/a><\/li>\n\n\n\n<li><a href=\"#bitcoin-ticker\" title=\"\">Example 2: Current Bitcoin Price<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before proceeding, make sure you check the following prerequisites:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">MicroPython Firmware<\/h3>\n\n\n\n<p>To follow this tutorial you need MicroPython firmware installed in your Raspberry Pi Pico board. You also need an IDE to write and upload the code to your board.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"250\" height=\"250\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/micropython-logo.png?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1\" alt=\"micorpython logo\" class=\"wp-image-148797\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/micropython-logo.png?w=250&amp;quality=100&amp;strip=all&amp;ssl=1 250w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/micropython-logo.png?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/figure><\/div>\n\n\n<p>The recommended MicroPython IDE for the Raspberry Pi Pico is Thonny IDE. Follow the next tutorial to learn how to install Thonny IDE, flash MicroPython firmware, and upload code to the board.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/getting-started-raspberry-pi-pico-w\/#install-thonny-ide\">Programming Raspberry Pi Pico using MicroPython<\/a><\/li>\n<\/ul>\n\n\n\n<p>Alternatively, if you like programming using VS Code, you can start with the following tutorial:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-vs-code-micropython\/\">Programming Raspberry Pi Pico with VS Code and MicroPython<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"http-requests-intro\">What are HTTP Requests?<\/h2>\n\n\n\n<p>The most common way to exchange data with another computer (server) on the internet is using the HTTP protocol.<\/p>\n\n\n\n<p>HTTP (Hypertext Transfer Protocol) works through a client-server model. In this model, the client communicates with a server using HTTP requests. An HTTP request is a message sent by the client to a server, typically to request a specific action or retrieve information. The server sends a response back to the client also through HTTP.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"365\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-HTTP-GET-Request.png?resize=750%2C365&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico HTTP GET Request\" class=\"wp-image-159894\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-HTTP-GET-Request.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-HTTP-GET-Request.png?resize=300%2C146&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Client:<\/strong> initiates communication through a request.<\/li>\n\n\n\n<li><strong>Server:<\/strong> receives and processes the request and sends a response in return.<\/li>\n<\/ul>\n\n\n\n<p>The Raspberry Pi Pico can either be a client or a server. When it is a client, it sends requests to servers. When it is a <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-web-server-micropython\/\" title=\"\">server<\/a>, it handles the client\u2019s requests. <\/p>\n\n\n\n<p class=\"rntbox rntclgreen\">Related content: <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-web-server-micropython\/\">Raspberry Pi Pico: Web Server (MicroPython)<\/a><\/p>\n\n\n\n<p>In this tutorial, we\u2019ll take a look at the <strong>Raspberry Pi Pico as an HTTP client<\/strong>.<\/p>\n\n\n\n<p>Here are some examples of what you can do using HTTP requests with the Pico:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Get data from the internet: for example, time, current weather, stock prices, traffic updates, and much more\u2026<\/li>\n\n\n\n<li>Datalogging: send data to the cloud to save your data online;<\/li>\n\n\n\n<li>Remote control of your Raspberry Pi Pico: by interacting with IoT platforms like Adafruit IO, Node-RED, and others\u2014you can interact with your board remotely by exchanging data via HTTP requests;<\/li>\n\n\n\n<li>Interact with third-party services to send notifications: SMS, emails, notifications, and much more\u2026<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"http-requests-technical-overview\">Technical Overview of HTTP Requests<\/h2>\n\n\n\n<p>Let\u2019s take a quick look at the technical aspects of HTTP requests. If this is your first time dealing with HTTP requests in a technical manner and it seems confusing, that\u2019s perfectly normal. <\/p>\n\n\n\n<p>But, don\u2019t worry, there are MicroPython modules that abstract all the technical stuff, making it very straightforward to make and handle HTTP requests. Additionally, for more information about the technical aspects of HTTP requests, we recommend the following resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.realisable.co.uk\/support\/documentation\/iman-user-guide\/DataConcepts\/WebRequestAnatomy.htm\" target=\"_blank\" rel=\"noopener\" title=\"\">Anatomy of an http request &amp; response<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.ibm.com\/docs\/en\/cics-ts\/5.3?topic=concepts-http-protocol\" target=\"_blank\" rel=\"noopener\" title=\"\">The HTTP Protocol (documentation by IBM)<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"http-requests\">HTTP Requests&nbsp;&nbsp;&nbsp;<\/h3>\n\n\n\n<p>HTTP request consists of several parts. The main elements are: request line, headers, and body.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Request Line<\/h4>\n\n\n\n<p>The request line specifies the HTTP method, the resource being requested (the URL), and the version of the HTTP protocol being used. Common HTTP methods include GET, POST, PUT, and DELETE. For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">GET \/path\/to\/resource HTTP\/1.1<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Headers<\/h4>\n\n\n\n<p>Headers provide information about the request. It can include the host to which the client is sending the request, the type of content being sent or accepted, the user\u2011agent (identifies the client making the request), and more. For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Host: example.com<br>User-Agent: RaspberryPiPico<br>Accept: application\/json<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Body<\/h4>\n\n\n\n<p>The body is an optional content, and it contains data or information that we want to send to the server. This is used in POST and PUT requests. For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">POST \/submit-form HTTP\/1.1<br>Content-Type: application\/x-www-form-urlencoded<br>username=johndoe&amp;password=secretpassword<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"http-request-methods\">HTTP Request Methods<\/h3>\n\n\n\n<p>The choice of HTTP method in a request indicates the intended action to be performed on the server. Some commonly used methods include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>GET:<\/strong> retrieve data from the server.<\/li>\n\n\n\n<li><strong>POST:<\/strong> submit data to be processed to a specified resource.<\/li>\n\n\n\n<li><strong>PUT:<\/strong> update a resource on the server.<\/li>\n\n\n\n<li><strong>DELETE<\/strong>: remove a resource from the server.<\/li>\n<\/ul>\n\n\n\n<p>In this tutorial, we&#8217;ll focus on using GET requests with the Raspberry Pi Pico.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"http-status-codes\">HTTP Status Codes<\/h3>\n\n\n\n<p>After receiving an HTTP request, the server responds with an HTTP status code indicating the outcome of the request. Status codes fall into categories such as 2xx (successful), 3xx (redirection), 4xx (client error), and 5xx (server error). Some of the most common:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>200 OK:<\/strong> the request was successful.<\/li>\n\n\n\n<li><strong>404 Not Found:<\/strong> the requested resource could not be found.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"http-requests-raspberry-pi-pico\">HTTP Requests with the Raspberry Pi Pico<\/h2>\n\n\n\n<p>The easiest way to make HTTP requests with the Raspberry Pi Pico is by using the <span class=\"rnthl rntliteral\">requests<\/span> library, which uses a high-level approach. This is very similar to the <em>Python<\/em> <span class=\"rnthl rntliteral\">requests<\/span> library but is more limited.<\/p>\n\n\n\n<p>You can also use the <span class=\"rnthl rntliteral\">socket<\/span> module, but it\u2019s a more low-level approach and is not so beginner-friendly.<\/p>\n\n\n\n<p>The following code is a basic example of how you can make a simple HTTP request to Google Website using the <span class=\"rnthl rntliteral\">requests<\/span> library.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Rui Santos &amp; Sara Santos - Random Nerd Tutorials\r\n# Complete project details: https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-w-http-requests-micropython\/\r\n \r\nimport network\r\nimport requests\r\n\r\n# Wi-Fi credentials\r\nssid = 'REPLACE_WITH_YOUR_SSID'\r\npassword = 'REPLACE_WITH_YOUR_PASSWORD'\r\n\r\n# Connect to network\r\nwlan = network.WLAN(network.STA_IF)\r\nwlan.active(True)\r\n\r\n# Connect to your network\r\nwlan.connect(ssid, password)\r\n\r\n# Make GET request\r\nresponse = requests.get(&quot;http:\/\/www.google.com&quot;)\r\n# Get response code\r\nresponse_code = response.status_code\r\n# Get response content\r\nresponse_content = response.content\r\n\r\n# Print results\r\nprint('Response code: ', response_code)\r\nprint('Response content:', response_content)<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Raspberry-Pi-Pico\/MicroPython\/HTTP_Request_Basic.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the Code Works<\/h3>\n\n\n\n<p>Start by including the <span class=\"rnthl rntliteral\">network<\/span> and the <span class=\"rnthl rntliteral\">requests<\/span> library.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>import network\nimport requests<\/code><\/pre>\n\n\n\n<p>Replace &#8216;<span class=\"rnthl rntliteral\">REPLACE_WITH_YOUR_SSID<\/span>&#8216; and &#8216;<span class=\"rnthl rntliteral\">REPLACE_WITH_YOUR_PASSWORD<\/span>&#8216; with your Wi-Fi network name (SSID) and password.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>ssid = 'REPLACE_WITH_YOUR_SSID'\npassword = 'REPLACE_WITH_YOUR_PASSWORD'<\/code><\/pre>\n\n\n\n<p>Then, initialize the Wi-Fi interface, activate it, and connect to your network using the SSID and password defined earlier.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code># Connect to network\nwlan = network.WLAN(network.STA_IF)\nwlan.active(True)\n# Connect to your network\nwlan.connect(ssid, password)<\/code><\/pre>\n\n\n\n<p>Finally, make the request. Using the <span class=\"rnthl rntliteral\">requests<\/span> module and the <span class=\"rnthl rntliteral\">get()<\/span> method, the code sends a GET request to the Google website. The response from the server is stored in the <span class=\"rnthl rntliteral\">response<\/span> variable.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>response = requests.get(\"http:\/\/www.google.com\")<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">response<\/span> is an object of type <span class=\"rnthl rntliteral\">Response<\/span>. This object has several attributes that you can access and might be useful. For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">response.status_code<\/span>: returns an integer value representing the status of the response;<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">response.content<\/span>: returns the actual content in bytes;<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">response.text<\/span>: returns the content converted to a string, using a character encoding such as UTF-8;<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">response.json()<\/span>: returns the response as a JSON object (dictionary);<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">response.headers()<\/span>: access information about the response\u2019s headers.<\/li>\n<\/ul>\n\n\n\n<p>After getting the response, we get the status of the response using the <span class=\"rnthl rntliteral\">status_code<\/span> attribute.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>response_code = response.status_code<\/code><\/pre>\n\n\n\n<p>We save the content of the response in the <span class=\"rnthl rntliteral\">response_content<\/span> variable using the <span class=\"rnthl rntliteral\">content<\/span> attribute.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>response_content = response.content<\/code><\/pre>\n\n\n\n<p>Finally, we print the status code and request content to the Shell.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>print('Response code: ', response_code)\nprint('Response content:', response_content)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Testing the Code<\/h3>\n\n\n\n<p>After inserting your network credentials, you can run the previous code on your Raspberry Pi Pico.<\/p>\n\n\n\n<p>If everything goes as expected, the response code should be 200, and it will print the content of the Google web page.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"765\" height=\"250\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/RPi-Pico-HTTP-GET-Request-Google-Response.png?resize=765%2C250&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Google HTTP GET Request\" class=\"wp-image-159897\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/RPi-Pico-HTTP-GET-Request-Google-Response.png?w=765&amp;quality=100&amp;strip=all&amp;ssl=1 765w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/RPi-Pico-HTTP-GET-Request-Google-Response.png?resize=300%2C98&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 765px) 100vw, 765px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"get-data-from-web\">Getting Data from the Web Using HTTP GET Requests<\/h2>\n\n\n\n<p>Now that you know how to make a basic HTTP GET request, we&#8217;ll show you different examples to get data from the internet. We&#8217;ll build two different examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#weather-forecaster\" title=\"\">Example 1: Weather Forecaster<\/a><\/li>\n\n\n\n<li><a href=\"#bitcoin-ticker\" title=\"\">Example 2: Current Bitcoin Price<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"weather-forecaster\">Example 1: Weather Forecaster<\/h3>\n\n\n\n<p>In this example, we\u2019ll use the <a href=\"https:\/\/www.weatherapi.com\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Weather API <\/a>to create a weather forecaster. This API is free and provides useful information about the weather in almost any location in the world.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"350\" height=\"108\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/weather-forecaster.jpg?resize=350%2C108&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Weather forecaster example\" class=\"wp-image-159901\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/weather-forecaster.jpg?w=350&amp;quality=100&amp;strip=all&amp;ssl=1 350w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/weather-forecaster.jpg?resize=300%2C93&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 350px) 100vw, 350px\" \/><\/figure><\/div>\n\n\n<p>We\u2019ll get the weather data for your location and display it on the shell.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Getting Your API Key<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to the Weather API website: <a href=\"https:\/\/www.weatherapi.com\/\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/www.weatherapi.com\/<\/a><\/li>\n\n\n\n<li>Signup to create an account.<\/li>\n\n\n\n<li>After verifying your account, login into your account.<\/li>\n\n\n\n<li>On your dashboard at <a href=\"https:\/\/www.weatherapi.com\/my\/\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/www.weatherapi.com\/my\/<\/a> , you\u2019ll find your API key (even though it says the trial will end, you can continue using your API key freely).<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"884\" height=\"247\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/weather-api-key.png?resize=884%2C247&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Weather API Key\" class=\"wp-image-159899\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/weather-api-key.png?w=884&amp;quality=100&amp;strip=all&amp;ssl=1 884w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/weather-api-key.png?resize=300%2C84&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/weather-api-key.png?resize=768%2C215&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 884px) 100vw, 884px\" \/><\/figure><\/div>\n\n\n<p>Copy the API key to a safe place because you\u2019ll need it later.<\/p>\n\n\n\n<p>To pull information on the weather in your chosen location, enter the following URL on your web browser, but inserting your location and API key on the right places:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/api.weatherapi.com\/v1\/current.json?q=<strong>YOUR_LOCATION<\/strong>+&amp;key=<strong>YOUR_API_KEY<\/strong>'<\/pre>\n\n\n\n<p>For example, in my case:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;api.weatherapi.com\/v1\/current.json?q=Oporto+&amp;key=d1578a064b07453c917164350240106'<\/code><\/pre>\n\n\n\n<p>Copy your URL and paste it into your browser, and the API will return information corresponding to your local weather. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>{\n  \"location\": {\n    \"name\": \"Oporto\",\n    \"region\": \"Porto\",\n    \"country\": \"Portugal\",\n    \"lat\": 41.15,\n    \"lon\": -8.62,\n    \"tz_id\": \"Europe\/Lisbon\",\n    \"localtime_epoch\": 1719843562,\n    \"localtime\": \"2024-07-01 15:19\"\n  },\n  \"current\": {\n    \"last_updated_epoch\": 1719843300,\n    \"last_updated\": \"2024-07-01 15:15\",\n    \"temp_c\": 22.3,\n    \"temp_f\": 72.1,\n    \"is_day\": 1,\n    \"condition\": {\n      \"text\": \"Sunny\",\n      \"icon\": \"\/\/cdn.weatherapi.com\/weather\/64x64\/day\/113.png\",\n      \"code\": 1000\n    },\n    \"wind_mph\": 10.5,\n    \"wind_kph\": 16.9,\n    \"wind_degree\": 310,\n    \"wind_dir\": \"NW\",\n    \"pressure_mb\": 1021,\n    \"pressure_in\": 30.15,\n    \"precip_mm\": 0,\n    \"precip_in\": 0,\n    \"humidity\": 69,\n    \"cloud\": 0,\n    \"feelslike_c\": 24.7,\n    \"feelslike_f\": 76.4,\n    \"windchill_c\": 21.9,\n    \"windchill_f\": 71.5,\n    \"heatindex_c\": 24.6,\n    \"heatindex_f\": 76.2,\n    \"dewpoint_c\": 15,\n    \"dewpoint_f\": 58.9,\n    \"vis_km\": 10,\n    \"vis_miles\": 6,\n    \"uv\": 6,\n    \"gust_mph\": 15.4,\n    \"gust_kph\": 24.7\n  }\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Code \u2013 HTTP GET Request: Weather API<\/h4>\n\n\n\n<p>The following code makes a request to the Weather API to get weather data on your location. Then, we display the data on the shell. We&#8217;ll display information about the current weather, temperature, humidity, and rain.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Rui Santos &amp; Sara Santos - Random Nerd Tutorials\r\n# Complete project details: https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-w-http-requests-micropython\/\r\n\r\nimport network\r\nimport time\r\nimport requests\r\n\r\n# Wi-Fi credentials\r\nssid = 'REPLACE_WITH_YOUR_SSID'\r\npassword = 'REPLACE_WITH_YOUR_PASSWORD'\r\n\r\napi_key = 'REPLACE_WITH_YOUR_API_KEY'\r\nlocation ='Oporto'\r\n\r\n# Request URL\r\nurl = f'https:\/\/api.weatherapi.com\/v1\/current.json?q={location}+&amp;key={api_key}'\r\n\r\ndef init_wifi(ssid, password):# Init Wi-Fi Interface\r\n    wlan = network.WLAN(network.STA_IF)\r\n    wlan.active(True)\r\n    # Connect to your network\r\n    wlan.connect(ssid, password)\r\n    # Wait for Wi-Fi connection\r\n    connection_timeout = 10\r\n    while connection_timeout &gt; 0:\r\n        if wlan.status() &gt;= 3:\r\n            break\r\n        connection_timeout -= 1\r\n        print('Waiting for Wi-Fi connection...')\r\n        time.sleep(1)\r\n    # Check if connection is successful\r\n    if wlan.status() != 3:\r\n        return False\r\n    else:\r\n        print('Connection successful!')\r\n        network_info = wlan.ifconfig()\r\n        print('IP address:', network_info[0])\r\n        return True\r\n\r\nif init_wifi(ssid, password):\r\n    try:\r\n        # Make the request\r\n        response = requests.get(url)\r\n        #Print the response code\r\n        print('Response code: ', response.status_code)\r\n        \r\n        # Get response content\r\n        weather = response.json()\r\n        # Close the request\r\n        response.close()\r\n        \r\n        # Print bulk weather data\r\n        print('Weather JSON: ', weather)\r\n        \r\n        # Get specific weather data\r\n        weather_description = weather['current']['condition']['text']\r\n        print('Current weather: ', weather_description)\r\n        \r\n        # Temperature and humidity\r\n        temperature_c = weather['current']['temp_c']\r\n        temperature_f = weather['current']['temp_f']\r\n        humidity = weather['current']['humidity']\r\n        print(f'Temperature in Celsius: {temperature_c:.2f}')\r\n        print(f'Temperature in Fahrenheit: {temperature_f:.2f}')\r\n        print(f'Humidity (%): {humidity:.2f}')              \r\n        \r\n        # Precipitation\r\n        precipitation = weather['current']['precip_mm']\r\n        print(f'Precipitation in mm: {precipitation}')              \r\n        \r\n        # Wind\r\n        wind_speed = weather['current']['wind_kph']\r\n        print('Wind speed in kph:', wind_speed)\r\n\r\n    except Exception as e:\r\n        # Handle any exceptions during the request\r\n        print('Error during request:', e)\r\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Raspberry-Pi-Pico\/MicroPython\/HTTP_Request_Get_Weather.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">How the Code Works<\/h4>\n\n\n\n<p>Let&#8217;s take a quick look at how this code works.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">To make the code work, first, you need to insert your network credentials to connect your Raspberry Pi Pico to the internet.<\/h5>\n\n\n\n<pre class=\"wp-block-code language-python\"><code># Wi-Fi credentials\nssid = 'REPLACE_WITH_YOUR_SSID'\npassword = 'REPLACE_WITH_YOUR_PASSWORD'<\/code><\/pre>\n\n\n\n<p>Then, insert your Weather API key, and the city from where you want to get the data.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>api_key = 'REPLACE_WITH_YOUR_API_KEY'\ncity = 'REPLACE_WITH_YOUR_CITY'<\/code><\/pre>\n\n\n\n<p>We save the request URL on the <span class=\"rnthl rntliteral\">url<\/span> variable. This is an f string with placeholders so that the URL is updated with your details at run time.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>url = f'https:\/\/api.weatherapi.com\/v1\/current.json?q={location}+&amp;key={api_key}'<\/code><\/pre>\n\n\n\n<p>We create a function called <span class=\"rnthl rntliteral\">init_wifi()<\/span> that connects to your local network. This function returns <span class=\"rnthl rntliteral\">True<\/span> if connecting to Wi-Fi was successful or <span class=\"rnthl rntliteral\">False<\/span>, if it wasn\u2019t.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def init_wifi(ssid, password):\n&nbsp; &nbsp; wlan = network.WLAN(network.STA_IF)\n&nbsp; &nbsp; wlan.active(True)\n&nbsp; &nbsp; # Connect to your network\n&nbsp; &nbsp; wlan.connect(ssid, password)\n&nbsp; &nbsp; # Wait for Wi-Fi connection\n&nbsp; &nbsp; connection_timeout = 10\n&nbsp; &nbsp; while connection_timeout &gt; 0:\n&nbsp; &nbsp; &nbsp; &nbsp; if wlan.status() &gt;= 3:\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break\n&nbsp; &nbsp; &nbsp; &nbsp; connection_timeout -= 1\n&nbsp; &nbsp; &nbsp; &nbsp; print('Waiting for Wi-Fi connection...')\n&nbsp; &nbsp; &nbsp; &nbsp; time.sleep(1)\n&nbsp; &nbsp; # Check if connection is successful\n&nbsp; &nbsp; if wlan.status() != 3:\n&nbsp; &nbsp; &nbsp; &nbsp; return False\n&nbsp; &nbsp; else:\n&nbsp; &nbsp; &nbsp; &nbsp; print('Connection successful!')\n&nbsp; &nbsp; &nbsp; &nbsp; network_info = wlan.ifconfig()\n&nbsp; &nbsp; &nbsp; &nbsp; print('IP address:', network_info&#091;0])\n&nbsp; &nbsp; &nbsp; &nbsp; return True<\/code><\/pre>\n\n\n\n<p>Then, we connect to Wi-Fi and check if we succeed before making the request.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>if init_wifi(ssid, password):<\/code><\/pre>\n\n\n\n<p>Making the request is as simple as using the <span class=\"rnthl rntliteral\">get()<\/span> method of the <span class=\"rnthl rntliteral\">requests<\/span> module and passing the URL as an argument.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>response = requests.get(url)<\/code><\/pre>\n\n\n\n<p>This will return a JSON object. So, we can convert the result into a Python dictionary using the <span class=\"rnthl rntliteral\">json()<\/span> method.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>weather = response.json()<\/code><\/pre>\n\n\n\n<p>Then, we close the connection to release any resources.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code># Close the request\nresponse.close()<\/code><\/pre>\n\n\n\n<p>Now, we have all the data you\u2019ve seen on your web browser on the previous steps saved on the <span class=\"rnthl rntliteral\">weather<\/span> variable.<\/p>\n\n\n\n<p>You access specific information by using the keys of the data you want to get. We get weather description, temperature, humidity, precipitation and wind speed. You can also get other properties by accessing the corresponding keys on the JSON object.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code># Get specific weather data\nweather_description = weather&#091;'current']&#091;'condition']&#091;'text']\nprint('Current weather: ', weather_description)\n        \n# Temperature and humidity\ntemperature_c = weather&#091;'current']&#091;'temp_c']\ntemperature_f = weather&#091;'current']&#091;'temp_f']\nhumidity = weather&#091;'current']&#091;'humidity']\nprint(f'Temperature in Celsius: {temperature_c:.2f}')\nprint(f'Temperature in Fahrenheit: {temperature_f:.2f}')\nprint(f'Humidity (%): {humidity:.2f}')              \n        \n# Precipitation\nprecipitation = weather&#091;'current']&#091;'precip_mm']\nprint(f'Precipitation in mm: {precipitation}')              \n        \n# Wind\nwind_speed = weather&#091;'current']&#091;'wind_kph']\nprint('Wind speed in kph:', wind_speed)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Testing the Code<\/h4>\n\n\n\n<p>After inserting your network credentials, API key and city, you can run the code on your Raspberry Pi Pico.<\/p>\n\n\n\n<p>You should get something similar to in the screenshot below but with the information for your chosen location.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"795\" height=\"465\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/get-weather-data-raspberry-pi-pico-weather-api.png?resize=795%2C465&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Getting Weather Data from the Weather API using Raspberry Pi Pico\" class=\"wp-image-159902\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/get-weather-data-raspberry-pi-pico-weather-api.png?w=795&amp;quality=100&amp;strip=all&amp;ssl=1 795w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/get-weather-data-raspberry-pi-pico-weather-api.png?resize=300%2C175&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/get-weather-data-raspberry-pi-pico-weather-api.png?resize=768%2C449&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 795px) 100vw, 795px\" \/><\/figure><\/div>\n\n\n<p>You can take this project further by displaying the data on a display, like an LCD or OLED display. You can create a while loop or a timer interrupt to request data periodically, or you can even request data for multiple locations just by changing the value of the <span class=\"rnthl rntliteral\">city<\/span> variable.<\/p>\n\n\n\n<p>We have some tutorials that you can find useful:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-i2c-lcd-display-micropython\/\">Raspberry Pi Pico with I2C LCD Display (MicroPython)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-ssd1306-oled-micropython\/\">Raspberry Pi Pico: SSD1306 OLED Display (MicroPython)<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"bitcoin-ticker\">Example 2: Request Bitcoin Price<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"225\" height=\"112\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/bitcoin-logo-get-price-rpi-pico.png?resize=225%2C112&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Bitcoin logo\" class=\"wp-image-159906\"\/><\/figure><\/div>\n\n\n<p>In this example, we\u2019ll request and display the current Bitcoin price. <em>CoinGecko<\/em> has an endpoint that you can use to make requests that returns the current Bitcoin price in USD: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;api.coingecko.com\/api\/v3\/simple\/price?ids=bitcoin&amp;vs_currencies=usd<\/code><\/pre>\n\n\n\n<p>If you open that URL on your web browser, you should get something as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\"bitcoin\":{\"usd\":62748}}<\/pre>\n\n\n\n<p>Now, using that URL, we can easily get the Bitcoin price using our Raspberry Pi Pico.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Rui Santos &amp; Sara Santos - Random Nerd Tutorials\r\n# Complete project details: https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-w-http-requests-micropython\/\r\n \r\nimport network\r\nimport requests\r\nfrom time import sleep\r\n\r\n# Wi-Fi credentials\r\nssid = 'REPLACE_WITH_YOUR_SSID'\r\npassword = 'REPLACE_WITH_YOUR_PASSWORD'\r\n\r\n# Request URL\r\nurl = 'https:\/\/api.coingecko.com\/api\/v3\/simple\/price?ids=bitcoin&amp;vs_currencies=usd'\r\n\r\ndef init_wifi(ssid, password):# Init Wi-Fi Interface\r\n    wlan = network.WLAN(network.STA_IF)\r\n    wlan.active(True)\r\n    # Connect to your network\r\n    wlan.connect(ssid, password)\r\n    # Wait for Wi-Fi connection\r\n    connection_timeout = 10\r\n    while connection_timeout &gt; 0:\r\n        if wlan.status() &gt;= 3:\r\n            break\r\n        connection_timeout -= 1\r\n        print('Waiting for Wi-Fi connection...')\r\n        sleep(1)\r\n    # Check if connection is successful\r\n    if wlan.status() != 3:\r\n        return False\r\n    else:\r\n        print('Connection successful!')\r\n        network_info = wlan.ifconfig()\r\n        print('IP address:', network_info[0])\r\n        return True\r\n\r\nif init_wifi(ssid, password):\r\n    try:\r\n        # Make the request\r\n        response = requests.get(url)\r\n        #Print the response code\r\n        print('Response code: ', response.status_code)\r\n        \r\n        # Get response content\r\n        bitcoin = response.json()\r\n        # Close the request\r\n        response.close()\r\n        \r\n        # Print bitcoin price\r\n        bitcoin_price = bitcoin['bitcoin']['usd']\r\n        print('Bitcoin price (USD): ', bitcoin_price)\r\n\r\n    except Exception as e:\r\n        # Handle any exceptions during the request\r\n        print('Error during request:', e)\r\n\r\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Raspberry-Pi-Pico\/MicroPython\/HTTP_Request_Get_Bitcoin_Price.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>This code works in a similar way to the one in the previous example.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"675\" height=\"270\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Rpi-Pico-MicroPython-Get-Bitcoin-Price-Demonstration.png?resize=675%2C270&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico MicroPython HTTP GET Request Bitcoin Price\" class=\"wp-image-159904\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Rpi-Pico-MicroPython-Get-Bitcoin-Price-Demonstration.png?w=675&amp;quality=100&amp;strip=all&amp;ssl=1 675w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Rpi-Pico-MicroPython-Get-Bitcoin-Price-Demonstration.png?resize=300%2C120&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 675px) 100vw, 675px\" \/><\/figure><\/div>\n\n\n<h4 class=\"wp-block-heading\">Taking It Further<\/h4>\n\n\n\n<p>Now, you can take this project further and display the bitcoin price on an <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-ssd1306-oled-micropython\/\" title=\"\">OLED<\/a> or <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-i2c-lcd-display-micropython\/\" title=\"\">LCD<\/a> and update the data every day. You can also request data for different cryptocurrencies.<\/p>\n\n\n\n<p>You can also add some sort of notification that will send you a <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-send-email-micropython\/\" title=\"\">message <\/a>when the price crosses a certain threshold value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, you learned about HTTP GET requests and why they are useful. We&#8217;ve also shown you two different examples to get data from the internet.<\/p>\n\n\n\n<p>We hope you found this tutorial useful. We have more Raspberry Pi Pico tutorials that you may like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-i2c-lcd-display-micropython\/\">Raspberry Pi Pico with I2C LCD Display (MicroPython)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-send-email-micropython\/\">Raspberry Pi Pico W: Sending Emails using SMTP Server (MicroPython)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-ssd1306-oled-micropython\/\">Raspberry Pi Pico: SSD1306 OLED Display (MicroPython)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-web-server-micropython\/\">Raspberry Pi Pico: Web Server (MicroPython)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-asynchronous-web-server-micropython\/\">Raspberry Pi Pico W: Asynchronous Web Server (MicroPython)<\/a><\/li>\n<\/ul>\n\n\n\n<p>If you want to learn more about the Raspberry Pi Pico, make sure to take a look at our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-micropython-ebook\/\" title=\"\"><strong>Learn Raspberry Pi Pico with MicroPython (eBook)<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-raspberry-pi-pico\/\" title=\"\">Free Raspberry Pi Pico Projects and Tutorials<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial is a getting started guide to HTTP GET requests with the Raspberry Pi Pico W. HTTP Requests are fundamental to interact with web services to retrieve data from &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Raspberry Pi Pico W: Getting Started with HTTP GET Requests (MicroPython)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-http-requests-micropython\/#more-159888\" aria-label=\"Read more about Raspberry Pi Pico W: Getting Started with HTTP GET Requests (MicroPython)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":159935,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324,326],"tags":[],"class_list":["post-159888","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry-pi-pico","category-raspberry-pi-pico-micropython"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/07\/Raspberry-Pi-Pico-HTTP-GET-Requests-MicroPython.jpg?fit=1920%2C1080&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/159888","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=159888"}],"version-history":[{"count":18,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/159888\/revisions"}],"predecessor-version":[{"id":160234,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/159888\/revisions\/160234"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/159935"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=159888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=159888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=159888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}