Skip to content

title: ESP32 HTTP Client Code Examples & Arduino Sketches description: Collection of complete C++ code examples for ESP32-HTTP-Client: CRUD operations, struct serialization, JSON arrays, Auth headers, and error handling. keywords: ESP32 HTTP client code examples, Arduino ESP32 HTTP sketch, ESP32 REST API example C++, PlatformIO ESP32 sample code tags: - example - overview


Examples

All examples are available in the examples/ directory and can be opened directly from the Arduino IDE via File → Examples → ESP32-HTTP-Client.

Example Description
CRUD Operations Full suite of REST methods (GET, POST, PUT, PATCH, DELETE) in a single sketch.
Struct <-> JSON Bi-directional C++ struct to JSON serialization and deserialization.
URL Parameters Dynamic path parameter replacement (/users/{id}) and query parameters.
Authentication Authenticating requests using Bearer / JWT, HTTP Basic Auth, and API Key headers.
Callbacks & Errors Request callbacks, timeouts, automatic retries, error handling, and runtime URL change.
Nested JSON Extracting deeply nested fields using dot-notation paths.
Array JSON Addressing specific elements of a JSON array by index.
Raw JSON Capturing entire objects or sub-arrays into an Arduino String.
Unix Timestamp Fetching a long Unix timestamp from a time API.
Custom Port Connecting to a server running on a non-standard port.
SOAP Web Services Consuming SOAP 1.1 and SOAP 1.2 web services with streaming XML responses.
SOAP Faults Inspecting SOAP Fault codes, reasons, details, and callbacks.
GraphQL Queries Running GraphQL queries and mutations with direct response field binding.
GraphQL Variables Parameterizing GraphQL operations with typed variables and struct mappings.
GraphQL Errors Inspecting GraphQL errors, locations, paths, and extensions while preserving data.
GraphQL Streaming Consuming deferred incremental streams (multipart/mixed, @defer).
JSON-RPC Web Services JSON-RPC 2.0 requests, positional/named parameters, notifications, and struct mapping.