From 20c480a914c1daadde466b39c2f1d20a25556f57 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 21 May 2020 10:48:04 -0700 Subject: [PATCH] ;web: tweak JSON PUT doc --- hledger-web/hledger-web.m4.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hledger-web/hledger-web.m4.md b/hledger-web/hledger-web.m4.md index 6fd2549d2..faa9a1791 100644 --- a/hledger-web/hledger-web.m4.md +++ b/hledger-web/hledger-web.m4.md @@ -203,9 +203,12 @@ sure that both machine clocks are roughly in step.) # JSON API -In addition to the web UI, hledger-web provides some API routes that -serve JSON in response to GET requests. (And when started with `--serve-api`, -it provides only these routes.): +In addition to the web UI, hledger-web also serves a JSON API that can be +used to get data or add new transactions. +If you only want the JSON API, run with the `--serve-api` flag. + +You can GET JSON data from these routes: + ``` /accountnames /transactions @@ -215,13 +218,13 @@ it provides only these routes.): /accounttransactions/#AccountName ``` -Also, you can append a new transaction to the journal by sending a PUT request to `/add` (hledger-web only). -As with the web UI's add form, hledger-web must be started with the `add` capability for this (enabled by default). +And you can add a new transaction to the journal with a PUT request to `/add`, +if hledger-web was started with the `add` capability (enabled by default). -Note the payload must be the full exact JSON representation of a hledger transaction -(partial JSON won't do). -You can download some sample JSON from `/transactions` or `/accounttransactions`, -or export it using hledger-lib's `writeJsonFile` helper (there's also `readJsonFile` for testing): +The payload must be the full, exact JSON representation of a hledger transaction +(partial data won't do). +You can get sample JSON from `/transactions` or `/accounttransactions`, +or you can export it with hledger-lib's `writeJsonFile` helper, like so: ```shell $ make ghci-web @@ -339,9 +342,6 @@ And here's how to test adding it with curl. This should add a new entry to your $ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json ``` -By default, both the server-side HTML UI and the JSON API are served. -Running with `--serve-api` disables the former, useful if you only want to serve the API. - # ENVIRONMENT _LEDGER_FILE_