-
Notifications
You must be signed in to change notification settings - Fork 0
Add LICENSE, AGENTS.md, and richer package.json metadata #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # AGENTS.md — uapi-sdk-typescript | ||
|
|
||
| This file tells AI coding agents how to use the **official TypeScript / | ||
| Node.js SDK** for the [uapis.cn](https://uapis.cn) public API platform. | ||
|
|
||
| ## What this package is | ||
|
|
||
| Strongly-typed Node / browser-compatible client for UAPI. Generated from the | ||
| live OpenAPI 3.1 spec at <https://uapis.cn/openapi.json> — so the method | ||
| list, parameter shapes, and return types stay in lock-step with the real | ||
| API. | ||
|
|
||
| ```bash | ||
| npm i uapi-sdk-typescript | ||
| # or | ||
| pnpm add uapi-sdk-typescript | ||
| # or | ||
| yarn add uapi-sdk-typescript | ||
| ``` | ||
|
|
||
| ## Quick start | ||
|
|
||
| ```ts | ||
| import { UapiClient } from "uapi-sdk-typescript"; | ||
|
|
||
| // Free-tier endpoints don't need an API key | ||
| const client = new UapiClient("https://uapis.cn"); | ||
|
|
||
| const weather = await client.misc.getMiscWeather({ city: "北京" }); | ||
| console.log(weather); | ||
|
|
||
| // Paid endpoints take a key | ||
| const paid = new UapiClient("https://uapis.cn", process.env.UAPI_KEY!); | ||
| const ocr = await paid.image.postImageOcr({ url: "https://…/photo.png" }); | ||
| ``` | ||
|
|
||
| The client is grouped by tag (`misc`, `network`, `text`, `image`, `social`, | ||
| `translate`, `search`, …) and each method name matches the underlying | ||
| `operationId` from the OpenAPI spec. | ||
|
|
||
| ## Discovery | ||
|
|
||
| When generating code, agents should: | ||
|
|
||
| 1. Pull the spec from <https://uapis.cn/openapi.json> if the schema you need | ||
| isn't already in your local types. | ||
| 2. Map the operation's `operationId` to a SDK method (`get-misc-weather` → | ||
| `client.misc.getMiscWeather`). | ||
| 3. Pass the request parameters as a single object — query params, path | ||
| params, and body all live there. | ||
|
|
||
| ## Authentication | ||
|
|
||
| - Many UAPI endpoints (network, text, random, convert, weather, time, | ||
| hotboard) work with no key. | ||
| - Paid endpoints want `X-API-Key`. The SDK forwards the second | ||
| `UapiClient` constructor argument to that header. | ||
| - For human-in-the-loop OAuth flows, see | ||
| <https://uapis.cn/.well-known/oauth-authorization-server>. | ||
|
|
||
| ## Errors | ||
|
|
||
| Every method throws an `AxiosError`-shaped error on non-2xx responses. The | ||
| error body is a JSON object: `{code, success: false, error, request_id?}`. | ||
| Surface the `error` text verbatim. | ||
|
|
||
| ## Rate limits | ||
|
|
||
| Headers `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`, | ||
| `Retry-After` are returned on every response. Honor them — back off on | ||
| `429` and obey `Retry-After`. | ||
|
|
||
| ## Related repos | ||
|
|
||
| - MCP server: <https://github.com/AxT-Team/uapi-mcp> — same endpoints as MCP tools. | ||
| - Skills bundle: <https://github.com/AxT-Team/uapi-agent-skills> — markdown | ||
| skills for AI agents that prefer SKILL-driven workflows. | ||
| - Browser-only SDK: <https://github.com/AxT-Team/uapi-browser-sdk>. | ||
| - Other languages: `uapi-sdk-python`, `uapi-sdk-go`, `uapi-sdk-rust`, | ||
| `uapi-sdk-java`, `uapi-sdk-csharp`, `uapi-sdk-cpp`, `uapi-sdk-php`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2025 AxT-Team / UAPI | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For non-2xx responses this SDK does not expose an AxiosError-shaped object:
HTTP.requestcatches Axios responses, maps them withmapError, and throws aUapiErrorsubclass withcode,status,details,payload, andmeta. Agents following this guidance will generate handlers that read Axios fields likeerror.response.data, which are absent on the thrown SDK errors and will lose the real API error details.Useful? React with 👍 / 👎.