Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -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
<https://uapis.cn/openapi.json>, 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{
Comment on lines +33 to +34
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Correct the quick-start API calls

The quick-start uses symbols that do not exist in this SDK: the public constructor is uapi.New(baseURL, token), the group accessor is client.Misc(), and GetMiscWeather takes a map[string]any rather than a context plus GetMiscWeatherRequest (checked in uapi/client.go). Any agent following this newly added AGENTS.md snippet will generate code that fails to compile for the basic weather example.

Useful? React with 👍 / 👎.

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 <https://uapis.cn/openapi.json>. The
`operationId` maps directly to a Go method (`get-misc-weather` →
`client.Misc.GetMiscWeather`).

## 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-python`, `uapi-sdk-rust`,
`uapi-sdk-java`, `uapi-sdk-csharp`, `uapi-sdk-cpp`, `uapi-sdk-php`.
21 changes: 21 additions & 0 deletions LICENSE
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.
Loading