{"id":24722024,"url":"https://github.com/hill-98/aliyun-openapi-bash-sdk","last_synced_at":"2025-10-09T18:30:45.689Z","repository":{"id":99602215,"uuid":"231073119","full_name":"Hill-98/aliyun-openapi-bash-sdk","owner":"Hill-98","description":"[Unofficial] Alibaba Cloud SDK for Bash","archived":false,"fork":false,"pushed_at":"2024-02-20T10:20:32.000Z","size":102,"stargazers_count":21,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T06:22:43.002Z","etag":null,"topics":["alibabacloud","aliyun","bash","sdk","shell"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hill-98.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-12-31T10:43:46.000Z","updated_at":"2024-09-14T12:13:57.000Z","dependencies_parsed_at":"2024-01-12T16:59:28.259Z","dependency_job_id":"750ba785-1e7c-4d1b-9442-689ba9bd3ae5","html_url":"https://github.com/Hill-98/aliyun-openapi-bash-sdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Hill-98/aliyun-openapi-bash-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hill-98%2Faliyun-openapi-bash-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hill-98%2Faliyun-openapi-bash-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hill-98%2Faliyun-openapi-bash-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hill-98%2Faliyun-openapi-bash-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hill-98","download_url":"https://codeload.github.com/Hill-98/aliyun-openapi-bash-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hill-98%2Faliyun-openapi-bash-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001947,"owners_count":26083226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alibabacloud","aliyun","bash","sdk","shell"],"created_at":"2025-01-27T12:15:54.653Z","updated_at":"2025-10-09T18:30:45.344Z","avatar_url":"https://github.com/Hill-98.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Aliyun OpenAPI Bash SDK\n\n[![Bats test](https://github.com/Hill-98/aliyun-openapi-bash-sdk/actions/workflows/bats-test.yml/badge.svg)](https://github.com/Hill-98/aliyun-openapi-bash-sdk/actions/workflows/bats-test.yml)\n\n这是一个非官方的阿里云 OpenAPI Bash SDK，用于 Bash 脚本调用阿里云 OpenAPI，相较于 [aliyun-cli](https://github.com/aliyun/aliyun-cli) 更加轻量，适合小存储设备。\n\n理论上支持所有阿里云 RPC OpenAPI，暂不支持 RESTful OpenAPI，将来可能会支持。\n\n\u003e 这可能是最好用的 Aliyun OpenAPI Bash SDK\n\n## 依赖\n\n* coreutils (`date`) # 获取时间戳\n* curl # 网络请求\n* openssl # 计算 HAMC-SHA1 签名\n\n### 可选依赖\n\n* ldd # 检查当前 Shell 是否使用 musl libc\n* coreutils (`grep`) # 检查当前 Shell 是否使用 musl libc\n\n\u003e 由于 glibc 和 musl libc 之间的差异，SDK 内部针对这两个不同的库做了些处理，初始化时使用 ldd 检查当前 Shell 是否使用了 musl libc。  \n\u003e 如果需要跳过检查，可以在导入之前设置变量: `ALIYUN_SDK_RUN_ON_MUSL_LIBC`，`1` 表示使用了 musl libc，`0` 表示没有使用。\n\n## 使用\n\n1. 声明变量 `AliAccessKeyId` 和 `AliAccessKeySecret`\n2. 导入 `AliyunOpenApiSDK.sh`\n3. 调用 `aliapi_rpc` 函数\n\n函数签名：\n```bash\n# Output: JsonString\n# Retrun Code: 0 = ALIYUN_SDK_LAST_HTTP_CODE == 200 | 1 = ALIYUN_SDK_LAST_HTTP_CODE != 200\naliapi_rpc \u003chttp_method\u003e \u003chost\u003e \u003capi_version\u003e \u003capi_action\u003e [\u003c--key\u003e \u003cvalue\u003e...]\n```\n\n`AliyunOpenApiSDK.sh` 可以作为脚本使用，脚本第一个参数为 `--rpc`，剩余参数为 `aliapi_rpc` 可接受参数。作为脚本使用时，`AliAccessKeyId` 和 `AliAccessKeySecret` 变量需要 `export`。\n\n**示例：**\n\n```bash\n#!/usr/bin/env bash\n\n# 设置 AliAccessKeyId 和 AliAccessKeySecret\nAliAccessKeyId=\"\u003cAliAccessKeyId\u003e\"\nAliAccessKeySecret=\"\u003cAliAccessKeySecret\u003e\"\n\n# 导入 SDK\nsource AliyunOpenApiSDK.sh\n\nget_show_size() {\n    echo 50\n}\n\n# 获取 SSL 证书列表：https://help.aliyun.com/document_detail/126511.html\n# 如果值以 () 结尾，那么 SDK 会假设它是一个函数，获取值时会判断函数是否存在并执行。\n# 如果不存在则使用原始值，所以这里 ShowSize 的值是 50。\naliapi_rpc GET cas.aliyuncs.com 2018-07-13 DescribeUserCertificateList --CurrentPage 1 --ShowSize \"get_show_size()\"\n# 如果 HTTP 状态码是 200，那么返回代码是 0，否则返回代码为 1。\n# 使用 ALIYUN_SDK_LAST_HTTP_CODE 变量可以获取最后一次调用的 HTTP 状态码。\nif [[ $? -eq 0 ]]; then\n    # 执行成功\nelse\n    # 执行失败\nfi\n```\n\n更多示例请参考 [examples](/examples) 下的文件\n\n如果你有好的示例，欢迎提交 [PR](https://github.com/Hill-98/aliyun-openapi-bash-sdk/pulls)。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhill-98%2Faliyun-openapi-bash-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhill-98%2Faliyun-openapi-bash-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhill-98%2Faliyun-openapi-bash-sdk/lists"}