|
通过托管OAuth认证访问Xero API。管理联系人、发票、付款、银行交易并运行财务报告。
bash
https://gateway.maton.ai/xero/{native-api-path}
将{native-api-path}替换为实际的Xero API端点路径。网关将请求代理到api.xero.com,并自动注入您的OAuth令牌和Xero-Tenant-Id标头。
所有请求都需要在Authorization标头中提供Maton API密钥:
Authorization: Bearer $MATONAPIKEY
环境变量: 将您的API密钥设置为MATONAPIKEY:
bash
export MATONAPIKEY=YOURAPIKEY
在https://ctrl.maton.ai管理您的Xero OAuth连接。
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections?app=xero&status=ACTIVE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python <
data = json.dumps({app: xero}).encode()
req = urllib.request.Request(https://ctrl.maton.ai/connections, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id})
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
json
{
connection: {
connection_id: 21fd90f9-5935-43cd-b6c8-bde9d915ca80,
status: ACTIVE,
creation_time: 2025-12-08T07:20:53.488460Z,
lastupdatedtime: 2026-01-31T20:03:32.593153Z,
url: https://connect.maton.ai/?session_token=...,
app: xero,
metadata: {}
}
}
在浏览器中打开返回的url以完成OAuth授权。
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id}, method=DELETE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果您有多个Xero连接,请使用Maton-Connection标头指定要使用的连接:
bash
python <
req = urllib.request.Request(https://gateway.maton.ai/xero/api.xro/2.0/Contacts)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Maton-Connection, 21fd90f9-5935-43cd-b6c8-bde9d915ca80)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果省略,网关将使用默认(最早)的活动连接。
bash
GET /xero/api.xro/2.0/Contacts
bash
GET /xero/api.xro/2.0/Contacts/{contactId}
bash
POST /xero/api.xro/2.0/Contacts
Content-Type: application/json
{
Contacts: [{
Name: John Doe,
EmailAddress: john@example.com,
Phones: [{PhoneType: DEFAULT, PhoneNumber: 555-1234}]
}]
}
bash
GET /xero/api.xro/2.0/Invoices
bash
POST /xero/api.xro/2.0/Invoices
Content-Type: application/json
{
Invoices: [{
Type: ACCREC,
Contact: {ContactID: xxx},
LineItems: [{
Description: Service,
Quantity: 1,
UnitAmount: 100.00,
AccountCode: 200
}]
}]
}
bash
GET /xero/api.xro/2.0/Accounts
bash
GET /xero/api.xro/2.0/Payments
bash
GET /xero/api.xro/2.0/BankTransactions
bash
GET /xero/api.xro/2.0/Reports/ProfitAndLoss?fromDate=2024-01-01&toDate=2024-12-31
bash
GET /xero/api.xro/2.0/Reports/BalanceSheet?date=2024-12-31
bash
GET /xero/api.xro/2.0/Reports/TrialBalance?date=2024-12-31
bash
GET /xero/api.xro/2.0/Organisation
javascript
const response = await fetch(
https://gateway.maton.ai/xero/api.xro/2.0/Contacts,
{
headers: {
Authorization: Bearer ${process.env.MATONAPIKEY}
}
}
);
python
import os
import requests
response = requests.get(
https://gateway.maton.ai/xero/api.xro/2.0/Contacts,
headers={Authorization: fBearer {os.environ[MATONAPIKEY]}}
)
| 状态码 | 含义 |
|---|---|
| 400 | 缺少Xero连接 |
| 401 |
bash
echo $MATONAPIKEY
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 xero-1776371193 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 xero-1776371193 技能
skillhub install xero-1776371193
文件大小: 3.87 KB | 发布时间: 2026-4-17 14:36