Protocol simulator

HTTP Simulator

Test an air-quality HTTP API with simulated measurements, JSON responses and repeatable scenarios.

Follow air-quality readings from SPX to your HTTP client

In Scenarios, select Urban Pollution Variation and plot PM2.5 and PM10 together. This recorded example shows two synthetic pollution peaks with different shapes and a return toward baseline, so you can see what a dashboard would have to follow over time.

SPX Scenarios shows the Urban Pollution Variation scenario and two peaks in PM2.5 and PM10.
The Airly-inspired demo plots changing PM2.5 and PM10 on the same concentration axis.

Screenshot preview

The Airly-inspired demo plots changing PM2.5 and PM10 on the same concentration axis. Open original image

Find the endpoint and check the JSON mapping

Open Communication and expand the HTTP adapter. Check the listening port and make sure it is reachable from your client. The HTTP path, method and response fields come from the model. In the Airly-inspired demo, the pollution measurements stay numeric inside SPX so they can be plotted as they change.

SPX Communication shows the HTTP adapter for the Airly-inspired demo, with its endpoint settings expanded.
The HTTP adapter for the same Airly-inspired demo, focused on its connection settings.

Screenshot preview

The HTTP adapter for the same Airly-inspired demo, focused on its connection settings. Open original image

Show the HTTP response mapping in YAML

Excerpt from the same Airly-inspired demo shown above. The response exposes the current readings as numbers.

endpoints:
  "/v1/air-quality/{profile}":
    method: GET
    response:
      current:
        pm2_5: "#attr(k__current_pm2_5)"
        pm10: "#attr(k__current_pm10)"

Check the values your HTTP client received

To test a write as well as a read, use the custom station below. Compare its two numeric readings before and after the control write. The full JSON example also shows the station ID and units.

Recorded custom-station test results
OperationResult
First GETHTTP 200 · PM2.5 12.4, PM10 21.8 µg/m³
GET after PATCHPM2.5 37.2, PM10 58.6 µg/m³

Try a ready-made air-quality station

Start the library station and read live numeric measurements from its JSON endpoint.

Test an application against a virtual HTTP device

Connect a dashboard or integration to a simulated endpoint. SPX maps HTTP requests and JSON fields to model attributes, so your application can read measurements while you observe or change the device in SPX UI.

HTTP · JSON

Connect your application to simulated measurements

Your software

HTTP client

Requests measurements and reads the JSON response.

HTTP / JSON

SPX · HTTP adapter

Endpoint bindings

Maps model endpoints and JSON fields to attributes.

Attributes

SPX · runtime

Virtual station

Simulates measurements and scenario changes.

The model defines the response; use a host and port reachable from your client.

Install SPX with HTTP support and SPX UI. The model defines its own paths, methods and response fields; configure an address and port reachable by your client. In Docker, the adapter port may need to be published to the host.

Create an air-quality station with your AI agent

This custom example takes inspiration from the general idea of Airly's air-quality data. It uses synthetic measurements and a fictional JSON contract: it does not implement or claim compatibility with Airly's API, authentication or response format.

Open your SPX workspace in a local AI agent and give it this prompt:

Prompt for your AI agent

Create a new custom SPX HTTP simulator model for an air-quality station inspired by the general idea of Airly, without claiming Airly compatibility. Use synthetic JSON only, with numeric PM2.5 and PM10 readings in µg/m³ and a clear demo marker. Save a new YAML under `custom_models/`, preserving all existing models and instances. Validate it, create and start one new instance, then perform a real HTTP GET and show the returned JSON. Change PM2.5 and PM10 using the supported simulator control path, perform a second real GET, and show that both numbers changed. Leave the new instance running for a screenshot. Do not edit website files.

Tested with GPT-6 Luna · Medium

Estimated API cost · $0.0076 per run

We tested this prompt with GPT-6 Luna · Medium. The agent generated and validated a new model and started an instance. After the host connection was refused, we asked it to test from inside the SPX container, where the endpoint was reachable. Download the tested YAML. The estimated cost on the card comes from a separate run that generated a fresh model and verified both GET responses from inside the SPX container. A new run can produce a different model and endpoint.

Connect and observe

In our generated model, GET /v1/air-quality returned HTTP 200 and this synthetic JSON:

{
  "demo_data": true,
  "station_id": "SPX-DEMO-001",
  "timestamp": "2026-11-14T12:00:00Z",
  "units": { "pm2_5": "ug/m3", "pm10": "ug/m3" },
  "readings": { "pm2_5": 12.4, "pm10": 21.8 }
}

The timestamp is fixed demonstration data. We then sent a JSON PATCH /simulator/readings with a timestamp and new pm2_5 and pm10 values. A second GET returned 37.2 and 58.6 µg/m³, respectively. This write endpoint is a simulator control for this example, not an Airly endpoint.

SPX UI showing the generated air-quality station and its numeric PM2.5 and PM10 attributes.
The generated station in SPX UI: numeric attributes can be inspected and plotted.

Screenshot preview

The generated station in SPX UI: numeric attributes can be inspected and plotted. Open original image

For a richer time-compressed scenario, a separate Airly-inspired demonstration model includes the Urban Pollution Variation scenario shown above. Its two illustrative PM peaks are synthetic and do not represent calibrated atmospheric physics.

In our setup, port 8097 was available inside the server container but not published on the host. Use the address and port reachable from your client. See the HTTP adapter guide for endpoint configuration.