Start in three steps
Connect an HTTP client to a virtual weather API, inspect its JSON and verify a profile update. This example serves static sample data.
Before you start: Install SPX with the HTTP package and SPX UI. Have an HTTP API client ready. Download the static forecast model.
1. Create the API instance
Import the YAML in Models → Load model from file. Create an instance from that registered model with http_host=0.0.0.0 and http_port=8091. Start it and confirm RUNNING.
2. Request the forecast
Check Communication → http_endpoint. Send GET to http://SPX_HOST:8091/v1/forecast/clear/48, replacing SPX_HOST and the port with your reachable host and published TCP port. Expect 200 and JSON containing forecast_profile="clear" and forecast_horizon_hours=48.
3. Update the profile and read it back
Send POST to /simulator/profile with Content-Type: application/json and body {"profile":"clear","horizon_hours":24}. Success: the reply contains status="ok" and forecast_horizon_hours=24. GET /v1/forecast/clear/24 to verify the new horizon. GET /v1/forecast/clear/48 to restore it, then stop the instance.
Protocol communication
Use these settings and messages with the library’s static weather forecast model.
- Client base URL
- http://SPX_HOST:8091; Communication → http_endpoint
- Body format
- JSON for POST/PUT; Content-Type: application/json
- Docker
- Publish TCP 8091 or use your configured host port
Replace host placeholders with reachable addresses and use your published ports.
Swipe the table to see requests and replies.
| Address / message | Operation / payload | Expected reply |
|---|---|---|
/v1/forecast/clear/48 | GET — profile clear, horizon 48 | 200 JSON; forecast_profile="clear", forecast_horizon_hours=48, current_weather.temperature=4.2 at defaults |
/simulator/profile | POST {"profile":"clear","horizon_hours":24} | 200 JSON; status="ok", active_profile="clear", forecast_horizon_hours=24 |
/simulator/location | PUT {"latitude":52.2297,"longitude":21.0122,"timezone":"Europe/Warsaw"} | 200 JSON; status="ok" plus the supplied location fields |
Values describe this model’s nominal setup unless noted. Live measurements change as the simulation runs.
Example request and reply
GET the forecast. POST the 24-hour profile, then GET /v1/forecast/clear/24 and verify the returned horizon and SPX forecast_horizon_hours attribute.
GET http://SPX_HOST:8091/v1/forecast/clear/48
→ 200; JSON fields include forecast_profile="clear",
forecast_horizon_hours=48, current_weather.temperature=4.2
POST http://SPX_HOST:8091/simulator/profile
Content-Type: application/json
{"profile":"clear","horizon_hours":24}
→ 200 {"status":"ok","active_profile":"clear","forecast_horizon_hours":24}No reply or an unexpected value?
- SPX_HOST is the reachable server address; 0.0.0.0 is a listen address.
- Use the exact method and route. GET /v1/forecast alone does not match /v1/forecast/{profile}/{horizon_hours}.
- This model serves static sample arrays with fixed dates. Changing profile/horizon updates metadata; it does not generate weather or resize those arrays.
What you can test next
- Use
PUT /simulator/locationto test location-field updates. - Compare your client’s JSON parsing with the returned field names and units.
- Change sample attributes in SPX and repeat the GET request. Profile/horizon metadata does not generate new forecast arrays.
See the HTTP adapter guide for configuration details.
