-
Notifications
You must be signed in to change notification settings - Fork 0
Add LICENSE, AGENTS.md, and richer package metadata #1
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # AGENTS.md — uapi-browser-sdk | ||
|
|
||
| This file tells AI coding agents how to use the **official browser / | ||
| vanilla-JS SDK** for the [uapis.cn](https://uapis.cn) public API platform. | ||
|
|
||
| ## What this package is | ||
|
|
||
| Browser-first, dependency-free TypeScript client for UAPI. Built on the | ||
| native `fetch` API, ships an ESM bundle, and works equally well from a | ||
| `<script type="module">` tag, a Vite/Next/Remix project, or a Cloudflare | ||
| Worker. Generated from the live OpenAPI 3.1 spec at | ||
| <https://uapis.cn/openapi.json>. | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| npm i uapi-browser-sdk | ||
| # or with pnpm / yarn | ||
| ``` | ||
|
|
||
| CDN: | ||
|
|
||
| ```html | ||
| <script type="module"> | ||
| import { UapiClient } from "https://esm.sh/uapi-browser-sdk"; | ||
| const client = new UapiClient("https://uapis.cn"); | ||
| console.log(await client.misc.getMiscWeather({ city: "北京" })); | ||
| </script> | ||
| ``` | ||
|
|
||
| ## Quick start | ||
|
|
||
| ```ts | ||
| import { UapiClient } from "uapi-browser-sdk"; | ||
|
|
||
| const client = new UapiClient("https://uapis.cn"); | ||
| const weather = await client.misc.getMiscWeather({ city: "北京" }); | ||
| console.log(weather); | ||
| ``` | ||
|
|
||
| The client is grouped by tag (`misc`, `network`, `text`, `image`, `social`, | ||
| `translate`, `search`, …) and each method name matches the underlying | ||
| `operationId`, camelCased. | ||
|
|
||
| ## Authentication | ||
|
|
||
| Free-tier endpoints work with no key. Paid endpoints take a key: | ||
|
|
||
| ```ts | ||
| const client = new UapiClient("https://uapis.cn", { apiKey: "sk_…" }); | ||
| ``` | ||
|
|
||
| > **Warning.** Putting an API key inside a public web page exposes it to | ||
| > anyone who reads the JS bundle. For browser-side calls to paid | ||
| > endpoints, prefer a thin server-side proxy that injects the key. | ||
|
|
||
| ## Errors | ||
|
|
||
| Methods throw a typed `UapiApiError` on non-2xx responses. The error | ||
| carries `code`, `error`, and `requestId` fields. Surface `error` verbatim. | ||
|
|
||
| ## Rate limits | ||
|
|
||
| Headers `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`, | ||
| `Retry-After` are exposed via `error.response.headers` (and on success | ||
| responses via the optional `withResponse` overload). Honor them. | ||
|
Comment on lines
+59
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Code written from this guidance will not compile or will fail at runtime: the package exports Useful? React with 👍 / 👎. |
||
|
|
||
| ## Related repos | ||
|
|
||
| - Server-side TS SDK: <https://github.com/AxT-Team/uapi-sdk-typescript>. | ||
| - MCP server: <https://github.com/AxT-Team/uapi-mcp>. | ||
| - Skills bundle: <https://github.com/AxT-Team/uapi-agent-skills>. | ||
| - Other languages: `uapi-sdk-python`, `uapi-sdk-go`, `uapi-sdk-rust`, | ||
| `uapi-sdk-java`, `uapi-sdk-csharp`, `uapi-sdk-cpp`, `uapi-sdk-php`. | ||
| 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. |
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.
When agents follow this auth example, the SDK silently ignores the key because
UapiClientOptionsonly supportsdisableCacheand the constructor only treats a string second argument as the bearer token (src/index.ts:1497-1501). Calls to paid endpoints therefore go out unauthenticated; the existing README usesnew UapiClient(baseURL, 'YOUR_API_KEY'), so this example should use the string token form or add realapiKeysupport.Useful? React with 👍 / 👎.