Blame
6874e1 | Hargata Softworks | 2024-01-29 01:25:19 | 1 | # API |
2 | ||||
640330 | Hargata Softworks | 2024-02-09 22:02:40 | 3 | LubeLogger provides API endpoints to retrieve and add records, full documentation of these endpoints can be found at `/api`. |
6874e1 | Hargata Softworks | 2024-01-29 01:25:19 | 4 | |
5 | ## Authentication | |||
6 | If authentication is enabled, it implements Basic Auth based on RFC2617, which stipulates that the "token" is passed in as a Base64-encoded string comprising of a username and password separated by a colon(":"). Because of this, neither the username nor password can contain a colon(":") character. | |||
7 | ||||
0878ff | Hargata Softworks | 2025-02-03 16:42:35 | 8 | ### In-line URL Authorization |
9 | In-line authorization is supported as of 1.4.3 as it is necessary for authorization for the calendar endpoint. Use it as so: | |||
10 | ||||
d0c66f | Hargata Softworks | 2025-02-03 16:43:13 | 11 | `https://username:password@lubeloggerdomain/api/endpoint` |
12 | ||||
13 | For the calendar endpoint, it will look something like this: | |||
14 | ||||
15 | `https://test:1234@demo.lubelogger.com/api/calendar` | |||
0878ff | Hargata Softworks | 2025-02-03 16:42:35 | 16 | |
c74580 | Hargata Softworks | 2024-12-31 15:52:38 | 17 | ## POST/PUT Encoding |
18 | As of 1.4.2, LubeLogger supports bodies in both form-data, x-www-form-urlencoded, and JSON format. | |||
19 | ||||
20 | Note that form-data and x-www-form-urlencoded will always convert any data into strings even if you are passing in a number. Post bodies in JSON if you wish to pass in numbers and integers. | |||
21 | ||||
22 | ## Locale-Invariant Formatting | |||
23 | By default, LubeLogger will return all data as strings for GET methods and it is locale-sensitive: | |||
24 | ||||
25 |  | |||
26 | ||||
27 | Note the date and decimal formatting. | |||
28 | ||||
29 | If you wish for locale invariant and type-rich formatting(numbers are returned as numbers instead of string), you can either inject the following environment variable: | |||
30 | ||||
31 | `LUBELOGGER_INVARIANT_API=true` | |||
32 | ||||
33 | Or add the following Header Key in your API request: | |||
34 | ||||
35 | `culture-invariant` | |||
36 | ||||
37 | No values are needed, the presence of the key is sufficient for LubeLogger to format the API response: | |||
38 | ||||
39 |  | |||
40 | ||||
368fc6 | Hargata Softworks | 2024-12-31 15:53:21 | 41 | ## Testing |
6874e1 | Hargata Softworks | 2024-01-29 01:25:19 | 42 | You can utilize any REST API testing tool to test your use-case. |
43 | ||||
3d05a7 | Hargata Softworks | 2024-12-10 15:18:18 | 44 | [Postman Collection](https://github.com/hargata/lubelog_scripts/blob/main/misc/LubeLogger.postman_collection.json) |
45 | ||||
6874e1 | Hargata Softworks | 2024-01-29 01:25:19 | 46 | ## Example Use Cases |
47 | - Send Email Reminders, see [[Reminders|Records/Reminders#reminder-emails]] | |||
48 | - Insert Odometer Records, see [[Odometer|Records/Odometer#api-integration]] | |||
3df82f | Hargata Softworks | 2024-04-19 03:21:58 | 49 | - Create DB Backups, [Example BASH Script](https://github.com/hargata/lubelog_scripts/blob/main/bash/makebackup.sh) [Example DOS Script](https://github.com/hargata/lubelog_scripts/blob/main/dos/makebackup.bat) |