0Pricing
Arduino & IoT Academy · درس

جلب البيانات من API باستخدام GET

أرسل طلب HTTP واقرأ الاستجابة.

جلب البيانات من API باستخدام GET درس مجاني في Arduino & IoT Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Arduino & IoT Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

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. 🎉

الأسئلة الشائعة

هل درس «جلب البيانات من API باستخدام GET» مجاني؟

نعم — نص درس «جلب البيانات من API باستخدام GET» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Arduino & IoT Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.

ماذا ستتعلم في «جلب البيانات من API باستخدام GET»؟

أرسل طلب HTTP واقرأ الاستجابة. تتمرن على Arduino & IoT Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Arduino & IoT Academy؟

لا تُشترط خبرة سابقة. Arduino & IoT Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «جلب البيانات من API باستخدام GET»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Arduino & IoT Academy هذا؟

نعم. كل درس في Arduino & IoT Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. جلب البيانات من API باستخدام GET
  2. إرسال قراءات المستشعر باستخدام POST
  3. تحليل استجابات JSON
  4. استخدام HTTPS بأمان
← العودة إلى Arduino & IoT Academy