Skip to content

Commit 0ff3e32

Browse files
committed
docs: align HTTP API examples with current JanusQL syntax
1 parent 772ccc4 commit 0ff3e32

5 files changed

Lines changed: 31 additions & 25 deletions

File tree

docs/HTTP_API.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ Register a new JanusQL query.
6161
```json
6262
{
6363
"query_id": "sensor_query_1",
64-
"janusql": "SELECT ?sensor ?temp FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-01-02T00:00:00Z] WHERE { ?sensor <http://example.org/temperature> ?temp . }"
64+
"janusql": "PREFIX ex: <http://example.org/> SELECT ?sensor ?temp FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1704153600] WHERE { WINDOW ex:histWindow { ?sensor ex:temperature ?temp . } }"
6565
}
6666
```
6767

68-
**Response (201 Created):**
68+
**Response (200 OK):**
6969
```json
7070
{
7171
"query_id": "sensor_query_1",
@@ -375,7 +375,7 @@ curl -X POST http://localhost:8080/api/queries \
375375
-H "Content-Type: application/json" \
376376
-d '{
377377
"query_id": "temp_query",
378-
"janusql": "SELECT ?sensor ?temp FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-01-02T00:00:00Z] WHERE { ?sensor <http://example.org/temperature> ?temp . }"
378+
"janusql": "PREFIX ex: <http://example.org/> SELECT ?sensor ?temp FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1704153600] WHERE { WINDOW ex:histWindow { ?sensor ex:temperature ?temp . } }"
379379
}'
380380
```
381381

@@ -439,7 +439,7 @@ response = requests.post(
439439
f"{BASE_URL}/api/queries",
440440
json={
441441
"query_id": "my_query",
442-
"janusql": "SELECT ?s ?p ?o FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-01-02T00:00:00Z] WHERE { ?s ?p ?o }"
442+
"janusql": "PREFIX ex: <http://example.org/> SELECT ?s ?p ?o FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1704153600] WHERE { WINDOW ex:histWindow { ?s ?p ?o . } }"
443443
}
444444
)
445445
print(f"Register: {response.json()}")
@@ -477,7 +477,7 @@ async function demo() {
477477
// Register a query
478478
const registerResponse = await axios.post(`${BASE_URL}/api/queries`, {
479479
query_id: 'js_query',
480-
janusql: 'SELECT ?s ?p ?o FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-01-02T00:00:00Z] WHERE { ?s ?p ?o }'
480+
janusql: 'PREFIX ex: <http://example.org/> SELECT ?s ?p ?o FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1704153600] WHERE { WINDOW ex:histWindow { ?s ?p ?o . } }'
481481
});
482482
console.log('Registered:', registerResponse.data);
483483

@@ -606,7 +606,7 @@ For a simple demo dashboard with "Start Replay" and "Start Query" buttons:
606606
headers: { 'Content-Type': 'application/json' },
607607
body: JSON.stringify({
608608
query_id: QUERY_ID,
609-
janusql: 'SELECT ?sensor ?temp FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-01-02T00:00:00Z] WHERE { ?sensor <http://example.org/temperature> ?temp . }'
609+
janusql: 'PREFIX ex: <http://example.org/> SELECT ?sensor ?temp FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1704153600] WHERE { WINDOW ex:histWindow { ?sensor ex:temperature ?temp . } }'
610610
})
611611
});
612612
@@ -844,4 +844,4 @@ Options:
844844

845845
For issues, feature requests, or questions:
846846
- GitHub Issues: https://github.com/SolidLabResearch/janus/issues
847-
- Documentation: https://github.com/SolidLabResearch/janus
847+
- Documentation: https://github.com/SolidLabResearch/janus

docs/HTTP_API_IMPLEMENTATION.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ Request:
7676
```json
7777
{
7878
"query_id": "sensor_query_1",
79-
"janusql": "SELECT ?sensor ?temp FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-01-02T00:00:00Z] WHERE { ?sensor <http://example.org/temperature> ?temp . }"
79+
"janusql": "PREFIX ex: <http://example.org/> SELECT ?sensor ?temp FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1704153600] WHERE { WINDOW ex:histWindow { ?sensor ex:temperature ?temp . } }"
8080
}
8181
```
8282

83-
Response (201):
83+
Response (200):
8484
```json
8585
{
8686
"query_id": "sensor_query_1",
@@ -322,7 +322,7 @@ const response = await fetch('http://localhost:8080/api/queries', {
322322
headers: { 'Content-Type': 'application/json' },
323323
body: JSON.stringify({
324324
query_id: 'my_query',
325-
janusql: 'SELECT ?s ?p ?o FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-12-31T23:59:59Z] WHERE { ?s ?p ?o }'
325+
janusql: 'PREFIX ex: <http://example.org/> SELECT ?s ?p ?o FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1735689599] WHERE { WINDOW ex:histWindow { ?s ?p ?o . } }'
326326
})
327327
});
328328

@@ -349,7 +349,7 @@ import json
349349
# Register query
350350
requests.post('http://localhost:8080/api/queries', json={
351351
'query_id': 'my_query',
352-
'janusql': 'SELECT ?s ?p ?o FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-12-31T23:59:59Z] WHERE { ?s ?p ?o }'
352+
'janusql': 'PREFIX ex: <http://example.org/> SELECT ?s ?p ?o FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1735689599] WHERE { WINDOW ex:histWindow { ?s ?p ?o . } }'
353353
})
354354

355355
# Start query
@@ -373,7 +373,7 @@ ws.run_forever()
373373
# Register
374374
curl -X POST http://localhost:8080/api/queries \
375375
-H "Content-Type: application/json" \
376-
-d '{"query_id": "test", "janusql": "SELECT ?s ?p ?o FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-12-31T23:59:59Z] WHERE { ?s ?p ?o }"}'
376+
-d '{"query_id": "test", "janusql": "PREFIX ex: <http://example.org/> SELECT ?s ?p ?o FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1735689599] WHERE { WINDOW ex:histWindow { ?s ?p ?o . } }"}'
377377

378378
# Start
379379
curl -X POST http://localhost:8080/api/queries/test/start
@@ -559,4 +559,4 @@ The Janus HTTP API is fully implemented and ready for use. It provides:
559559

560560
The implementation follows Rust best practices, uses modern async patterns, and integrates seamlessly with the existing Janus architecture.
561561

562-
**Ready for testing and integration with external dashboards and agents.**
562+
**Ready for testing and integration with external dashboards and agents.**

docs/MVP_TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ async fn main() {
836836
.route("/api/queries", post(register_query))
837837
.route("/api/queries", get(list_queries))
838838
.route("/api/queries/:id/start", post(start_query))
839-
.route("/api/queries/:id/stop", post(stop_query))
839+
.route("/api/queries/:id", delete(stop_query))
840840
.route("/api/queries/:id/results", get(query_results_ws))
841841
.layer(CorsLayer::permissive())
842842
.with_state(state);

docs/QUICKSTART_HTTP_API.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ curl -X POST http://localhost:8080/api/queries \
5656
-H "Content-Type: application/json" \
5757
-d '{
5858
"query_id": "test_query",
59-
"janusql": "SELECT ?s ?p ?o FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-12-31T23:59:59Z] WHERE { ?s ?p ?o }"
59+
"janusql": "PREFIX ex: <http://example.org/> SELECT ?s ?p ?o FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1735689599] WHERE { WINDOW ex:histWindow { ?s ?p ?o . } }"
6060
}'
6161
```
6262

@@ -187,7 +187,7 @@ curl http://localhost:8080/api/replay/status
187187
# 4. Register and start query
188188
curl -X POST http://localhost:8080/api/queries \
189189
-H "Content-Type: application/json" \
190-
-d '{"query_id": "analysis", "janusql": "SELECT ?sensor ?temp FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-12-31T23:59:59Z] WHERE { ?sensor <http://example.org/temperature> ?temp . FILTER(?temp > 25.0) }"}'
190+
-d '{"query_id": "analysis", "janusql": "PREFIX ex: <http://example.org/> SELECT ?sensor ?temp FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1735689599] WHERE { WINDOW ex:histWindow { ?sensor ex:temperature ?temp . FILTER(?temp > 25.0) } }"}'
191191

192192
curl -X POST http://localhost:8080/api/queries/analysis/start
193193

@@ -200,7 +200,7 @@ curl -X POST http://localhost:8080/api/queries/analysis/start
200200
# 1. Register live query
201201
curl -X POST http://localhost:8080/api/queries \
202202
-H "Content-Type: application/json" \
203-
-d '{"query_id": "live_monitor", "janusql": "SELECT ?sensor ?temp FROM LIVE SLIDING WINDOW sensors [RANGE PT10S, SLIDE PT5S] WHERE { ?sensor <http://example.org/temperature> ?temp . }"}'
203+
-d '{"query_id": "live_monitor", "janusql": "PREFIX ex: <http://example.org/> SELECT ?sensor ?temp FROM NAMED WINDOW ex:liveWindow ON STREAM ex:sensorStream [RANGE 10000 STEP 5000] WHERE { WINDOW ex:liveWindow { ?sensor ex:temperature ?temp . } }"}'
204204

205205
# 2. Start query (before replay to catch all events)
206206
curl -X POST http://localhost:8080/api/queries/live_monitor/start
@@ -218,7 +218,7 @@ curl -X POST http://localhost:8080/api/replay/start \
218218
# Register hybrid query
219219
curl -X POST http://localhost:8080/api/queries \
220220
-H "Content-Type: application/json" \
221-
-d '{"query_id": "hybrid", "janusql": "SELECT ?s ?p ?o FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-01-02T00:00:00Z] FROM LIVE SLIDING WINDOW stream [RANGE PT30S, SLIDE PT10S] WHERE { ?s ?p ?o }"}'
221+
-d '{"query_id": "hybrid", "janusql": "PREFIX ex: <http://example.org/> REGISTER RStream ex:output AS SELECT ?s ?p ?o FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1704153600] FROM NAMED WINDOW ex:liveWindow ON STREAM ex:sensorStream [RANGE 30000 STEP 10000] WHERE { WINDOW ex:histWindow { ?s ?p ?o . } WINDOW ex:liveWindow { ?s ?p ?o . } }"}'
222222

223223
# Start replay first to populate historical data
224224
curl -X POST http://localhost:8080/api/replay/start \
@@ -282,4 +282,4 @@ If you need test data, create `data/sensors.nq`:
282282
## Support
283283

284284
- GitHub Issues: https://github.com/SolidLabResearch/janus/issues
285-
- Documentation: See `HTTP_API.md` for complete API reference
285+
- Documentation: See `HTTP_API.md` for complete API reference

examples/http_client_example.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
109109
let query_request = RegisterQueryRequest {
110110
query_id: "sensor_query_1".to_string(),
111111
janusql: r#"
112+
PREFIX ex: <http://example.org/>
112113
SELECT ?sensor ?temp ?time
113-
FROM HISTORICAL FIXED WINDOW [2024-01-01T00:00:00Z, 2024-01-02T00:00:00Z]
114+
FROM NAMED WINDOW ex:histWindow ON STREAM ex:sensorStream [START 1704067200 END 1704153600]
114115
WHERE {
115-
?sensor <http://example.org/temperature> ?temp .
116-
?sensor <http://example.org/timestamp> ?time .
116+
WINDOW ex:histWindow {
117+
?sensor ex:temperature ?temp .
118+
?sensor ex:timestamp ?time .
119+
}
117120
}
118121
"#
119122
.to_string(),
@@ -141,11 +144,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
141144
let live_query_request = RegisterQueryRequest {
142145
query_id: "live_sensor_query".to_string(),
143146
janusql: r#"
147+
PREFIX ex: <http://example.org/>
144148
SELECT ?sensor ?temp
145-
FROM LIVE SLIDING WINDOW sensors [RANGE PT10S, SLIDE PT5S]
149+
FROM NAMED WINDOW ex:liveWindow ON STREAM ex:sensorStream [RANGE 10000 STEP 5000]
146150
WHERE {
147-
?sensor <http://example.org/temperature> ?temp .
148-
FILTER(?temp > 25.0)
151+
WINDOW ex:liveWindow {
152+
?sensor ex:temperature ?temp .
153+
FILTER(?temp > 25.0)
154+
}
149155
}
150156
"#
151157
.to_string(),

0 commit comments

Comments
 (0)