GET Data from an API
Make an HTTP request and read the response.
GET Data from an API is a free Arduino & IoT Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Web Is Just Requests
Your board can pull data from the internet the same way a browser does: by making an HTTP request to a URL. 🌐
What GET Means
A GET request asks a server, please send me this data. It only reads, it never changes anything on the other side.
You Need a Connection First
Before any request, your ESP must already be on WiFi. Without a network connection there is nowhere to send the request.
Include HTTPClient
The HTTPClient library gives you simple functions to make requests. Include it at the top of your sketch.
#include <HTTPClient.h>Create the Client
Make an HTTPClient object, then point it at your target URL with begin(). This sets up the request you are about to send.
HTTPClient http;
http.begin("http://api.example.com/data");Send the GET
Call GET() to fire the request. It returns an HTTP status code that tells you whether the server liked your request.
int code = http.GET();Check the Status Code
A code of 200 means success. Always check it before trusting the data, since 404 or 500 means something went wrong.
if (code == 200) {
// good response
}Read the Response Body
When the status is good, grab the actual data with getString(). This is the text the server sent back to you.
String body = http.getString();Always Free the Connection
Call end() when you are done. This closes the connection and frees memory so the next request starts clean.
http.end();Negative Codes Are Local
A negative status code does not come from the server. It means the request failed on your side, often no WiFi or a bad URL.
Do Not Hammer the Server
Add a delay between requests so you do not flood the API. Most services limit how often you may ask for data.
Quick Check
Your code received an HTTP status of 200. What does that tell you?
Recap
You connected, called GET(), checked for 200, read the body with getString(), and closed with end(). That is a full read from the web. 🎉
Frequently asked questions
Is the “GET Data from an API” lesson free?
Yes — the full text of “GET Data from an API” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.
What will I learn in “GET Data from an API”?
Make an HTTP request and read the response. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Arduino & IoT Academy?
No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “GET Data from an API” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Arduino & IoT Academy lesson?
Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- GET Data from an API
- POST Sensor Readings
- Parse JSON Responses
- Use HTTPS Securely