fetch data using python and dweet.io

How to fetch data from dweet.io using Python (Tutorial)

We sometimes use affiliate links in our content. This won't cost you anything, but it helps us to offset the costs of paying our writing team. You can support us directly on BuyMeACoffee. Thank you!

For this tutorial, I’m going to walk you through the process of fetching data from dweet.io using Python.

Fetch Data from dweet.io using Python

dweet.io is a website that is similar to twitter but for connected devices. You can access sensor readings through a dweet.io URL in a JSON format. We will use this website to fetch data using a Python script.

Before we begin, I recommend that you have some prior knowledge of Python. We’ll be using Python3 for this lesson, but the libraries for this exercise work with previous releases of Python.

If you don’t know Python or aren’t familiar with dictionaries, loops, syntax, or connecting to webpages to retrieve data, then I recommend taking an introductory Python class before trying this tutorial. Feel free to try this tutorial out if you have some experience with Python. Just know that I won’t be covering common syntax or explaining every detail.

I’ve linked to the Python for Everybody webpage. This material is also offered on Coursera as a 5-class specialization. You can also take the Complete Python Bootcamp on Udemy. I highly recommend taking one of these courses if you want a thorough understanding of the fundamentals of Python.

Setup & Configuration

I’ve listed all the things you’ll need to complete this project.

You’ll need to code on a laptop computer (Mac, Windows, or Linux). You won’t be able to complete this project using a tablet or iPad.

Install Python on your computer. (Windows Tutorial | Mac Tutorial)

You’ll also be prompted to install a text editor for Python. Feel free to choose whatever text editor you like. I recommend Atom.io or Sublime Text. This tutorial will be showing you screenshots from Atom.io

Download the dweepy repository from Github. Follow the instructions in the README to setup dweepy.

Getting started with dweet.io

The dweet.io website gives you the option to have public (unlocked) or private (locked) devices. All of the unlocked devices are listed on the Discover page. We will be using a random unlocked device for this tutorial. You have the option when you’re developing your own devices to lock or unlock them. Locks are $1.99/mo and will keep your sensor data private.

Since we are just fetching data, we won’t need any actual hardware configured. You can learn how to send data to dweet.io with a Wemos D1 Mini (ESP8266) in this tutorial.

Navigate to the Discover Page on dweet.io

Your list of devices will vary from the screenshot below. Select one that has a few streams. I’m going to choose the “theBHVbooktemper2017” thing and capture Temperature & Humidity data.

fetch data from dweet.io using Python

Next, click on the name of the thing. It will open up a webpage and show you recent data.

fetch data from dweet.io using Python

Create the retrieve.py script to fetch data from dweet.io

Navigate to the folder where you installed the dweepy repository. Open up the dweepy folder and create a new Python script. Your Python file must be located inside the dweepy Github folder or you’ll receive an error when you run the script. I’ve called mine “retrieve.py”

We’re going to use the features of the dweepy repository to connect to theBHVbooktemper2017 and fetch these readings.

The script will work by prompting the user for a thing name. Next, we will use the dweepy repository to connect to the URL on dweet.io to obtain readings as a JSON file.

We can then parse the JSON using key-value pairs (from dictionaries) in Python. Lastly, we’ll print these readings in Terminal for the user to see. Here’s what you get once it’s all setup!

fetch data from dweet.io using Python

Code walk-through video

Since this code is simple enough to replicate, I’ve compiled a code walk-through video. Use this to gather inspiration for your solution! You can also download a copy of the example code below!

If you like these types of videos, be sure to subscribe to the Learn Robotics YouTube Channel

Next Steps

In the next tutorial, I’m going to show you how to log data from dweet.io into a local database.

If you liked this article, be sure to share it with a friend! And as always, if you have any questions, drop them below!

Support Content Like This

You May Also Like

Have a question? Need Help?

Thanks for dropping by! Comments are no longer moderated daily.
Before posting your comment, please consider buying a coffee.
If you'd like to work with Liz, you can schedule a call here.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Learn Robotics Botly Favicon

Become a Learn Robotics Insider


Be the first to know when we launch new robotics content. Plus gain FREE robotics tips to your inbox.

Awesome! Check your inbox for a surprise!

Remote Robotics Courses for High School, Middle School, or Pre-College Training

Join the Powered by Learn Robotics Program

Teach robotics anywhere with our turnkey robotics program!

Download our free program brochure!

Success! Check your email for the download!

Interactive Robotics Classes

If you made it this far...

Chances are you’ll like our other stuff too!

Sign up and receive the best in robotics projects, tips, and offers.