[PR #13422] [CLOSED] refactor: integrate Axios for API client and enhance API structure #110509

Closed
opened 2026-05-18 10:07:56 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/13422
Author: @dasein108
Created: 5/2/2025
Status: Closed

Base: devHead: dev


📝 Commits (4)

  • ac01628 feat: integrate Axios for API client and enhance API structure
  • 45604d3 adjust error handling pattern
  • cd0cc12 Remove console log from Axios response interceptor for cleaner error handling
  • c40a738 missing user api methid

📊 Changes

29 files changed (+2524 additions, -8909 deletions)

View changed files

📝 package-lock.json (+464 -184)
📝 package.json (+2 -0)
src/lib/apis/apiClient.ts (+98 -0)
📝 src/lib/apis/audio/index.ts (+21 -172)
📝 src/lib/apis/auths/index.ts (+162 -694)
src/lib/apis/axios.ts (+63 -0)
📝 src/lib/apis/channels/index.ts (+85 -412)
📝 src/lib/apis/chats/index.ts (+87 -1013)
src/lib/apis/clients.ts (+19 -0)
📝 src/lib/apis/configs/index.ts (+87 -397)
📝 src/lib/apis/evaluations/index.ts (+27 -236)
📝 src/lib/apis/files/index.ts (+22 -231)
📝 src/lib/apis/folders/index.ts (+28 -257)
📝 src/lib/apis/functions/index.ts (+45 -439)
📝 src/lib/apis/groups/index.ts (+33 -162)
📝 src/lib/apis/images/index.ts (+60 -230)
📝 src/lib/apis/index.ts (+527 -1243)
📝 src/lib/apis/knowledge/index.ts (+53 -337)
📝 src/lib/apis/memories/index.ts (+18 -179)
📝 src/lib/apis/models/index.ts (+21 -256)

...and 9 more files

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests to validate the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

  • Implemented ApiClient class for structured API calls in apiClient.ts.
  • Created various API client instances for different services in clients.ts.
  • Refactored existing API functions to utilize the new ApiClient structure.
  • Updated package dependencies to include Axios version 1.9.0 and added type definitions for file-saver.
  • Improved error handling and logging across API calls for better debugging.

Description

  • Refactored the /apis domain to follow DRY and SOLID principles by replacing duplicated code with modular Axios instances scoped to each API domain. Implemented built-in authentication and standardized error handling. Introduced TypeScript definitions based on the backend API schema to ensure type safety and consistency across the entire frontend codebase.

Added

  • Added Axios instance creation for API requests in axios.ts.
  • Implemented ApiClient class for structured API calls in apiClient.ts.
  • Created various API client instances for different services in clients.ts.
  • TypeScript definitions to reflect backend api schema

Changed

  • Refactored existing API functions to utilize the new ApiClient structure inside /apis domain.
  • Improved error handling and logging across API calls for better debugging.

Additional Information

  • token propagation can incaplulated inside axious interceptor and fully removed from out of this code

  • This commit marks the initial step in modernizing a codebase heavily burdened with legacy patterns, duplicated logic, and numerous linter warnings/errors. It lays the foundation for further refactoring aimed at improving maintainability, readability, and compatibility with AI-assisted development tools.

  • Over 6,500 lines of redundant or outdated code were removed with careful consideration to preserve existing behavior, though full end-to-end testing is still necessary.

  • Upcoming refactoring goals:

    • WebSocket functionality overhaul

    • DRY refactor of LLM interaction layers

    • Native integration of tool support for OpenAI/Anthropic models

Screenshots or Videos

  • [Attach any relevant screenshots or videos demonstrating the changes]

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the CONTRIBUTOR_LICENSE_AGREEMENT, and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/13422 **Author:** [@dasein108](https://github.com/dasein108) **Created:** 5/2/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (4) - [`ac01628`](https://github.com/open-webui/open-webui/commit/ac016282030c8000dfd5fc36fded952859ac42e3) feat: integrate Axios for API client and enhance API structure - [`45604d3`](https://github.com/open-webui/open-webui/commit/45604d374b4c7571c56469466da48f996085b4f2) adjust error handling pattern - [`cd0cc12`](https://github.com/open-webui/open-webui/commit/cd0cc124676eb7a839e57aa6ae40cb957e65fe15) Remove console log from Axios response interceptor for cleaner error handling - [`c40a738`](https://github.com/open-webui/open-webui/commit/c40a73861d79568a1d1cded9c0958e8c8ffb4d34) missing user api methid ### 📊 Changes **29 files changed** (+2524 additions, -8909 deletions) <details> <summary>View changed files</summary> 📝 `package-lock.json` (+464 -184) 📝 `package.json` (+2 -0) ➕ `src/lib/apis/apiClient.ts` (+98 -0) 📝 `src/lib/apis/audio/index.ts` (+21 -172) 📝 `src/lib/apis/auths/index.ts` (+162 -694) ➕ `src/lib/apis/axios.ts` (+63 -0) 📝 `src/lib/apis/channels/index.ts` (+85 -412) 📝 `src/lib/apis/chats/index.ts` (+87 -1013) ➕ `src/lib/apis/clients.ts` (+19 -0) 📝 `src/lib/apis/configs/index.ts` (+87 -397) 📝 `src/lib/apis/evaluations/index.ts` (+27 -236) 📝 `src/lib/apis/files/index.ts` (+22 -231) 📝 `src/lib/apis/folders/index.ts` (+28 -257) 📝 `src/lib/apis/functions/index.ts` (+45 -439) 📝 `src/lib/apis/groups/index.ts` (+33 -162) 📝 `src/lib/apis/images/index.ts` (+60 -230) 📝 `src/lib/apis/index.ts` (+527 -1243) 📝 `src/lib/apis/knowledge/index.ts` (+53 -337) 📝 `src/lib/apis/memories/index.ts` (+18 -179) 📝 `src/lib/apis/models/index.ts` (+21 -256) _...and 9 more files_ </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests to validate the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry - Implemented `ApiClient` class for structured API calls in `apiClient.ts`. - Created various API client instances for different services in `clients.ts`. - Refactored existing API functions to utilize the new `ApiClient` structure. - Updated package dependencies to include Axios version 1.9.0 and added type definitions for file-saver. - Improved error handling and logging across API calls for better debugging. ### Description - Refactored the /apis domain to follow DRY and SOLID principles by replacing duplicated code with modular Axios instances scoped to each API domain. Implemented built-in authentication and standardized error handling. Introduced TypeScript definitions based on the backend API schema to ensure type safety and consistency across the entire frontend codebase. ### Added - Added Axios instance creation for API requests in `axios.ts`. - Implemented `ApiClient` class for structured API calls in `apiClient.ts`. - Created various API client instances for different services in `clients.ts`. - TypeScript definitions to reflect backend api schema ### Changed - Refactored existing API functions to utilize the new `ApiClient` structure inside `/apis` domain. - Improved error handling and logging across API calls for better debugging. --- ### Additional Information - token propagation can incaplulated inside axious interceptor and fully removed from out of this code - This commit marks the initial step in modernizing a codebase heavily burdened with legacy patterns, duplicated logic, and numerous linter warnings/errors. It lays the foundation for further refactoring aimed at improving maintainability, readability, and compatibility with AI-assisted development tools. - Over 6,500 lines of redundant or outdated code were removed with careful consideration to preserve existing behavior, though **full end-to-end testing is still necessary.** - Upcoming refactoring goals: - WebSocket functionality overhaul - DRY refactor of LLM interaction layers - Native integration of tool support for OpenAI/Anthropic models ### Screenshots or Videos - [Attach any relevant screenshots or videos demonstrating the changes] ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [CONTRIBUTOR_LICENSE_AGREEMENT](CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-18 10:07:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#110509