|
| 1 | +# AGENTS.md — uapi-sdk-cpp |
| 2 | + |
| 3 | +This file tells AI coding agents how to use the **official C++ SDK** for |
| 4 | +the [uapis.cn](https://uapis.cn) public API platform. |
| 5 | + |
| 6 | +## What this library is |
| 7 | + |
| 8 | +Header-only C++17 client for UAPI. Generated from the live OpenAPI 3.1 |
| 9 | +spec at <https://uapis.cn/openapi.json>. |
| 10 | + |
| 11 | +## Install |
| 12 | + |
| 13 | +CMake (FetchContent): |
| 14 | + |
| 15 | +```cmake |
| 16 | +include(FetchContent) |
| 17 | +FetchContent_Declare( |
| 18 | + uapi-sdk-cpp |
| 19 | + GIT_REPOSITORY https://github.com/AxT-Team/uapi-sdk-cpp |
| 20 | + GIT_TAG main |
| 21 | +) |
| 22 | +FetchContent_MakeAvailable(uapi-sdk-cpp) |
| 23 | +
|
| 24 | +target_link_libraries(my_app PRIVATE uapi) |
| 25 | +``` |
| 26 | + |
| 27 | +## Quick start |
| 28 | + |
| 29 | +```cpp |
| 30 | +#include <uapi/client.hpp> |
| 31 | + |
| 32 | +int main() { |
| 33 | + uapi::Client client("https://uapis.cn"); |
| 34 | + |
| 35 | + auto weather = client.misc().get_misc_weather({.city = "北京"}); |
| 36 | + std::cout << weather.dump() << std::endl; |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +The client is grouped by tag (`misc()`, `network()`, `text()`, `image()`, |
| 41 | +`social()`, `translate()`, `search()`, …). Method names match the OpenAPI |
| 42 | +`operationId`, snake_cased. |
| 43 | + |
| 44 | +## Authentication |
| 45 | + |
| 46 | +Free-tier endpoints work with no key. Paid endpoints take a key: |
| 47 | + |
| 48 | +```cpp |
| 49 | +uapi::Client client("https://uapis.cn", "sk_…"); |
| 50 | +``` |
| 51 | +
|
| 52 | +## Errors |
| 53 | +
|
| 54 | +Methods throw `uapi::ApiException` on non-2xx responses. The exception |
| 55 | +carries `code`, `error`, and `request_id` fields. Surface `error` |
| 56 | +verbatim. |
| 57 | +
|
| 58 | +## Rate limits |
| 59 | +
|
| 60 | +Headers `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`, |
| 61 | +`Retry-After` are exposed on response headers. Honor them. |
| 62 | +
|
| 63 | +## Related repos |
| 64 | +
|
| 65 | +- MCP server: <https://github.com/AxT-Team/uapi-mcp>. |
| 66 | +- Skills bundle: <https://github.com/AxT-Team/uapi-agent-skills>. |
| 67 | +- Other languages: `uapi-sdk-typescript`, `uapi-sdk-python`, `uapi-sdk-go`, |
| 68 | + `uapi-sdk-rust`, `uapi-sdk-java`, `uapi-sdk-csharp`, `uapi-sdk-php`. |
0 commit comments