Build and learn
August 24, 2023

Adding third-party API data into Viam

Saul N. Jinnear
Consulting Engineer
On this page

Viam’s data platform is super cool and useful for storing data generated by your robot. But, there are times where it could be helpful to store some data from external sources alongside that generated by your robot.

For example, I’ve got a plant monitoring bot that I’ve built and I’ve got loads of data from the sensors surrounding my plant. I do not, however, have weather data to go with it. I know I can get weather data from weatherapi.com. But how can I get that store alongside the data from my robot?

Stick with me kid! We’ll get this thing going in no time!!!

Adding external data to Viam’s data platform is nice and easy. All we’ve got to do is wrap the API calls we want to make in a simple modular sensor component.

The process

I started out by making a very small python script that simply queries weatherapi.com for the current weather.

With the logic refined and functioning, I set out to create a modular sensor. How could I do this with as little effort as possible? I just copied the simple module example from https://github.com/viamrobotics/viam-python-sdk/tree/main/examples/simple_module. Then I modified the class name and model to make this a sensor of my own.

Then to make this sensor function as an API-querier, I moved the logic from my initial script into the get_readings function. Sweet! Now this component can query that API and return the data via get_readings().

The data service can now be configured to query this endpoint at whatever cadence I see fit. Almost too easy!

I wanted to commit this to the repo where others could find and use it, so I moved the api_key from being hardcoded (as it was in my original script) into an attribute for the component. I did similar work to move the other query params (in this case “zipcode”) out to a config attribute as well.

What an exciting adventure we’ve just gone on together!!

Final code

twitter iconfacebook iconlinkedin iconreddit icon

Find us at our next event

Feb 19, 2026
,
6:00-9:00PM

Scaling Physical AI in the Real World

In Person
Viam HQ, NYC
Physical AI is no longer a future concept—it's here. Join us for a panel discussion on what it takes to build and deploy production-ready intelligent systems that work in real-world environments. Leaders from Viam, Gambit Robotics, and Illuminix will share real examples from kitchen automation to augmented reality to robotics, exploring how teams design systems resilient enough for the messy, unpredictable real world.
RSVP
Mar 6, 2026
,
9:00AM-5:00PM

LLMday 2026

In Person
Viam HQ, NYC
Join us at the Viam HQ of LLMday for a full day filled with practical talks from engineers and practitioners working on agentic systems, reliability, safety, and real world deployments, plus plenty of time to connect with others in the field.
Get Tickets