|
| 1 | +# AGENTS.md — uapi-sdk-java |
| 2 | + |
| 3 | +This file tells AI coding agents how to use the **official Java SDK** for |
| 4 | +the [uapis.cn](https://uapis.cn) public API platform. |
| 5 | + |
| 6 | +## What this artifact is |
| 7 | + |
| 8 | +Idiomatic Java client for UAPI. Generated from the live OpenAPI 3.1 spec at |
| 9 | +<https://uapis.cn/openapi.json> — class names, method names, and parameter |
| 10 | +shapes track the real API. |
| 11 | + |
| 12 | +## Install |
| 13 | + |
| 14 | +Maven (`pom.xml`): |
| 15 | + |
| 16 | +```xml |
| 17 | +<dependency> |
| 18 | + <groupId>cn.uapis</groupId> |
| 19 | + <artifactId>uapi-sdk-java</artifactId> |
| 20 | + <version>0.1.17</version> |
| 21 | +</dependency> |
| 22 | +``` |
| 23 | + |
| 24 | +Gradle (`build.gradle.kts`): |
| 25 | + |
| 26 | +```kotlin |
| 27 | +implementation("cn.uapis:uapi-sdk-java:0.1.17") |
| 28 | +``` |
| 29 | + |
| 30 | +## Quick start |
| 31 | + |
| 32 | +```java |
| 33 | +import cn.uapis.UapiClient; |
| 34 | +import cn.uapis.api.MiscApi; |
| 35 | +import cn.uapis.model.GetMiscWeatherRequest; |
| 36 | + |
| 37 | +UapiClient client = new UapiClient("https://uapis.cn"); |
| 38 | +MiscApi misc = new MiscApi(client); |
| 39 | +var resp = misc.getMiscWeather(new GetMiscWeatherRequest().city("北京")); |
| 40 | +System.out.println(resp); |
| 41 | +``` |
| 42 | + |
| 43 | +The SDK is grouped by tag (`MiscApi`, `NetworkApi`, `TextApi`, `ImageApi`, |
| 44 | +`SocialApi`, `TranslateApi`, `SearchApi`, …). Method names match the |
| 45 | +OpenAPI `operationId`, camelCased. |
| 46 | + |
| 47 | +## Authentication |
| 48 | + |
| 49 | +Free-tier endpoints work with no key. Paid endpoints take a key: |
| 50 | + |
| 51 | +```java |
| 52 | +UapiClient client = new UapiClient("https://uapis.cn", "sk_…"); |
| 53 | +``` |
| 54 | + |
| 55 | +## Errors |
| 56 | + |
| 57 | +Methods throw `UapiApiException` (subclass of `IOException`) on non-2xx |
| 58 | +responses. The exception carries `code`, `error`, and `requestId` fields. |
| 59 | +Surface `error` verbatim. |
| 60 | + |
| 61 | +## Rate limits |
| 62 | + |
| 63 | +Headers `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`, |
| 64 | +`Retry-After` are exposed on response headers. Honor them. |
| 65 | + |
| 66 | +## Related repos |
| 67 | + |
| 68 | +- MCP server: <https://github.com/AxT-Team/uapi-mcp>. |
| 69 | +- Skills bundle: <https://github.com/AxT-Team/uapi-agent-skills>. |
| 70 | +- Other languages: `uapi-sdk-typescript`, `uapi-sdk-python`, `uapi-sdk-go`, |
| 71 | + `uapi-sdk-rust`, `uapi-sdk-csharp`, `uapi-sdk-cpp`, `uapi-sdk-php`. |
0 commit comments