diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..995be98 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,78 @@ +# AGENTS.md — uapi-sdk-go + +This file tells AI coding agents how to use the **official Go SDK** for the +[uapis.cn](https://uapis.cn) public API platform. + +## What this package is + +Idiomatic Go client for UAPI. Generated from the live OpenAPI 3.1 spec at +, so the method list, parameter shapes, and +return types stay in lock-step with the real API. + +```bash +go get github.com/AxT-Team/uapi-sdk-go@latest +``` + +## Quick start + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/AxT-Team/uapi-sdk-go/uapi" +) + +func main() { + ctx := context.Background() + + // Free-tier endpoints don't need an API key + client := uapi.NewClient("https://uapis.cn") + weather, err := client.Misc.GetMiscWeather(ctx, &uapi.GetMiscWeatherRequest{ + City: "北京", + }) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", weather) +} +``` + +The client is grouped by tag (`Misc`, `Network`, `Text`, `Image`, `Social`, +`Translate`, `Search`, …). Method names match the OpenAPI `operationId`. + +## Authentication + +Free-tier endpoints work with no key. Paid endpoints take a key: + +```go +client := uapi.NewClient("https://uapis.cn", uapi.WithAPIKey("sk_…")) +``` + +## Errors + +Every method returns `(response, error)`. On non-2xx, `error` is a +`*uapi.APIError` with `Code`, `Success`, `Error`, and `RequestID`. Surface +`err.Error` verbatim; do not retry on `400` or `401`. + +## Rate limits + +Headers `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`, +`Retry-After` are exposed via `uapi.RateLimitFrom(resp)`. Honor them — back +off on `429` and obey `Retry-After`. + +## Discovery + +For unknown endpoints, fetch . The +`operationId` maps directly to a Go method (`get-misc-weather` → +`client.Misc.GetMiscWeather`). + +## Related repos + +- MCP server: — same endpoints as MCP tools. +- Skills bundle: . +- Other languages: `uapi-sdk-typescript`, `uapi-sdk-python`, `uapi-sdk-rust`, + `uapi-sdk-java`, `uapi-sdk-csharp`, `uapi-sdk-cpp`, `uapi-sdk-php`. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4e7b5fa --- /dev/null +++ b/LICENSE @@ -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.