<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Matt</title>
    <description>The latest articles on DEV Community by Matt (@robotwizard).</description>
    <link>https://dev.to/robotwizard</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3636308%2F9987321a-8233-41ad-a4a8-b87e717de64f.png</url>
      <title>DEV Community: Matt</title>
      <link>https://dev.to/robotwizard</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/robotwizard"/>
    <language>en</language>
    <item>
      <title>How to create a virtual environment in Visual Studio Code with Python</title>
      <dc:creator>Matt</dc:creator>
      <pubDate>Mon, 29 Dec 2025 20:14:05 +0000</pubDate>
      <link>https://dev.to/robotwizard/how-to-create-a-virtual-environment-in-visual-studio-code-with-python-486p</link>
      <guid>https://dev.to/robotwizard/how-to-create-a-virtual-environment-in-visual-studio-code-with-python-486p</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Virtual environments are a fundamental tool that all beginner software developers should learn at some point. Virtual environments are isolated spaces generated by a computer. These spaces separate package installs from eachother. This is important because certain projects may use and require different package versions.  Virtual environments prevent conflict between these versions by isolating the different versions from each other. &lt;/p&gt;

&lt;p&gt;This tutorial will cover how to set up a virtual environment quickly in Visual Studio with the pre installed python module &lt;strong&gt;venv&lt;/strong&gt;. This tutorial assumes that you know the basics of navigating Visual Studio Code and have Python installed.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Creating an environment:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In order to create a virtual environment, follow the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Visual Studio Code&lt;/li&gt;
&lt;li&gt;Open a new terminal (Terminal -&amp;gt; New Terminal)&lt;/li&gt;
&lt;li&gt;Within that terminal, run the appropriate commands based on your operating system&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;MacOS/Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ Mkdir envFolder
$ cd envFolder
$ python3 -m venv .venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; Mkdir NameOfFolder
&amp;gt; cd NameOfFolder
&amp;gt;  python3 -m venv .venv

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Activating the environment:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;After a virtual environment is created, it has to be activated before it is used. In order to activate the virtual environment, run the following script in your terminal:&lt;/p&gt;

&lt;p&gt;If you're using macOS/Linux, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ . . venv/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’re using Windows, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; .venv\Scripts\activate

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that if you tried to run the above script, you may have received an error message stating that the execution of scripts is disabled on your computer. For security purposes, some computers will disable script execution to prevent the user from running scripts that could cause harm to their system. &lt;/p&gt;

&lt;p&gt;To temporarily bypass this restriction:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Close Visual Studio Code&lt;/li&gt;
&lt;li&gt;Reopen Visual Studio Code as an administrator &lt;/li&gt;
&lt;li&gt;Open a new terminal&lt;/li&gt;
&lt;li&gt;Run the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This temporarily lets the user bypass the security restrictions that disable the execution of scripts&lt;br&gt;
Afterwards, repeat the above steps, starting with step 5 of creating a new environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you successfully activated the virtual enviroment then you should see (.venv) at the start of a new line in the terminal. The virtual environment only stays activated while the terminal is open and will automatically deactivate if the terminal is ever closed.&lt;/p&gt;

&lt;p&gt;Virtual environments should always be created if you're starting a new project that requires external libraries to be downloaded. Getting in the habit of creating virtual environments will help prevent issues in future projects that you will work on.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>vscode</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to use Python's requests library to retrieve data from APIs</title>
      <dc:creator>Matt</dc:creator>
      <pubDate>Tue, 23 Dec 2025 03:43:59 +0000</pubDate>
      <link>https://dev.to/robotwizard/how-to-use-pythons-request-library-to-retrieve-data-from-apis-2c6</link>
      <guid>https://dev.to/robotwizard/how-to-use-pythons-request-library-to-retrieve-data-from-apis-2c6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;Python’s requests library allows developers send messages from a client, such as a web browser, to a server in order to receive data. These messages are commonly referred to as &lt;strong&gt;HTTP requests&lt;/strong&gt; and are used when interacting with APIs.&lt;/p&gt;

&lt;p&gt;An &lt;strong&gt;API (Application Programming Interface)&lt;/strong&gt; allows different software applications to communicate with each other without directly accessing each other’s internal systems. Think of an API as a cashier in a fast-food restaurant. The cashier takes in the customer's order and passes it to the kitchen, where the order is being prepared.&lt;/p&gt;

&lt;p&gt;When a company or organization wants to give people access to their data while maintaining security, they often use APIs as a middleman. This allows users, such as developers and researchers, to retrieve data without risking changes to the original dataset.&lt;/p&gt;

&lt;p&gt;Python’s requests library makes gathering data from APIs simple and effective. In this tutorial, I will be using the &lt;a href="https://www.freetogame.com/api-doc%20api" rel="noopener noreferrer"&gt;FREETOGAME&lt;/a&gt; as an example. However, the concept learned in this tutorial can be applied to other APIs. Additionally, this tutorial uses Visual Studio Code, but you can follow along in any Python environment. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setup:
&lt;/h2&gt;

&lt;p&gt;Since requests is a third-party library, it has to be installed before use:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Visual Studio Code and make a new file&lt;/li&gt;
&lt;li&gt;Open a terminal (Ctrl+Shift+~ or Terminal -&amp;gt; New Terminal)&lt;/li&gt;
&lt;li&gt;In this terminal type pip install requests and hit enter&lt;/li&gt;
&lt;li&gt;Verify installation in Python by typing import requests into the code editor. If no errors appear, installation was successful&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Fetching Data:
&lt;/h2&gt;

&lt;p&gt;The requests library supports 7 different HTTPS methods. However, this tutorial only focuses on the &lt;strong&gt;requests.get()&lt;/strong&gt; method. This method takes in a URL as a parameter and is used to fetch a resource, such as data. &lt;/p&gt;

&lt;p&gt;The URL used in this example can be found in the  &lt;a href="https://www.freetogame.com/api-doc" rel="noopener noreferrer"&gt;FREETOGAME&lt;/a&gt; API. Scroll down until you see the text live game list, and then copy the URL below that text. Afterwards, enter the following code into your editor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     response = requests.get("https://www.freetogame.com/api/games")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check to see if the request was successful, print the response variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     print(response)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything has been set up correctly, then when you run the program, &lt;strong&gt; **should be output in the terminal. The number 200 is a **status code&lt;/strong&gt; that indicates that the HTTP request was a success!&lt;/p&gt;

&lt;h2&gt;
  
  
  Parsing JSON Data:
&lt;/h2&gt;

&lt;p&gt;Although the request succeeded, the data is still not visible.  Most APIs return data in &lt;strong&gt;JSON&lt;/strong&gt; format, which is a structured text format that is easy for both humans and machines to read. To convert the response to JSON, use the &lt;strong&gt;.json()&lt;/strong&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     gameList = response.json()
     print(gameList)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If done correctly, this will output a large list containing dictionaries representing different games. Although we can now see what the data contains, the output is hard to read. To view the data of one specific game. Replace the print statement in the above example with the following code and then click run.&lt;br&gt;
print(gameList[0])&lt;/p&gt;

&lt;p&gt;This outputs a dictionary containing information about the game Overwatch 2, including its description, the platforms it is on, and its developers.  &lt;/p&gt;
&lt;h2&gt;
  
  
  Accessing specific data:
&lt;/h2&gt;

&lt;p&gt;If you only need a specific piece of data in the dictionary, such as the release date of the games, you can access it using &lt;strong&gt;dictionary keys&lt;/strong&gt;.  For example, type in the following code and run your program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     print(gameList[0]['release_date'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output should be the date 2022-10-04. If you want to retrieve the release dates of every game in the list, use a for loop. Type in the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     for game in gameList:
         print(game['release_date'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If done correctly, you should now be able to see the release dates of all the games in the list. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;The requests library is a very powerful and fairly easy library to work with APIs. To continue learning, consider exploring error handling, query parameters, and APIs that require authentication. In the real world, developers are expected to handle a wide variety of APIs.&lt;br&gt;
Thank you for reading until the end of this tutorial.&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>api</category>
    </item>
  </channel>
</rss>
