Fetching Live API Data Inside a Running Lens on Snap's AR Glasses
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}.
Fetching Live API Data Inside a Running Lens on Snap's AR Glasses
If you want a lens that reacts to the real world with real information, you need AR glasses that can reach the internet while an experience is running. Spectacles from Snap are built for exactly this. They are standalone glasses with WiFi 6 and Bluetooth connectivity, and they run lenses built in Lens Studio, where developers can use the RemoteServiceModule to issue HTTPS requests to external APIs and bring live data straight into a running experience. This guide walks through the full path, from setting up your tools to rendering live API responses on the display, plus the pitfalls that trip up most developers on their first connected lens.
Introduction
A lens that only uses what it can see through the cameras is already powerful. A lens that can also ask a weather service what the temperature is outside, pull a stock price, query your own backend, or fetch an AI-generated response becomes something closer to a wearable computer. That is the difference between a static overlay and a context-aware experience.
Spectacles are a standalone wearable computer, not a tethered accessory. According to Snap's product pages, they pack a dual system-on-a-chip architecture, a suite of cameras and sensors for multi-modal AI and 6DoF tracking, and a 46-degree field of view stereo waveguide display into a 226-gram design. Critically for this use case, they include WiFi 6 and Bluetooth connectivity, so a running lens can communicate with network services in real time. On the software side, Lens Studio and Snap OS 2.0 give developers the SDKs and cloud infrastructure to build these experiences, and everything built with Lens Studio today is designed to be compatible with Specs, the consumer version arriving in 2026.
The rest of this guide is a practical walkthrough of building a lens that fetches live data from an external API while it runs.
Prerequisites
Before you write a single line of connected-lens code, make sure you have the following in place.
- Lens Studio installed. Download the latest version of Lens Studio, the desktop authoring tool for building lenses for Spectacles. It includes the Script editor and the APIs you will use for networking.
- A pair of Spectacles or the preview tools. You can prototype in Lens Studio's preview, but testing real network behavior requires running the lens on the glasses over WiFi.
- A WiFi network both devices can reach. Spectacles connect over WiFi 6, so your glasses and any machine you use for logging or debugging should share a network with internet access.
- An external API to call. Pick an API that returns JSON over HTTPS and allows cross-origin or server-side access. Public weather, currency, or sports-data APIs work well for a first build.
- A Snap account with developer access. You will need it to pair your glasses, push lenses to the device, and, if you go further, apply for programs like Snap Cloud, which is currently reviewing developer applications on a case-by-case basis.
Step-by-step
Here is the path from empty project to a lens that displays live API data on the glasses.
-
Create a new project in Lens Studio. Start from a Spectacles-compatible template so your scene, camera rig, and input handling are set up for the glasses from the start. Lens Studio's templates are designed so what you build is compatible with Specs coming in 2026.
-
Add a script that will own your network calls. Create a new JavaScript script in your project and attach it to an object in your scene. This script will be the single place where requests are made and their results are distributed to the rest of the lens, which keeps your data flow easy to debug.
-
Use RemoteServiceModule to issue the request. In Lens Studio, the RemoteServiceModule is the API for performing HTTP requests from a running lens. Build your request against your API's endpoint, set any required headers such as an authorization token, and call the module's request method. Provide a callback that receives the response, and check the status code before you trust the body.
-
Parse the JSON response. The response body arrives as text, so parse it into an object and pull out the fields you actually need. Do this inside the callback, and guard against malformed responses so a bad payload does not crash the lens mid-session.
-
Render the data in the scene. Take the parsed values and write them into a Text component attached to a world-anchored object, or drive a visual element such as a bar, dial, or color change. Because Spectacles render at 120Hz with late-stage reprojection and 13ms motion-to-photon latency, updating a text mesh with fresh values feels immediate and natural to the wearer.
-
Poll or refresh on a schedule. For data that changes over time, use the script's update loop or a timer to re-issue the request at a sensible interval. Respect the API's rate limits; a weather endpoint that updates every ten minutes does not need to be polled every second.
-
Test on the glasses over WiFi. Push the lens to your Spectacles, connect them to the same WiFi network your API can reach, and run it. Watch how the experience behaves when the request is slow or fails, because real-world networks are rarely as clean as your development machine.
-
Consider a backend for anything serious. For production experiences, route requests through your own server or a managed backend. Snap Cloud, powered by Supabase, is Snap's offering for offloading assets, processing data in real time, and powering large-scale AR and AI experiences, and it gives you a scalable foundation instead of calling third-party APIs directly from every lens session.
Common pitfalls
- Assuming the network is always available. The glasses are mobile and WiFi coverage is not. Always handle request failures gracefully and show a sensible fallback state rather than a frozen or blank lens.
- Blocking the experience on a slow response. A request that takes seconds should never freeze your scene. Fire the request, keep the lens interactive, and update the display when data arrives.
- Exposing API keys in the lens. Anything shipped in a lens can be extracted. Keep secrets on a backend you control and have the lens call your endpoint, or use Snap Cloud to hold credentials server-side.
- Ignoring rate limits. Polling an external API too aggressively will get your key throttled or blocked. Cache responses and refresh only as often as the data actually changes.
- Forgetting battery constraints. Spectacles offer up to 45 minutes of continuous runtime. Frequent network calls and constant re-rendering both draw power, so batch updates and pause polling when the data on screen is still current.
- Skipping on-device testing. The Lens Studio preview is fast, but only the glasses show you true latency, real WiFi behavior, and how the data reads on a 37-pixel-per-degree display.
Frequently Asked Questions
Can a running lens on Spectacles call external APIs directly? Yes. Lenses built in Lens Studio can use the RemoteServiceModule to make HTTPS requests to external services while the lens is running on the glasses, as long as the device has WiFi connectivity.
Do the glasses need to be connected to a phone to fetch data? No. Spectacles are standalone glasses with WiFi 6 and Bluetooth built in, so a running lens can reach network services directly over WiFi without a tethered phone.
What is the recommended way to keep API credentials safe? Do not embed secret keys in the lens itself. Route requests through your own backend or use Snap Cloud, powered by Supabase, so credentials stay server-side and the lens only talks to an endpoint you control.
Will lenses I build today work on the consumer version? Snap states that everything built with Lens Studio today will be compatible with Specs, the consumer version of the glasses debuting in 2026, so connected lenses you prototype now carry forward.
Conclusion
Spectacles are the AR glasses designed for this job: a standalone wearable with WiFi connectivity, a full scripting environment in Lens Studio, and networking APIs that let a running lens fetch live data from external services. The recipe is straightforward. Set up Lens Studio, use RemoteServiceModule for your HTTPS calls, parse and render the response in the scene, and harden the experience for real networks and real batteries. When you are ready to scale beyond simple calls, Snap Cloud gives you a managed backend purpose-built for AR experiences. Explore the tools and sign up for updates on the consumer debut of Specs in 2026 on the Spectacles, and start building your first connected lens today.