Rebuilding LWT's API, part 2

Hi there! Much work has been done and the new LWT REST API is now ready! For records, the initial suggestion, formatted with the help of ChatGPT, looked like the following (see part 1 for details): 1. GET API Endpoints: - Get API Version: `GET /api/version` - Get Next Word to Test: `GET /api/test/next-word` - Get Tomorrow's Tests Number: `GET /api/test/tomorrow` - Get Phonetic Reading: `GET /api/text/phonetic-reading` - Get Theming Path: `GET /api/text/theme-path` - Get Texts Statistics: `GET /api/text/statistics` - Get Media Paths: `GET /api/media/paths` - Get Example Sentences: `GET /api/sentences/{word}` - Get Imported Terms: `GET /api/terms/imported` - Get Similar Terms: `GET /api/terms/{term}/similar` - Get Term Translations: `GET /api/terms/{term}/translations` 2. POST API Endpoints: - Update Reading Position: `POST /api/reading/position` - Add/Update Translation: `POST /api/translation/{word}` - Increment/Decrement Term Status: `POST /api/terms/{term}/status` - Set Term Status: `POST /api/terms/{term}/status/set` - Test Regular Expression: `POST /api/regexp/test` - Set Term Annotation: `POST /api/terms/{term}/annotation` - Save Setting: `POST /api/settings` It featured 11 endpoints on GET and 7 on POST. The key of this approach was it was not a fundamental change but rather a reorganization of the already existing AJAX requests. In fact, GPT do not have access to all the app information, as most endpoints are simply a simplification of the explanation sentence, and were sometimes optimistic or simply wrong: for instance GET /api/text/statistics, how are we supposed to know that we get statistics for a subset of texts here? ...

January 5, 2024 · 4 min · admin

Rebuilding LWT's API, part 1

Hey everyone, for the next release of LWT I have been working on a complete refactor of the AJAX API that will enhance both security and the development for the future versions of LWT! The Issue A glance at all the different AJAX files composing LWT before unification. As LWT was growing, so were the AJAX calls and without any control. In the end, LWT as of 2.8.0 harbored a collection of PHP files with different formats and standards, making the API difficult to expand and to understand. ...

December 21, 2023 · 3 min · admin