## Official CLI App There's an official CLI app for Linux. It's maintained by me, even though I cannot promise to provide proper support. Take a look at it [here](https://github.com/SinTan1729/chhoto-url-cli). The instructions below describe how to use all the features using `curl`. ## Instructions for CLI usage The application can be used from the terminal using something like `curl`. In all the examples below, replace `http://localhost:4567` with where your instance of `chhoto-url` is accessible. You can get the version of `chhoto-url` the server is running using `curl http://localhost:4567/api/version` and get the siteurl using `curl http://localhost:4567/api/siteurl`. These routes are accessible without any authentication. ### API key validation **This is required for programs that rely on a JSON response from Chhoto URL.** In order to use API key validation, set the [`CHHOTO_API_KEY`](./INSTALLATION.md#chhoto_api_key) environment variable. If this is not set, the API will default to cookie validation (see section above). If the API key is insecure, a warning will be outputted along with a generated API key which may be used. **All responses for requests using API key are JSON encoded.** Example Linux command for generating a secure API key: `tr -dc A-Za-z0-9 < /dev/urandom | head -c 128` For each response, the response code will be `200`, `401`, `400`, `500`, or `404`, depending on the context. The routes are as follows. ## Note Some of the requests/responses use `shorturl` and `longurl`, while some use `shortlink` and `longlink`. This is due to my own lack of foresight while developing the initial API. I don't want to change it since it might break compatibility, and the issue isn't big enough to make that worth it. So please be careful if you use the API. #### `/api/new` To add a link: ```bash curl -X POST \ -H "X-API-Key: " \ -d '{ \ "shortlink":"", \ "longlink":"", \ "expiry_delay": , \ "notes": "" \ }' \ http://localhost:4567/api/new ``` If `` is empty or omitted, one will be generated automatically. The `` is specified in seconds. It is capped to a maximum of 5 years. A missing `` or a value of 0 will disable expiry. The server will reply in the following format. ```json { "success": true, "error": false, "shorturl": "", "expiry_time": } ``` or ```json { "success": false, "error": true, "reason": "" } ``` Multiple links can be created in a single request by sending an array of objects like the example below. ```bash curl -X POST \ -H "X-API-Key: " \ -d '[ \ { \ "shortlink":"", \ "longlink":"", \ "expiry_delay": , \ "notes": "" \ }' \ , { \ "shortlink":"", \ "longlink":"", \ "expiry_delay": , \ "notes": "" \ }' \ ... ... ] \ http://localhost:4567/api/new ``` In that case, the response is an array containing one result per input object (in order), each in one of the formats shown above. Except for malformed requests or internal server errors, the HTTP status code is always `200`. Clients must inspect the `success` field of each response object to determine whether the operation succeeded. #### `/api/getconfig` To get the config for the backend: ```bash curl -H "X-API-Key: " \ -d '' http://localhost:4567/api/getconfig ``` (This would work without authentication in public mode.) The server will reply in the following format. ```json { "version": "", "site_url": "", "allow_capital_letters": true/false, "public_mode": true/false, "public_mode_expiry_delay": "", "slug_style": "