UnionSkill 工业智能体 API — 一行代码接入 CNC 报价、非标设计、智造飞轮能力
curl -X POST https://api.unionskillai.com/ \
-H 'Content-Type: application/json' \
-H 'X-API-Key: YOUR_API_KEY' \
-d '{"query": "{ order(id: \"o1\") { id total user { name } } }"}'
{
"data": {
"order": {
"id": "o1",
"total": 88,
"user": { "name": "Alice Zhang" }
}
}
}
所有 API 请求必须携带 API Key,通过 HTTP Header 传递:
401 UNAUTHENTICATED 错误。基于 Apollo Federation 2 构建的联邦化 GraphQL 超图,包含以下子图:
| 子图 | 实体 | 说明 |
|---|---|---|
products | Product | 产品目录、价格、库存 |
users | User | 用户信息、认证 |
orders | Order, OrderItem | 订单、订单明细 |
查询订单详情(跨子图联邦查询)
query {
order(id: "o1") {
id
total
user {
name
email
}
items {
productId
quantity
product {
name
price
}
}
}
}
查询产品列表
query {
products {
id
name
price
stock
}
}
GraphQL 超图同时集成了外部 REST API(通过 Apollo Connectors):
query {
posts {
id
title
body
}
}
import requests
API_KEY = "YOUR_API_KEY"
ENDPOINT = "https://api.unionskillai.com/"
headers = {
"Content-Type": "application/json",
"X-API-Key": API_KEY
}
query = """
query {
order(id: "o1") {
id total
user { name }
}
}
"""
response = requests.post(ENDPOINT, json={"query": query}, headers=headers)
data = response.json()
print(data["data"]["order"])
const res = await fetch('https://api.unionskillai.com/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'YOUR_API_KEY'
},
body: JSON.stringify({
query: `{
order(id: "o1") {
id total
user { name }
}
}`
})
});
const { data } = await res.json();
console.log(data.order);
curl -X POST https://api.unionskillai.com/ \
-H 'Content-Type: application/json' \
-H 'X-API-Key: YOUR_API_KEY' \
-d '{
"query": "{ order(id: \"o1\") { id total user { name } items { productId } } }"
}'
| HTTP 状态码 | 错误码 | 说明 |
|---|---|---|
200 | - | 请求成功 |
401 | UNAUTHENTICATED | 缺少或无效的 API Key |
400 | GRAPHQL_VALIDATION_FAILED | GraphQL 查询语法错误 |
400 | BAD_USER_INPUT | 请求参数错误 |
500 | INTERNAL_SERVER_ERROR | 服务器内部错误 |
503 | SERVICE_UNAVAILABLE | 子图服务不可用 |
{
"errors": [
{
"message": "API Key required (X-API-Key header)",
"extensions": {
"code": "UNAUTHENTICATED"
}
}
]
}
访问 sandbox.unionskillai.com 使用品牌化 Apollo Sandbox IDE,无需编写代码即可测试所有 GraphQL 查询。
| 能力 | 说明 |
|---|---|
| Schema 浏览 | 自动加载完整 GraphQL Schema,支持类型搜索 |
| 查询编辑器 | 自动补全、语法高亮、实时验证 |
| 跨子图查询 | 联邦查询自动合并多个子图数据 |
| REST 集成 | 通过 Connectors 调用外部 REST API |