Built-in project · ESP32-C3-DevKitM-1

API lab: fetch JSON, on an ESP32-C3

Call an API with normal HTTPClient code, edit its JSON response in Cloud and inspect the complete request and response. The whole build, an ESP32-C3, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

IntermediateRuns in your browser. Free, and no account needed.

API lab: fetch JSON · ESP32-C3-DevKitM-1live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · ESP32-C3-DevKitM-1
/*
 * API lab: call an endpoint and inspect the JSON it returns.
 *
 * Open the Cloud panel, edit the status and response body for api.mokxi, then
 * watch this same firmware handle the new answer. Nothing leaves this browser.
 */
#include <HTTPClient.h>
#include <WiFi.h>
#include <WiFiClient.h>

const char *SSID = "Mokxi-Lab";
const char *PASSWORD = "breadboard";

void setup() {
  Serial.begin(115200);
  WiFi.begin(SSID, PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(250);
  }
  Serial.println("\nConnected. Open Cloud and edit the API response.");
}

void loop() {
  WiFiClient client;
  HTTPClient http;
  http.begin(client, "http://api.mokxi/data");
  int status = http.GET();
  Serial.print("HTTP status: ");
  Serial.println(status);
  Serial.print("JSON response: ");
  Serial.println(http.getString());
  http.end();
  delay(5000);
}

Parts list

2 parts, plus the jumper wires. Every one is in the editor's parts bin.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.