导入
API 工具类
学习使用AvaTax API提供的一些实用端点。
代码示例
1https://sandbox-rest.avatax.com/api/v2/utilities/ping
1# 账户 ID 和许可证密钥 2account_id = "{{ACCOUNT_ID}}" 3license_key = "{{LICENSE_KEY}}" 4 5# 接口地址 6endpoint_url = "https://sandbox-rest.avatax.com/api/v2/utilities/ping" 7 8# 使用账户 ID 和许可证密钥创建基础认证令牌 9auth_token = requests.auth.HTTPBasicAuth(account_id, license_key) 10 11# 向 AvaTax API 发送 GET 请求 12response = requests.get(url=endpoint_url, auth=auth_token) 13 14# 打印响应结果 15print_response(response)
响应字段
| 字段名 | 类型 | 描述 |
|---|---|---|
| version | 字符串 | 该字段表示返回 ping 响应的 AvaTax API 版本号。 |
| authenticated | 布尔值 | 该字段表示 Avalara 是否成功验证了我们发送的凭证。 |
| authenticationType | 字符串 | 该字段表示我们凭证的认证类型。 |
| authenticatedUserName | 字符串 | 该字段表示已认证的 Avalara 账户用户名。 |
| authenticatedUserId | 整数 | 该字段表示已认证的 Avalara 用户 ID。 |
| authenticatedAccountId | 整数 | 该字段表示已认证的 Avalara 账户 ID。 |
代码示例
1https://sandbox-rest.avatax.com/api/v2/utilities/subscriptions
1# 账户 ID 和许可证密钥 2account_id = "{{ACCOUNT_ID}}" 3license_key = "{{LICENSE_KEY}}" 4 5# 接口地址 6endpoint_url = "https://sandbox-rest.avatax.com/api/v2/utilities/subscriptions" 7 8# 使用账户 ID 和许可证密钥创建基础认证令牌 9auth_token = requests.auth.HTTPBasicAuth(account_id, license_key) 10 11# 向 AvaTax API 发送 GET 请求 12response = requests.get(url=endpoint_url, auth=auth_token) 13 14# 打印响应结果 15print_response(response)
响应字段
| 字段名 | 类型 | 描述 |
|---|---|---|
| value | 订阅对象数组 | 该字段表示 Avalara 订阅列表。 |
| subscriptionTypeId | 整数 | 该字段表示订阅类型的 ID。 |
| subscriptionDescription | 字符串 | 该字段表示订阅的描述信息。 |