Daten per GET von einer API abrufen
Stellen Sie eine HTTP-Anfrage und lesen Sie die Antwort aus.
Daten per GET von einer API abrufen ist eine kostenlose Arduino & IoT Academy-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Arduino & IoT Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
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. 🎉
Häufig gestellte Fragen
Ist die Lektion „Daten per GET von einer API abrufen“ kostenlos?
Ja — der vollständige Text von „Daten per GET von einer API abrufen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Arduino & IoT Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Daten per GET von einer API abrufen“?
Stellen Sie eine HTTP-Anfrage und lesen Sie die Antwort aus. Du übst Arduino & IoT Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Arduino & IoT Academy zu starten?
Keine Vorkenntnisse erforderlich. Arduino & IoT Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.
Wie lange dauert die Lektion „Daten per GET von einer API abrufen“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Arduino & IoT Academy-Lektion Code schreiben und ausführen?
Ja. Jede Arduino & IoT Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Daten per GET von einer API abrufen
- Sensormesswerte per POST senden
- JSON-Antworten parsen
- HTTPS sicher verwenden