-
Notifications
You must be signed in to change notification settings - Fork 0
Add LICENSE, AGENTS.md, and richer pyproject.toml 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
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,92 @@ | ||
| # AGENTS.md — uapi-sdk-python | ||
|
|
||
| This file tells AI coding agents how to use the **official Python SDK** for | ||
| the [uapis.cn](https://uapis.cn) public API platform. | ||
|
|
||
| ## What this package is | ||
|
|
||
| Strongly-typed Python client for UAPI. Generated from the live OpenAPI 3.1 | ||
| spec at <https://uapis.cn/openapi.json> — method names, parameter shapes, | ||
| and return types stay in lock-step with the real API. | ||
|
|
||
| ```bash | ||
| pip install uapi-sdk-python | ||
| # or, with uv | ||
| uv add uapi-sdk-python | ||
| # or, with poetry | ||
| poetry add uapi-sdk-python | ||
| ``` | ||
|
|
||
| ## Quick start | ||
|
|
||
| ```python | ||
| from uapi import UapiClient | ||
|
|
||
| # Free-tier endpoints don't need an API key | ||
| client = UapiClient(base_url="https://uapis.cn") | ||
| weather = client.misc.get_misc_weather(city="北京") | ||
| print(weather) | ||
|
|
||
| # Paid endpoints take a key | ||
| import os | ||
| paid = UapiClient(base_url="https://uapis.cn", api_key=os.environ["UAPI_KEY"]) | ||
| ocr = paid.image.post_image_ocr(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, snake-cased. | ||
|
|
||
| ## Discovery | ||
|
|
||
| When generating code, agents should: | ||
|
|
||
| 1. Pull the spec from <https://uapis.cn/openapi.json> if you need a schema | ||
| that isn't in the local types yet. | ||
| 2. Map the operation's `operationId` to a SDK method (`get-misc-weather` → | ||
| `client.misc.get_misc_weather`). | ||
| 3. Pass the request parameters as keyword arguments. | ||
|
|
||
| ## 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 `api_key` | ||
| constructor argument to that header. | ||
| - For human-in-the-loop OAuth flows, see | ||
| <https://uapis.cn/.well-known/oauth-authorization-server>. | ||
|
|
||
| ## Errors | ||
|
|
||
| Every method raises a typed `UapiError` (subclass of `httpx.HTTPStatusError`) | ||
|
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.
This states that Useful? React with 👍 / 👎. |
||
| 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`. | ||
|
|
||
| ## Async | ||
|
|
||
| The SDK is built on `httpx`, so an async client is also available: | ||
|
|
||
| ```python | ||
| import asyncio | ||
| from uapi import AsyncUapiClient | ||
|
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.
This async example imports Useful? React with 👍 / 👎. |
||
|
|
||
| async def main(): | ||
| async with AsyncUapiClient(base_url="https://uapis.cn") as client: | ||
| return await client.misc.get_misc_weather(city="上海") | ||
|
|
||
| print(asyncio.run(main())) | ||
| ``` | ||
|
|
||
| ## 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>. | ||
| - Other languages: `uapi-sdk-typescript`, `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.
For paid-endpoint examples, this constructor call will fail because
UapiClient.__init__acceptstoken, notapi_key, and the implementation sends it asAuthorization: Bearer ...rather thanX-API-Key(uapi/client.pylines 98-99 and 120-125). Agents following this new quick start will getTypeError: unexpected keyword argument 'api_key'before making any request.Useful? React with 👍 / 👎.