特斯拉主页开发者跳至主要内容

NAV

概述

FleetAPI是一个基于REST API的数据和命令服务,提供对特斯拉车辆和能源设备的访问。合作伙伴通过FleetAPI可以与自己的设备或客户授予其访问权限的设备进行交互。

设置

  1. https://developer.tesla.cn上设置第三方帐户。
    • 在“客户端详细信息”步骤中,建议对于大多数用例选择“授权代码和机器对机器”。 仅应为拥有车辆的企业帐户选择“机器对机器”(M2M)。
    • 请注意,由于以下常见原因,帐户创建请求可能会被自动拒绝:
      • 域名无效
      • 应用程序名称已存在
  2. 完成帐户注册之后:
    1. 生成用于签署命令的公钥/私钥对,并将公钥托管在您网站的/.well-known部分中。 请参阅此处获取更详细的信息。
    2. 生成合作伙伴身份验证令牌
    3. 使用您的合作伙伴令牌以POST的方式调用/api/1/partner_accounts
  3. 向客户请求授权权限并代表他们生成第三方令牌。有关示例,请参阅身份验证部分。
  4. 要与车辆互动,请向客户发送配对请求< /a>,然后使用 Tesla 车辆命令协议 http 代理 发送命令。

如果注册流程或 API 遇到任何问题,请参阅帮助部分

地区要求

FleetAPI在不同的区域有不同的地址. 针对不同用户您需要选择对应区域。此文档当中的示例适用于中国大陆地区

API最佳实践

避免使用DNS缓存

车队API的高可​​用是建立在动态IP的基础上;DNS后面的地址在正常操作期间可能会突然更改。 DNS缓存里面的信息有可能会过时。这会导致连接的问题和错误。

建议避免更改DNS TTL设置(使用默认值),以确保DNS解析器遵循权威DNS服务器提供的TTL值。

避免频繁轮询设备数据

车队API允许开发人员通过API从设备获取数据,这些数据原本的设计不是用来被经常使用的。大多数API都有严格的速率限制以进行保护。如果您需要定期获取数据,请使用车队telemetry,它提供自定义的直接的实时数据流。

确保使用未过期的授权令牌进行API调用

用于授权的车队API的Bearer令牌是简单的JWT令牌。在调用后端之前,请务必检查它们是否在1分钟内过期。如果他们在,请更新令牌再调用API。

对于高度分布式应用程序来说,缓存令牌是一个可行的选择。尽管如此,在选择这种方法时请使用有效的安全措施以确保安全。

遵守当地隐私法和数据管理调理

车队API根据当地法规(个人信息保护法、CCPA、GDPR 等)在多个区域进行本地化。 API可能会返回一些错误来指导开发人员,但开发人员有责任在安全、数据隐私、数据传输和数据治理方面遵守相应的法规。

请始终确保私钥和密码的安全

使用私钥和密码时请遵循最佳安全实践。现代云提供商提供密钥管理服务(例如 AWS Key Management Service、Azure Key Vault 和 Google Cloud Key Management Service)或硬件安全模块(HSM)解决方案来安全地创建和管理私钥和密码。请勿通过网络获取或传输私钥,尤其是在私钥未加密的情况下。

超时错误发生后验证车辆状态

在给车辆中发送和执行命令之前或之后可能会发生超时,因此在发生超时时很难确定车辆的状态。开发者有责任确保车辆处于所需状态。大多数车队API命令都是有状态的,可以安全地重试,但某些命令(例如honk_horn和media_next_track)可能会导致重复操作。因此,开发人员在重试这些命令时应小心谨慎,以避免出现意外后果。

会员等级

以下是当前可用的访问特斯拉FleetAPI的会员等级。

发现级

订阅计划 发现级
设备数据限制 1个API请求/车辆/5分钟

1百万个API请求/天
命令限制 50个API请求/车辆/天

50万个API请求/天
唤醒限制 5个API请求/车辆/小时
能力 API访问
登录Tesla
Tesla for Business的访问
企业充电API
发票
有限的Fleet Telemetry数据流
价格 ¥0/周
订阅时长 每周自动续订直至取消
可用性 此订阅计划是临时计划,将于2024年替换为不同的选项



接口惯例

请求格式

请求需要带有'Content-Type''application/json'的http标头。此外,所有经过身份验证的端点都需要标准Bearer授权标头和有效令牌。

  Content-Type: application/json
  Authorization: Bearer 8s2wfclhyp5iiikowm3ocnfalt7qfl7es8xhuda3ttusslssx6c14hq7yocp62c5

POST请求的参数应放在请求的JSON对象中。

响应格式

响应以JSON对象的形式返回,具有以下公共字段:

字段 说明
response: <json> JSON作为请求的响应. 可能是标量、数组或对象,具体取决于具体请求
error: short-string 短错误,例如"not_found", "invalid_resource", "invalid_password"
error_description: long-string 附加错误信息
messages: {"field1":["problem1","problem2"],...} 数据验证问题,尤其是422响应

请求参数

设备/实体/车辆端点的{id}路径参数应为从车辆列表端点返回的记录中的id,这个id的类型是整型。例如: 车辆列表. 对于车辆端点车辆命令, 可以使用有效的VIN来代替整数ID。

响应代码

端点示例并未涵盖所有可能的响应代码。以下是状态码的常见含义。 响应正文通常采用JSON编码,并在“错误”字段中包含详细信息。

成功案例

状态码 说明 详细
200 Ok 请求已被成功处理
201 Created 记录创建成功

客户端错误

状态码 说明 详细
400 请求错误
• error:invalid_command 如果data_request或命令未知
• error:invalid_field 如果新添加数据包含无效字段
401 未经授权
• 无响应正文 - OAuth令牌已过期
• error:mobile_access_disabled 如果车辆已关闭远程访问
• error:login_failed 如果change_password 上的current_password 不正确
• error:password_changed 如果自上次获取令牌以来密码已更改
• login_required - 用户已重置密码并且需要新的身份验证代码,或者刷新令牌已被使用。
402 需要付款 您需要付款才能使用API(仅限非免费帐户)
403 禁止
• 未授权访问此资源,开发人员应检查所需的授权范围
• 与设备交互需要使用特斯拉车辆命令协议。
404 未找到 请求的资源不存在
405 不允许 不允许该操作
406 不能接受的 error:not_a_JSON_request 如果 HTTP请求未将Content-Type设置为application/json
408 设备不可用 如果发出请求时车辆未“在线”。
412 前提条件失败 不满足处理请求的条件
• Unregistered account - 您必须先调用合作伙伴账户注册端点
418 客户端版本太低 (不支持) 移动应用程序需要更新(仅限特斯拉应用程序)。
422 无效资源 error:invalid_resource 如果数据存在语义问题,例如数据丢失或无效
• 车辆尚不支持签名命令
423 锁定 帐户已锁定,必须由 Tesla 解锁。无响应体
429 Rate limited 帐户或服务器受到速率限制,当帐户发出太多请求时会发生这种情况
• 请检查'Retry-After'请求标头(以秒为单位)以确定何时发出下一个请求
451 资源因法律原因不可用 查询没有适当隐私设置的用户/车辆(例如错误的区域)
499 客户关闭请求 在服务器发送响应之前客户端已关闭请求

服务器错误

状态码 说明 详细
500 服务器内部错误 处理请求时发生错误
503 暂停服务 内部服务或车辆未响应(超时)
504 网关超时 服务器没有收到响应

设备错误

状态码 说明 详细
540 设备意外响应 车辆响应错误 - 可能需要重新启动、OTA 更新或服务


API状态

GET /status

curl 'https://fleet-api.prd.cn.vn.cloud.tesla.cn/status'

如果API正常运行,则该端点返回字符串“ok”。不需要HTTP标头。

所有 Fleet API 的使用都必须遵守 Fleet API 协议。 发现违规的帐户将被禁止,恕不另行通知。

身份验证

API访问需要身份验证令牌。令牌类型包括以下两种:

  1. 合作伙伴身份验证令牌 - 此种令牌的对象是应用程序或业务client_id,并将使用授权类型为client_credentials的方式生成。这可用于与修改应用程序(如注册 )相关的调用,或用于访问企业拥有的设备。
  2. 第三方令牌 - 此令牌的对象是客户帐户的ID,并将使用授予authorization_code类型生成。该令牌由第三方应用程序代表客户生成,可用于大多数接口。

OAuth 服务器的元数据文件可以在以下位置找到:[https://auth.tesla.cn/oauth2/v3/thirdparty/.well-known/openid-configuration](https://auth.tesla.cn/oauth2/v3 /thirdparty/.well-known/openid-configuration)。

包含这些请求的 Postman 集合可以在此处找到。

生成合作伙伴身份验证令牌

POST https://auth.tesla.cn/oauth2/v3/token

生成用于管理合作伙伴的帐户或他们拥有的设备的令牌。

CLIENT_ID=<command to obtain your client_id>
CLIENT_SECRET=<secure command to obtain your client_secret>
AUDIENCE="https://fleet-api.prd.cn.vn.cloud.tesla.cn"
# Partner authentication token request
curl --request POST \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'grant_type=client_credentials' \
  --data-urlencode "client_id=$CLIENT_ID" \
  --data-urlencode "client_secret=$CLIENT_SECRET" \
  --data-urlencode 'scope=openid vehicle_device_data vehicle_cmds vehicle_charging_cmds' \
  --data-urlencode "audience=$AUDIENCE" \
  'https://auth.tesla.cn/oauth2/v3/token'

代表客户生成第三方令牌

使用此授权代码授予流程代表客户生成令牌。这允许您使用客户授予的授权范围进行API调用。


1. 启动授权代码流程,请客户端将用户定向到/authorize的请求.

https://auth.tesla.cn/oauth2/v3/authorize?&client_id=$CLIENT_ID&locale=en-US&prompt=login&redirect_uri=$REDIRECT_URI&response_type=code&scope=openid%20vehicle_device_data%20offline_access&state=$STATE`

https://auth.tesla.cn/oauth2/v3/authorize

参数

参数名 必需? 例子 说明
response_type Yes code 类型位字符串,固定值为“code”
client_id Yes abc-123 合作伙伴应用的client_id
redirect_uri Yes https://example.com/auth/callback 合作伙伴应用的回调url, spec: rfc6749
scope Yes openid offline_access vehicle_device_data vehicle_cmds vehicle_charging_cmds 以空格为分隔符的授权范围, 包括openid和offline_access 用来获取refresh token
state Yes db4af3f87... 验证的随机数
nonce No 7baf90cda... 防止重放攻击的随机数

2. 从回调中提取URL参数中的code

3. 执行代码交换调用以生成令牌。 保存刷新令牌以便以后生成新的令牌。发出API请求时,访问令牌可以用作Authorization标头中的Bearer令牌。“invalid_auth_code”可能意味着“代码”已过期

POST https://auth.tesla.cn/oauth2/v3/token

# Authorization code token request
CODE=<extract from callback>
curl --request POST \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'grant_type=authorization_code' \
  --data-urlencode "client_id=$CLIENT_ID" \
  --data-urlencode "client_secret=$CLIENT_SECRET" \
  --data-urlencode "code=$CODE" \
  --data-urlencode "audience=$AUDIENCE" \
  --data-urlencode "redirect_uri=$CALLBACK" \
  'https://auth.tesla.cn/oauth2/v3/token'
# Extract access_token and refresh_token from this response

参数

参数名 必需? 例子 说明
grant_type Yes authorization_code 授权类型,包括 authorization_code, refresh_token, client_credentials
client_id Yes abc-123 合作伙伴应用的client_id
client_secret Yes secret-password 合作伙伴应用的client_secret
code Yes a90869e9d... 授权请求回调的code
redirect_uri Yes https://example.com/auth/callback 合作伙伴应用的回调url, spec: rfc6749
scope No openid vehicle_device_data vehicle_cmds vehicle_charging_cmds 以空格为分隔符的授权范围
audience Yes https://fleet-api.prd.cn.vn.cloud.tesla.cn 生成令牌的Audience

4. 使用刷新令牌生成新的令牌并获取刷新令牌. 使用刷新令牌有两种常见的失败模式,将返回 401 - login_required 响应: 1. 刷新令牌已被使用;只有最新的刷新令牌才有效。 2. 用户已重置密码。

# Refresh token request
REFRESH_TOKEN=<extract from authorization code token request>
curl --request POST \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'grant_type=refresh_token' \
  --data-urlencode "client_id=$CLIENT_ID" \
  --data-urlencode "refresh_token=$REFRESH_TOKEN" \
  'https://auth.tesla.cn/oauth2/v3/token'

POST https://auth.tesla.cn/oauth2/v3/token

参数

参数名 必需? 例子 说明
grant_type Yes refresh_token 授权类型必须是refresh_token。
client_id Yes abc-123 合作伙伴应用程序客户端 ID
refresh_token Yes NA_a90869e9d... 从代码交换响应中刷新令牌。

5. 用户向应用程序授予范围后,他们可以使用同意管理页面修改范围或撤销访问权限:

https://auth.tesla.cn/user/revoke/consent?revoke_client_id=$CLIENT_ID&back_url=$RETURN_URL

https://auth.tesla.cn/user/revoke/consent?revoke_client_id=cb30fbdf81e9-4405-ba59-ddbc042277e8&back_url=https://accounts.tesla.cn/account-settings/security?tab=tpty-apps

范围修改与现有刷新令牌兼容,并将应用于新的访问令牌。



授权范围

名称 范围 说明
登录Tesla openid 允许Tesla的用户使用其Tesla凭证登录应用程序。
刷新令牌 offline_access 允许获取刷新令牌而无需用户再次登录。
档案信息 user_data 联系信息、家庭住址、个人资料图片和推荐信息
车辆信息 vehicle_device_data 车辆实时数据、位置、符合条件的升级、附近的超充站点、所有权和服务调度数据
车辆命令 vehicle_cmds 添加/删除驾驶员、访问实时摄像头、解锁、唤醒、远程启动和安排软件更新等命令
车辆充电管理 vehicle_charging_cmds 车辆充电历史记录、计费金额、充电位置、安排命令以及开始/停止充电
Energy Product Information energy_device_data Energy live status, site info, backup history, energy history, and charge history.
Energy Product Settings energy_cmds Update settings like backup reserve percent, operation mode, and storm mode.

要查看按范围可用的端点列表,请参阅 scopes.json



Energy Endpoints

backup

POST /api/1/energy_sites/{energy_site_id}/backup

授权范围: energy_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/backup' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/backup", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/backup")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/energy_sites/{energy_site_id}/backup", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Adjust the site's backup reserve.

参数

姓名 类型 必需的 描述
energy_site_id 路径 integer ID field of an energy site from /api/1/products endpoint.
backup_reserve_percent 正文 integer The desired backup reserve percent.
点击查看成功回复{ "response": { "code": 201, "message": "Updated" } }

backup_history

GET /api/1/energy_sites/{energy_site_id}/calendar_history?kind=backup&

授权范围: energy_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/calendar_history?kind=backup&=null' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/calendar_history?kind=backup&", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/calendar_history?kind=backup&")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/energy_sites/{energy_site_id}/calendar_history?kind=backup&=null", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Returns the backup (off-grid) event history of the site in duration of seconds.

参数

姓名 类型 必需的 描述
energy_site_id 路径 integer ID field of an energy site from /api/1/products endpoint.
kind 查询 string The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
start_date 查询 string Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
end_date 查询 string End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
period 查询 string Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
time_zone 查询 string Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
点击查看成功回复{ "response": { "events": [ { "timestamp": "2023-01-01T01:00:00-08:00", "duration": 3600 }, { "timestamp": "2023-01-02T08:00:00-08:00", "duration": 7200 } ], "total_events": 2 } }

charge_history

GET /api/1/energy_sites/{energy_site_id}/telemetry_history?kind=charge&

授权范围: energy_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/telemetry_history?kind=charge&=null' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/telemetry_history?kind=charge&", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/telemetry_history?kind=charge&")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/energy_sites/{energy_site_id}/telemetry_history?kind=charge&=null", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Returns the charging history of a wall connector.

  • Energy values are in watt hours.

参数

姓名 类型 必需的 描述
energy_site_id 路径 integer ID field of an energy site from /api/1/products endpoint.
kind 查询 string The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
start_date 查询 string Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
end_date 查询 string End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
time_zone 查询 string Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
点击查看成功回复{ "response": { "charge_history": [ { "charge_start_time": { "seconds": 1672560000 }, "charge_duration": { "seconds": 12000 }, "energy_added_wh": 25000 } ] } }

energy_history

GET /api/1/energy_sites/{energy_site_id}/calendar_history?kind=energy&

授权范围: energy_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/calendar_history?kind=energy&=null' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/calendar_history?kind=energy&", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/calendar_history?kind=energy&")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/energy_sites/{energy_site_id}/calendar_history?kind=energy&=null", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Returns the energy measurements of the site, aggregated to the requested period.

参数

姓名 类型 必需的 描述
energy_site_id 路径 integer ID field of an energy site from /api/1/products endpoint.
kind 查询 string The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
start_date 查询 string Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
end_date 查询 string End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
period 查询 string Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
time_zone 查询 string Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
点击查看成功回复{ "response": { "period": "day", "time_series": [ { "timestamp": "2023-06-01T01:00:00-07:00", "solar_energy_exported": 70940, "generator_energy_exported": 0, "grid_energy_imported": 521, "grid_services_energy_imported": 17.53125, "grid_services_energy_exported": 3.80859375, "grid_energy_exported_from_solar": 43660, "grid_energy_exported_from_generator": 0, "grid_energy_exported_from_battery": 19, "battery_energy_exported": 10030, "battery_energy_imported_from_grid": 80, "battery_energy_imported_from_solar": 16800, "battery_energy_imported_from_generator": 0, "consumer_energy_imported_from_grid": 441, "consumer_energy_imported_from_solar": 10480, "consumer_energy_imported_from_battery": 10011, "consumer_energy_imported_from_generator": 0 } ] } }

grid_import_export

POST /api/1/energy_sites/{energy_site_id}/grid_import_export

授权范围: energy_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/grid_import_export' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/grid_import_export", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/grid_import_export")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/energy_sites/{energy_site_id}/grid_import_export", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Allow/disallow charging from the grid and exporting energy to the grid.

参数

姓名 类型 必需的 描述
energy_site_id 路径 integer ID field of an energy site from /api/1/products endpoint.
disallow_charge_from_grid_with_solar_installed 正文 boolean The desired behavior towards importing from the grid. Charging from the grid is disabled when set to true and enabled when set to false.
customer_preferred_export_rule 正文 string The desired behavior for grid exporting. The available options are battery_ok, pv_only, and never.
点击查看成功回复{ "response": { "code": 204, "message": "Updated" } }

live_status

GET /api/1/energy_sites/{energy_site_id}/live_status

授权范围: energy_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/live_status' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/live_status", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/live_status")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/energy_sites/{energy_site_id}/live_status", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Returns the live status of the site (power, state of energy, grid status, storm mode).

  • Power values are in watts.
  • Energy values are in watt hours.

参数

姓名 类型 必需的 描述
energy_site_id 路径 integer ID field of an energy site from /api/1/products endpoint.
点击查看成功回复{ "response": { "solar_power": 3102, "energy_left": 18020.894736842107, "total_pack_energy": 39343, "percentage_charged": 45.80457701965307, "backup_capable": true, "battery_power": -3090, "load_power": 2581, "grid_status": "Active", "grid_power": 2569, "island_status": "on_grid", "storm_mode_active": false, "timestamp": "2023-01-01T00:00:00-08:00" } }

off_grid_vehicle_charging_reserve

POST /api/1/energy_sites/{energy_site_id}/off_grid_vehicle_charging_reserve

授权范围: energy_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/off_grid_vehicle_charging_reserve' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/off_grid_vehicle_charging_reserve", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/off_grid_vehicle_charging_reserve")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/energy_sites/{energy_site_id}/off_grid_vehicle_charging_reserve", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Adjust the site's off-grid vehicle charging backup reserve.

参数

姓名 类型 必需的 描述
energy_site_id 路径 integer ID field of an energy site from /api/1/products endpoint.
off_grid_vehicle_charging_reserve_percent 正文 integer The desired off grid vehicle charging reserve percent.
点击查看成功回复{ "response": { "code": 201, "message": "Updated" } }

operation

POST /api/1/energy_sites/{energy_site_id}/operation

授权范围: energy_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/operation' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/operation", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/operation")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/energy_sites/{energy_site_id}/operation", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Set the site's mode.

参数

姓名 类型 必需的 描述
energy_site_id 路径 integer ID field of an energy site from /api/1/products endpoint.
default_real_mode 正文 string The desired operation mode. Use autonomous for time-based control and self_consumption for self-powered mode.
点击查看成功回复{ "response": { "code": 201, "message": "Updated" } }

products

GET /api/1/products

授权范围: 以下之一 - vehicle_device_data, energy_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/products' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/products", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/products")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/products", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Returns products mapped to user.

点击查看成功回复{ "response": [ { "id": 100021, "user_id": 429511308124, "vehicle_id": 99999, "vin": "5YJ3000000NEXUS01", "color": null, "access_type": "OWNER", "display_name": "Owned", "option_codes": "TEST0,COUS", "cached_data": null, "granular_access": { "hide_private": false }, "tokens": [ "4f993c5b9e2b937b", "7a3153b1bbb48a96" ], "state": null, "in_service": false, "id_s": "100021", "calendar_enabled": false, "api_version": null, "backseat_token": null, "backseat_token_updated_at": null, "command_signing": "off" }, { "energy_site_id": 429124, "resource_type": "battery", "site_name": "My Home", "id": "STE12345678-12345", "gateway_id": "1112345-00-E--TG0123456789", "energy_left": 35425, "total_pack_energy": 39362, "percentage_charged": 90, "battery_power": 1000 } ], "count": 2 }

site_info

GET /api/1/energy_sites/{energy_site_id}/site_info

授权范围: energy_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/site_info' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/site_info", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/site_info")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/energy_sites/{energy_site_id}/site_info", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Returns information about the site. Things like assets (has solar, etc), settings (backup reserve, etc), and features (storm_mode_capable, etc).

  • Power values are in watts.
  • Energy values are in watt hours.
  • default_real_mode can be autonomous for time-based control and self_consumption for self-powered mode.

参数

姓名 类型 必需的 描述
energy_site_id 路径 integer ID field of an energy site from /api/1/products endpoint.
点击查看成功回复{ "response": { "id": "0000000-00-A--TEST0000000DIN", "site_name": "My Home", "backup_reserve_percent": 20, "default_real_mode": "autonomous", "installation_date": "2023-01-01T00:00:00-08:00", "user_settings": { "storm_mode_enabled": true }, "components": { "solar": true, "solar_type": "pv_panel", "battery": true, "grid": true, "backup": true, "load_meter": true, "storm_mode_capable": true, "off_grid_vehicle_charging_reserve_supported": true, "solar_value_enabled": true, "set_islanding_mode_enabled": true, "battery_type": "ac_powerwall", "configurable": true }, "version": "23.12.11 452c76cb", "battery_count": 3, "nameplate_power": 15000, "nameplate_energy": 40500, "installation_time_zone": "America/Los_Angeles", "max_site_meter_power_ac": 1000000000, "min_site_meter_power_ac": -11.726 } }

storm_mode

POST /api/1/energy_sites/{energy_site_id}/storm_mode

授权范围: energy_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/storm_mode' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/storm_mode", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/energy_sites/{energy_site_id}/storm_mode")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/energy_sites/{energy_site_id}/storm_mode", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Update storm watch participation.

参数

姓名 类型 必需的 描述
energy_site_id 路径 integer ID field of an energy site from /api/1/products endpoint.
enabled 正文 boolean The storm mode participation value to set.
点击查看成功回复{ "response": { "code": 201, "message": "Updated" } }

充电 (charging)

charging_history

GET /api/1/dx/charging/history

授权范围: vehicle_charging_cmds

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/charging/history' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/charging/history", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/charging/history")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/dx/charging/history", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回分页的充电历史记录。(暂未开放,即将推出)

参数

姓名 类型 必需的 描述
vin 查询 string VIN
startTime 查询 string 下载充电历史记录的区间的开始时间(例如"2023-07-27T11:43:45-07:00").
endTime 查询 string 下载充电历史记录的区间的结束时间(例如"2023-07-27T11:43:45-07:00").
pageNo 查询 integer 页号
pageSize 查询 integer 每页数量
sortBy 查询 string 排序依据的字段
sortOrder 查询 string 排序顺序 (ASC or DESC).
点击查看成功回复{ "response": { "data": [ { "sessionId": 1234567, "vin": "TEST00000000VIN01", "siteLocationName": "Truckee, CA - Soaring Way", "chargeStartDateTime": "2023-07-27T11:43:45-07:00", "chargeStopDateTime": "2023-07-27T12:08:35-07:00", "unlatchDateTime": "2023-07-27T12:25:31-07:00", "countryCode": "US", "fees": [ { "sessionFeeId": 7654321, "feeType": "CHARGING", "currencyCode": "USD", "pricingType": "PAYMENT", "rateBase": 0.46, "rateTier1": 0, "rateTier2": 0, "rateTier3": null, "rateTier4": null, "usageBase": 40, "usageTier1": 0, "usageTier2": 24, "usageTier3": null, "usageTier4": null, "totalBase": 18.4, "totalTier1": 0, "totalTier2": 0, "totalTier3": 0, "totalTier4": 0, "totalDue": 18.4, "netDue": 18.4, "uom": "kwh", "isPaid": true, "status": "PAID" }, { "sessionFeeId": 87654321, "feeType": "PARKING", "currencyCode": "USD", "pricingType": "NO_CHARGE", "rateBase": 0, "rateTier1": 0, "rateTier2": 0, "rateTier3": null, "rateTier4": null, "usageBase": 0, "usageTier1": 0, "usageTier2": 0, "usageTier3": null, "usageTier4": null, "totalBase": 0, "totalTier1": 0, "totalTier2": 0, "totalTier3": 0, "totalTier4": 0, "totalDue": 0, "netDue": 0, "uom": "min", "isPaid": true, "status": "PAID" } ], "billingType": "IMMEDIATE", "invoices": [ { "fileName": "ABC-123NN-US.pdf", "contentId": "abc-123-efg", "invoiceType": "IMMEDIATE" } ], "vehicleMakeType": "TSLA" } ] } }

charging_invoice

GET /api/1/dx/charging/invoice/{id}

授权范围: vehicle_charging_cmds

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/charging/invoice/{id}' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/charging/invoice/{id}", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/charging/invoice/{id}")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/dx/charging/invoice/{id}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回收费发票

参数

姓名 类型 必需的 描述
id 路径 string 内容 ID。 这可以从充电历史事件的invoices.contentId中获取
点击查看成功回复{ "response": "raw .pdf document" }

charging_sessions(仅适用于商务车队所有者)

GET /api/1/dx/charging/sessions

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/charging/sessions' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/charging/sessions", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/charging/sessions")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/dx/charging/sessions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回充电Session,包括定价和能源数据。此端点仅适用于拥有车队的企业帐户。(暂未开放,即将推出)

参数

姓名 类型 必需的 描述
vin 查询 string VIN
date_from 查询 string 下载充电历史记录的区间的开始时间(例如"2023-07-27T11:43:45-07:00").
date_to 查询 string 下载充电历史记录的区间的结束时间(例如"2023-07-27T11:43:45-07:00").
limit 查询 integer 返回总数
offset 查询 integer offset
点击查看成功回复{ "response": { "data": [ { "charging_periods": [ { "dimensions": [ { "type": "ENERGY", "volume": 0 } ], "start_date_time": "string" } ], "id": "string", "location": { "country": "string", "name": "string" }, "model": "string", "start_date_time": "string", "stop_date_time": "string", "tariffs": { "currency": "string", "elements": [ { "price_components": [ { "price": 0, "step_size": 0, "type": "ENERGY" } ], "restrictions": { "additionalProp1": {} } } ] }, "total_cost": { "excl_vat": 0, "incl_vat": 0, "vat": 0 }, "total_energy": 0, "total_time": 0, "vin": "string" } ], "status_code": 0, "status_message": "string", "timestamp": { "time.Time": "string" } } }

合作伙伴 (partner)

fleet_telemetry_errors

GET /api/1/partner_accounts/fleet_telemetry_errors

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts/fleet_telemetry_errors' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts/fleet_telemetry_errors", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts/fleet_telemetry_errors")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/partner_accounts/fleet_telemetry_errors", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回车辆在收到配置后报告的最近的车队遥测错误。

此端点需要合作伙伴身份验证令牌

点击查看成功回复{ "response": { "fleet_telemetry_errors": [ { "name": "client-id", "error": "msg", "vin": "vin" }, { "name": "client-id", "error": "msg2", "vin": "vin" } ] } }

public_key

GET /api/1/partner_accounts/public_key

授权范围: 以下之一 - vehicle_device_data, vehicle_cmds

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts/public_key' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts/public_key", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts/public_key")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/partner_accounts/public_key", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回与域名关联的公钥。它可用于确保注册成功。

此端点需要合作伙伴身份验证令牌

参数

姓名 类型 必需的 描述
domain 查询 string Partner domain used to validate registration flow.
点击查看成功回复{ "response": { "public_key": "0437d832a7a695151f5a671780a276aa4cf2d6be3b2786465397612a342fcf418e98022d3cedf4e9a6f4b3b160472dee4ca022383d9b4cc4001a0f3023caec58fa" } }

register

POST /api/1/partner_accounts

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/partner_accounts", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

完成注册合作方账号之后才可以访问API. 每个developer.tesla.cn上的应用程序都必须完成此步骤。

  • 此端点的域名必须与developer.tesla.cn上的allowed_origins的根域匹配。例如: 123.abc.com 可用于www.abc.com的allowed_origin。
  • 此请求的承载令牌必须是合作伙伴身份验证令牌.
  • 使用secp256r1 curve(prime256v1)的PEM编码EC公钥必须托管在https://<您的域名>/.well-known/appspecific/com.tesla.3p.public-key.pem。该公钥将在设备上注册并用于验证车辆命令代理生成的命令。
  • 该域名将作为基于移动应用程序的车辆密钥配对过程的一部分显示给用户。

此端点需要合作伙伴身份验证令牌

参数

姓名 类型 必需的 描述
domain 正文 string 您的域名。您必须在https://\<您的域名\>/.well-known/appspecific/com.tesla.3p.public-key.pem托管使用PEM编码的EC公钥。域名必须是小写的,并且与您的应用程序在developer.tesla.cn上的allowed_origins中的域名具有相同的根路径。
csr 正文 string 应为您的帐户配置的证书签名请求。 上传后,可能需要一周的时间才能完全处理完毕。”
点击查看成功回复{ "response": { "client_id": "client-id", "name": "The Best Tesla Partner", "description": "The very best Tesla partner", "domain": "the-best-partner.com", "ca": null, "created_at": "2023-06-28T00:42:00.000Z", "updated_at": "2023-06-28T00:42:00.000Z", "enterprise_tier": "discovery", "account_id": "account-id", "issuer": null, "csr": "-----BEGIN CERTIFICATE REQUEST-----\nMIHZMIGBAgEAMB8xHTAbBgNVBAMMFHRoZS1iZXN0LXBhcnRuZXIuY29tMFkwEwYH\nKoZIzj0CAQYIKoZIzj0DAQcDQgAEN9gyp6aVFR9aZxeAonaqTPLWvjsnhkZTl2Eq\nNC/PQY6YAi087fTppvSzsWBHLe5MoCI4PZtMxAAaDzAjyuxY+qAAMAoGCCqGSM49\nBAMCA0cAMEQCIE7LtTJO/Vrbr97cMz+FyjmzJ5FA+Xck55/QOnPq9AsOAiB77g0W\noEFqpvbpUQ1Y7biEoPa1gT0/nvoB31suLABmMg==\n-----END CERTIFICATE REQUEST-----\n", "csr_updated_at": "2023-06-28T00:42:00.000Z", "public_key": "0437d832a7a695151f5a671780a276aa4cf2d6be3b2786465397612a342fcf418e98022d3cedf4e9a6f4b3b160472dee4ca022383d9b4cc4001a0f3023caec58fa" } }

用户 (user)

feature_config

GET /api/1/users/feature_config

授权范围: user_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/feature_config' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/feature_config", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/feature_config")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/users/feature_config", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回应用于用户的任何自定义功能标志。

点击查看成功回复{ "response": { "signaling": { "enabled": true, "subscribe_connectivity": false, "use_auth_token": false } } }

me

GET /api/1/users/me

授权范围: user_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/me' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/me", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/me")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/users/me", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回用户帐户的摘要。

点击查看成功回复{ "response": { "email": "test-user@tesla.com", "full_name": "Testy McTesterson", "profile_image_url": "https://vehicle-files.prd.usw2.vn.cloud.tesla.com/profile_images/f98c87cd7bebc06069b89b33f9ec634c195520f75b6e63ea89f0b7c61449c689.jpg", "vault_uuid": "b5c443af-a286-49eb-a4ad-35a97963155d" } }

orders

GET /api/1/users/orders

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/orders' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/orders", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/orders")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/users/orders", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回用户的活跃订单

点击查看成功回复{ "response": [ { "vehicleMapId": 1234466, "referenceNumber": "RN00000001", "vin": "5YJ30000000000001", "orderStatus": "BOOKED", "orderSubstatus": "_Z", "modelCode": "m3", "countryCode": "US", "locale": "en_US", "mktOptions": "APBS,DV2W,IBB1,PMNG,PRM30,SC04,MDL3,W41B,MT322,CPF0,RSF1,CW03", "isB2b": false } ], "count": 1 }

region

GET /api/1/users/region

授权范围: 以下之一 - vehicle_device_data, vehicle_cmds, energy_cmds, energy_device_data, user_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/region' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/region", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/users/region")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/users/region", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回用户的区域和对应的Fleet API根URL。不接受任何参数,响应基于身份验证令牌的主题。

点击查看成功回复{ "response": { "region": "eu", "fleet_api_base_url": "https://fleet-api.prd.eu.vn.cloud.tesla.com" } }

车辆指令 (vehicle_commands)

actuate_trunk

POST /api/1/vehicles/{vehicle_tag}/command/actuate_trunk

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/actuate_trunk' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/actuate_trunk", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/actuate_trunk")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/actuate_trunk", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

控制车辆的前备箱(which_trunk: "front")或者后备箱(which_trunk: "rear").

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
which_trunk 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

adjust_volume

POST /api/1/vehicles/{vehicle_tag}/command/adjust_volume

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/adjust_volume' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/adjust_volume", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/adjust_volume")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/adjust_volume", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

调节车辆媒体播放音量。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
volume 正文 number A floating point number from 0.0 to 11.0
点击查看成功回复{ "response": { "result": true, "reason": "" } }

auto_conditioning_start

POST /api/1/vehicles/{vehicle_tag}/command/auto_conditioning_start

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/auto_conditioning_start' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/auto_conditioning_start", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/auto_conditioning_start")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/auto_conditioning_start", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

开启车内空调。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

auto_conditioning_stop

POST /api/1/vehicles/{vehicle_tag}/command/auto_conditioning_stop

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/auto_conditioning_stop' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/auto_conditioning_stop", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/auto_conditioning_stop")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/auto_conditioning_stop", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

关闭车内空调。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

cancel_software_update

POST /api/1/vehicles/{vehicle_tag}/command/cancel_software_update

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/cancel_software_update' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/cancel_software_update", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/cancel_software_update")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/cancel_software_update", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

取消安装车辆软件更新的倒计时。车辆开始安装软件后,此操作将不再起作用。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

charge_max_range

POST /api/1/vehicles/{vehicle_tag}/command/charge_max_range

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_max_range' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_max_range", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_max_range")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/charge_max_range", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

在最大续航里程模式下充电 -- 我们建议限制在长途旅行时使用此模式。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

charge_port_door_close

POST /api/1/vehicles/{vehicle_tag}/command/charge_port_door_close

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_port_door_close' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_port_door_close", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_port_door_close")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/charge_port_door_close", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

关闭充电口盖

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

charge_port_door_open

POST /api/1/vehicles/{vehicle_tag}/command/charge_port_door_open

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_port_door_open' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_port_door_open", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_port_door_open")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/charge_port_door_open", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

打开充电口盖

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

charge_standard

POST /api/1/vehicles/{vehicle_tag}/command/charge_standard

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_standard' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_standard", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_standard")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/charge_standard", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

使用标准充电模式充电

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

charge_start

POST /api/1/vehicles/{vehicle_tag}/command/charge_start

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_start' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_start", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_start")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/charge_start", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

开始车辆充电

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

charge_stop

POST /api/1/vehicles/{vehicle_tag}/command/charge_stop

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_stop' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_stop", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/charge_stop")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/charge_stop", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

停止车辆充电

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

clear_pin_to_drive_admin

POST /api/1/vehicles/{vehicle_tag}/command/clear_pin_to_drive_admin

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/clear_pin_to_drive_admin' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/clear_pin_to_drive_admin", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/clear_pin_to_drive_admin")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/clear_pin_to_drive_admin", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

停用PIN驾驶并重置相关PIN,车辆运行固件版本需高于2023.44。此命令仅适用于车队管理员或所有者。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

door_lock

POST /api/1/vehicles/{vehicle_tag}/command/door_lock

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/door_lock' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/door_lock", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/door_lock")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/door_lock", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

锁车门

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

door_unlock

POST /api/1/vehicles/{vehicle_tag}/command/door_unlock

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/door_unlock' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/door_unlock", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/door_unlock")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/door_unlock", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

解锁车门

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

erase_user_data

POST /api/1/vehicles/{vehicle_tag}/command/erase_user_data

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/erase_user_data' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/erase_user_data", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/erase_user_data")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/erase_user_data", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

从用户界面中删除用户数据。车辆必须处于停放状态。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

flash_lights

POST /api/1/vehicles/{vehicle_tag}/command/flash_lights

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/flash_lights' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/flash_lights", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/flash_lights")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/flash_lights", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

车辆前灯短暂闪烁。车辆必须处于驻车状态。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

guest_mode

POST /api/1/vehicles/{vehicle_tag}/command/guest_mode

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/guest_mode' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/guest_mode", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/guest_mode")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/guest_mode", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

  • 限制访客驾驶员使用某些车辆 UI 功能:
    • 驾驶员 PIN 码
    • 限速模式
    • 手套箱密码
    • 添加/删除车辆钥匙
    • 编辑车辆昵称
  • 允许在车辆上擦除用户数据
  • 允许用户使用车辆钥匙卡设置特斯拉手机应用程序访问权限:
    • 用户使用钥匙卡解锁或认证车辆启动时,车载触摸屏将提示用户扫描二维码,将其手机设置为车辆钥匙。
      • 二维码为一次性使用,10分钟后失效。
      • 需要车辆固件版本 2024.14 或更高版本
    • 任何扫描该二维码的账号都将能通过特斯拉应用程序访问此车辆,并且该账号的特斯拉个人资料将被下载到车内。
      • 特斯拉应用程序访问权限允许用户查看车辆实时位置,发送远程指令,并且在车辆蓝牙范围内将手机设置为钥匙。
      • 客人访问权限无法使用某些驾驶员访问功能,例如维修和道路救援。
    • 客人访问权限会在以下情况自动移除:
      • 使用钥匙卡驾驶车辆。
      • 扫描新二维码(一次仅允许一位访客)。
      • 客人访问权限已禁用。
    • 此外,还可以使用 drivers remove api 端点远程撤销访客访问权限
    • 如果用户没有安装应用程序,他们将看到此网页 (https://www.tesla.com/_gs/test) 为了指导他们完成此过程。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
enable 正文 boolean
点击查看成功回复{ "response": { "result": true, "reason": "" } }

honk_horn

POST /api/1/vehicles/{vehicle_tag}/command/honk_horn

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/honk_horn' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/honk_horn", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/honk_horn")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/honk_horn", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

鸣笛。车辆必须处于驻车状态。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

media_next_fav

POST /api/1/vehicles/{vehicle_tag}/command/media_next_fav

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_next_fav' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_next_fav", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_next_fav")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/media_next_fav", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

将媒体播放器前进到下一个最喜欢的曲目。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

media_next_track

POST /api/1/vehicles/{vehicle_tag}/command/media_next_track

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_next_track' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_next_track", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_next_track")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/media_next_track", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

将媒体播放器前进到下一个曲目。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

media_prev_fav

POST /api/1/vehicles/{vehicle_tag}/command/media_prev_fav

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_prev_fav' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_prev_fav", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_prev_fav")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/media_prev_fav", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

将媒体播放器前进到上一个最喜欢的曲目。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

media_prev_track

POST /api/1/vehicles/{vehicle_tag}/command/media_prev_track

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_prev_track' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_prev_track", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_prev_track")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/media_prev_track", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

将媒体播放器前进到上一曲目。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

media_toggle_playback

POST /api/1/vehicles/{vehicle_tag}/command/media_toggle_playback

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_toggle_playback' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_toggle_playback", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_toggle_playback")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/media_toggle_playback", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

切换当前播放/暂停状态。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

media_volume_down

POST /api/1/vehicles/{vehicle_tag}/command/media_volume_down

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_volume_down' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_volume_down", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/media_volume_down")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/media_volume_down", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

将音量调低一格。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

POST /api/1/vehicles/{vehicle_tag}/command/navigation_gps_request

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/navigation_gps_request' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/navigation_gps_request", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/navigation_gps_request")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/navigation_gps_request", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

开始导航到给定坐标。Order 可用于指定多个停靠点的顺序。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
lat 正文 number
lon 正文 number
order 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

POST /api/1/vehicles/{vehicle_tag}/command/navigation_request

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/navigation_request' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/navigation_request", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/navigation_request")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/navigation_request", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

将位置发送至车载导航系统。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
type 正文 string
value 正文 Unknown
locale 正文 string
timestamp_ms 正文 string
点击查看成功回复{ "response": { "result": true, "queued": true } }

POST /api/1/vehicles/{vehicle_tag}/command/navigation_sc_request

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/navigation_sc_request' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/navigation_sc_request", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/navigation_sc_request")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/navigation_sc_request", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

导航到超充站点

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
id 正文 integer
order 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

remote_auto_seat_climate_request

POST /api/1/vehicles/{vehicle_tag}/command/remote_auto_seat_climate_request

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_auto_seat_climate_request' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_auto_seat_climate_request", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_auto_seat_climate_request")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/remote_auto_seat_climate_request", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置自动座椅加热和冷却。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
auto_seat_position 正文 integer
auto_climate_on 正文 boolean
点击查看成功回复{ "response": { "result": true, "reason": "" } }

remote_auto_steering_wheel_heat_climate_request

POST /api/1/vehicles/{vehicle_tag}/command/remote_auto_steering_wheel_heat_climate_request

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_auto_steering_wheel_heat_climate_request' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_auto_steering_wheel_heat_climate_request", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_auto_steering_wheel_heat_climate_request")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/remote_auto_steering_wheel_heat_climate_request", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

设置自动方向盘加热开/关。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
on 正文 boolean
点击查看成功回复{ "response": { "result": true, "reason": "" } }

remote_boombox

POST /api/1/vehicles/{vehicle_tag}/command/remote_boombox

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_boombox' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_boombox", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_boombox")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/remote_boombox", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

在车辆外部扬声器播放声音。

声音ID:

  • 0:随机放屁

  • 2000:定位哔声

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
sound 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

remote_seat_cooler_request

POST /api/1/vehicles/{vehicle_tag}/command/remote_seat_cooler_request

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_seat_cooler_request' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_seat_cooler_request", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_seat_cooler_request")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/remote_seat_cooler_request", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置座椅冷却。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
seat_position 正文 integer
seat_cooler_level 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

remote_seat_heater_request

POST /api/1/vehicles/{vehicle_tag}/command/remote_seat_heater_request

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_seat_heater_request' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_seat_heater_request", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_seat_heater_request")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/remote_seat_heater_request", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置座椅加热。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

remote_start_drive

POST /api/1/vehicles/{vehicle_tag}/command/remote_start_drive

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_start_drive' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_start_drive", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_start_drive")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/remote_start_drive", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

远程启动车辆。需要启用无钥匙驾驶。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

remote_steering_wheel_heat_level_request

POST /api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heat_level_request

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heat_level_request' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heat_level_request", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heat_level_request")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heat_level_request", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置方向盘温度。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
level 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

remote_steering_wheel_heater_request

POST /api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heater_request

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heater_request' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heater_request", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heater_request")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/remote_steering_wheel_heater_request", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置方向盘加热功能的开/关。适用于不支持自动方向盘加热的车辆。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
on 正文 boolean
点击查看成功回复{ "response": { "result": true, "reason": "" } }

reset_pin_to_drive_pin

POST /api/1/vehicles/{vehicle_tag}/command/reset_pin_to_drive_pin

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/reset_pin_to_drive_pin' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/reset_pin_to_drive_pin", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/reset_pin_to_drive_pin")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/reset_pin_to_drive_pin", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

移除驾驶的PIN。 要求车辆处于“使用pin驾驶”模式而不是“代客泊车”模式。请注意,此命令仅在PIN码未激活时有效。此命令必须使用Tesla车辆命令协议 - 有关更多信息,请参阅此文档

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

reset_valet_pin

POST /api/1/vehicles/{vehicle_tag}/command/reset_valet_pin

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/reset_valet_pin' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/reset_valet_pin", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/reset_valet_pin")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/reset_valet_pin", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

删除代客模式的PIN。要使用此命令,必须禁用代客模式。 请参阅 set_valet_mode

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

schedule_software_update

POST /api/1/vehicles/{vehicle_tag}/command/schedule_software_update

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/schedule_software_update' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/schedule_software_update", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/schedule_software_update")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/schedule_software_update", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

安排将来安装的车辆软件更新的时间(无线“OTA”)。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
offset_sec 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_bioweapon_mode

POST /api/1/vehicles/{vehicle_tag}/command/set_bioweapon_mode

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_bioweapon_mode' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_bioweapon_mode", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_bioweapon_mode")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_bioweapon_mode", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

打开和关闭生物武器防御模式。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
on 正文 boolean
manual_override 正文 boolean
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_cabin_overheat_protection

POST /api/1/vehicles/{vehicle_tag}/command/set_cabin_overheat_protection

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_cabin_overheat_protection' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_cabin_overheat_protection", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_cabin_overheat_protection")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_cabin_overheat_protection", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置车辆过热保护。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
on 正文 boolean
fan_only 正文 boolean
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_charge_limit

POST /api/1/vehicles/{vehicle_tag}/command/set_charge_limit

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_charge_limit' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_charge_limit", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_charge_limit")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_charge_limit", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置车辆充电限额。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
percent 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_charging_amps

POST /api/1/vehicles/{vehicle_tag}/command/set_charging_amps

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_charging_amps' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_charging_amps", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_charging_amps")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_charging_amps", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置车辆充电电流。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
charging_amps 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_climate_keeper_mode

POST /api/1/vehicles/{vehicle_tag}/command/set_climate_keeper_mode

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_climate_keeper_mode' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_climate_keeper_mode", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_climate_keeper_mode")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_climate_keeper_mode", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

启用温度保持模式。可设置的值为 0,1,2,3。分别对应 “关闭”, “保持模式”, “宠物模式”,“露营模式”

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
climate_keeper_mode 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_cop_temp

POST /api/1/vehicles/{vehicle_tag}/command/set_cop_temp

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_cop_temp' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_cop_temp", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_cop_temp")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_cop_temp", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

调节驾驶室过热保护温度(COP)。该命令不会激活COP。精确的目标温度取决于用户是否选择了C或F。可接受的值为:“0”、“1”、“2”。分别映射到低(90F/30C)、中(95F/35C)、高(100F/40C)。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
cop_temp 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_pin_to_drive

POST /api/1/vehicles/{vehicle_tag}/command/set_pin_to_drive

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_pin_to_drive' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_pin_to_drive", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_pin_to_drive")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_pin_to_drive", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置四位数的驾驶PIN。必须先输入该PIN码,然后才能驾驶车辆。设置PIN码后,即使禁用PIN码驾驶,车辆也会记住其值,并且会丢弃使用此方法提供的任何新PIN码。要更改现有PIN,请首先调用Reset_pin_to_drive_pin。此命令必须使用Tesla车辆命令协议 - 有关更多信息,请参阅此文档

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
on 正文 boolean
password 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_preconditioning_max

POST /api/1/vehicles/{vehicle_tag}/command/set_preconditioning_max

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_preconditioning_max' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_preconditioning_max", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_preconditioning_max")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_preconditioning_max", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置空调预处理的覆盖 - 如果不使用覆盖,则它应默认为空。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
on 正文 boolean
manual_override 正文 boolean
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_scheduled_charging

POST /api/1/vehicles/{vehicle_tag}/command/set_scheduled_charging

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_scheduled_charging' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_scheduled_charging", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_scheduled_charging")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_scheduled_charging", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置充电完成的时间。 time参数是0:00过后的分钟(例如:time=120 计划在车辆当地时间凌晨 2:00 充电)

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
enable 正文 boolean
time 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_scheduled_departure

POST /api/1/vehicles/{vehicle_tag}/command/set_scheduled_departure

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_scheduled_departure' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_scheduled_departure", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_scheduled_departure")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_scheduled_departure", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置完成出发的时间。 departure_timeend_off_peak_time 参数是午夜后的分钟数(例如:departure_time=120 安排车辆当地时间凌晨 2:00 出发)。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
enable 正文 boolean
departure_time 正文 integer
off_peak_charging_enabled 正文 boolean
off_peak_charging_weekdays_only 正文 boolean
preconditioning_enabled 正文 boolean
end_off_peak_time 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_sentry_mode

POST /api/1/vehicles/{vehicle_tag}/command/set_sentry_mode

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_sentry_mode' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_sentry_mode", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_sentry_mode")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_sentry_mode", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

启用和禁用哨兵模式。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
on 正文 boolean
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_temps

POST /api/1/vehicles/{vehicle_tag}/command/set_temps

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_temps' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_temps", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_temps")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_temps", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置驾驶员侧和/或乘客侧车厢温度(如果启用同步,则设置其他区域)。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
driver_temp 正文 integer
passenger_temp 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_valet_mode

POST /api/1/vehicles/{vehicle_tag}/command/set_valet_mode

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_valet_mode' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_valet_mode", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_valet_mode")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_valet_mode", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

打开代客模式并设置一个四位数的密码,然后必须输入该密码才能禁用代客模式。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
on 正文 boolean
password 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

set_vehicle_name

POST /api/1/vehicles/{vehicle_tag}/command/set_vehicle_name

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_vehicle_name' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_vehicle_name", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/set_vehicle_name")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/set_vehicle_name", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

更改车辆的名称。此命令必须使用Tesla车辆命令协议 - 有关更多信息,请参阅此文档

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
vehicle_name 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

speed_limit_activate

POST /api/1/vehicles/{vehicle_tag}/command/speed_limit_activate

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_activate' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_activate", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_activate")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/speed_limit_activate", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

使用四位PIN码激活限速模式。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
pin 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

speed_limit_clear_pin

POST /api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

停用速度限制模式并重置关联的PIN。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
pin 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

speed_limit_clear_pin_admin

POST /api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin_admin

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin_admin' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin_admin", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin_admin")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/speed_limit_clear_pin_admin", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

停用限速模式并重置相关PIN, 车辆运行固件版本需高于2023.38+。此命令仅适用于车队管理员或所有者。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "result": true, "reason": "" } }

speed_limit_deactivate

POST /api/1/vehicles/{vehicle_tag}/command/speed_limit_deactivate

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_deactivate' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_deactivate", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_deactivate")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/speed_limit_deactivate", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

停用限速模式。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
pin 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

speed_limit_set_limit

POST /api/1/vehicles/{vehicle_tag}/command/speed_limit_set_limit

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_set_limit' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_set_limit", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/speed_limit_set_limit")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/speed_limit_set_limit", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

设置速度限制模式的最大速度(以英里/小时为单位)。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
limit_mph 正文 integer
点击查看成功回复{ "response": { "result": true, "reason": "" } }

sun_roof_control

POST /api/1/vehicles/{vehicle_tag}/command/sun_roof_control

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/sun_roof_control' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/sun_roof_control", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/sun_roof_control")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/sun_roof_control", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

控制具有天窗功能的车辆上的天窗。

支持的状态:停止、关闭和通风。Control the sunroof on sunroof-enabled vehicles.

Supported states: stop, close, and vent.

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
state 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

take_drivenote

POST /api/1/vehicles/{vehicle_tag}/command/take_drivenote

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/take_drivenote' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/take_drivenote", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/take_drivenote")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/take_drivenote", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

记录驾驶笔记。note参数的长度被截断为80个字符。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
note 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

POST /api/1/vehicles/{vehicle_tag}/command/trigger_homelink

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/trigger_homelink' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/trigger_homelink", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/trigger_homelink")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/trigger_homelink", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

⚠️ 现代车辆需要使用Tesla车辆命令协议(参考详细资料). ⚠️

打开HomeLink(用于打开和关闭车库门)。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
lat 正文 number
lon 正文 number
token 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

upcoming_calendar_entries

POST /api/1/vehicles/{vehicle_tag}/command/upcoming_calendar_entries

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/upcoming_calendar_entries' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/upcoming_calendar_entries", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/upcoming_calendar_entries")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/upcoming_calendar_entries", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

即将到来的日历条目存储在车辆上。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
calendar_data 正文 string
点击查看成功回复{ "response": { "reason": "", "result": true } }

window_control

POST /api/1/vehicles/{vehicle_tag}/command/window_control

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/window_control' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/window_control", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/command/window_control")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/command/window_control", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

控制停放车辆的车窗。支持的命令: vent和close。关闭时,指定用户的纬度和经度,以确保它们在车辆的范围内(除非这是M3平台车辆)。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
lat 正文 number
lon 正文 number
command 正文 string
点击查看成功回复{ "response": { "result": true, "reason": "" } }

车辆端点 (vehicle_endpoints)

drivers

GET /api/1/vehicles/{vehicle_tag}/drivers

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/drivers' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/drivers", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/drivers")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles/{vehicle_tag}/drivers", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回车辆的所有允许的驾驶员。该端点仅供车主使用。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": [ { "my_tesla_unique_id": 8888888, "user_id": 800001, "user_id_s": "800001", "vault_uuid": "b5c443af-a286-49eb-a4ad-35a97963155d", "driver_first_name": "Testy", "driver_last_name": "McTesterson", "granular_access": { "hide_private": false }, "active_pubkeys": [], "public_key": "" } ], "count": 1 }

drivers_remove

DELET /api/1/vehicles/{vehicle_tag}/drivers

授权范围: vehicle_cmds

curl --request DELETE \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/drivers' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'DELETE',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/drivers", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/drivers")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("DELETE", "/api/1/vehicles/{vehicle_tag}/drivers", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

取消驾驶员对车辆的访问。共享用户只能删除自己的访问权限。所有者可以删除共享访问权限或自己的访问权限。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
share_user_id 查询 integer user id from a share
点击查看成功回复{ "response": "ok" }

eligible_subscriptions

GET /api/1/dx/vehicles/subscriptions/eligibility

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/vehicles/subscriptions/eligibility' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/vehicles/subscriptions/eligibility", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/vehicles/subscriptions/eligibility")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/dx/vehicles/subscriptions/eligibility", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回符合条件的车辆订阅

参数

姓名 类型 必需的 描述
vin 查询 string Vin
点击查看成功回复{ "response": { "country": "string", "eligible": [ { "addons": [ { "billingPeriod": "string", "currencyCode": "string", "optionCode": "string", "price": 0, "tax": 0, "total": 0 } ], "billingOptions": [ { "billingPeriod": "string", "currencyCode": "string", "optionCode": "string", "price": 0, "tax": 0, "total": 0 } ], "optionCode": "string", "product": "string", "startDate": "string" } ], "vin": "string" } }

eligible_upgrades

GET /api/1/dx/vehicles/upgrades/eligibility

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/vehicles/upgrades/eligibility' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/vehicles/upgrades/eligibility", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/vehicles/upgrades/eligibility")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/dx/vehicles/upgrades/eligibility", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回符合条件的车辆升级。

参数

姓名 类型 必需的 描述
vin 查询 string Vin
点击查看成功回复{ "response": { "vin": "TEST00000000VIN01", "country": "US", "type": "VEHICLE", "eligible": [ { "optionCode": "$FM3U", "optionGroup": "PERF_FIRMWARE", "currentOptionCode": "$FM3B", "pricing": [ { "price": 2000, "total": 2000, "currencyCode": "USD", "isPrimary": true } ] } ] } }

fleet_status

POST /api/1/vehicles/fleet_status

授权范围: vehicle_device_data

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/fleet_status' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/fleet_status", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/fleet_status")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/fleet_status", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

用于检查你的共钥是否已经和提供的车辆相配对。

参数

姓名 类型 必需的 描述
vins 正文 array Vehicle Identification Number (VIN)列表
点击查看成功回复{ "response": { "key_paired_vins": [], "unpaired_vins": [ "5YJ3000000NEXUS01" ], "vehicle_info": { "5YJ3000000NEXUS01": { "firmware_version": "2024.14.30" } } } }

fleet_telemetry_config create

POST /api/1/vehicles/fleet_telemetry_config

授权范围: vehicle_device_data

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/fleet_telemetry_config' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/fleet_telemetry_config", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/fleet_telemetry_config")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/fleet_telemetry_config", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

配置车辆以连接到自托管fleet-telemetry< /a> 服务器。 该端点并发度为1(同时调用多个会返回状态429)。 一次调用即可配置多辆车辆。

如果未配置任何指定的 VIN,则响应将包含“skipped_vehicles”。 VIN 可能被拒绝的原因:

参数

姓名 类型 必需的 描述
vins 正文 array 车辆识别号(VIN)列表。
config.hostname 正文 string 舰队遥测服务器的url,必须与注册应用程序的根域(二级+一级域)匹配
config.ca 正文 string fleet-telemetry服务器的公共证书颁发机构证书
config.fields.<field_to_stream>.interval_seconds 正文 integer 将字段流式传输到服务器的时间间隔(以秒为单位)。详尽的清单<field_to_stream>可以在此链接找到.
config.alert_types 正文 array fleet-telemetry服务器需要捕获的警报列表。
config.exp 正文 integer 当前配置的过期时间(以秒为单位的纪元时间)。 如果未指定,配置将无限期有效。
config.port 正文 integer 车队遥测服务器端口。
点击查看成功回复{ "response": { "updated_vehicles": 1, "skipped_vehicles": { "missing_key": [], "unsupported_hardware": [ "5YJ3000000NEXUS02" ], "unsupported_firmware": [ "5YJ3000000NEXUS02" ] } } }

fleet_telemetry_config delete

DELET /api/1/vehicles/{vehicle_tag}/fleet_telemetry_config

授权范围: vehicle_device_data

curl --request DELETE \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/fleet_telemetry_config' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'DELETE',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/fleet_telemetry_config", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/fleet_telemetry_config")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("DELETE", "/api/1/vehicles/{vehicle_tag}/fleet_telemetry_config", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Disconnects vehicles to stream telemetry data to self hosted fleet-telemetry server.

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "updated_vehicles": 1 } }

fleet_telemetry_config get

GET /api/1/vehicles/{vehicle_tag}/fleet_telemetry_config

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/fleet_telemetry_config' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/fleet_telemetry_config", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/fleet_telemetry_config")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles/{vehicle_tag}/fleet_telemetry_config", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Fetches a vehicle's fleet telemetry config. synced set to true means the vehicle has adopted the target config. synced set to false means the vehicle will attempt to adopt the target config when it next establishes a backend connection.

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "synced": true, "config": { "hostname": "test-telemetry.com", "ca": "-----BEGIN CERTIFICATE-----\ncert\n-----END CERTIFICATE-----\n", "exp": 1704067200, "port": 4443, "fields": { "DriveRail": { "interval_seconds": 1800 }, "BmsFullchargecomplete": { "interval_seconds": 1800 } }, "alert_types": [ "service" ] } } }

list

GET /api/1/vehicles

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回此账户下车辆的列表.

参数

姓名 类型 必需的 描述
page 查询 integer 页号
per_page 查询 integer 每页数量
点击查看成功回复{ "response": [ { "id": 100021, "vehicle_id": 99999, "vin": "TEST00000000VIN01", "color": null, "access_type": "OWNER", "display_name": "Owned", "option_codes": "TEST0,COUS", "granular_access": { "hide_private": false }, "tokens": [ "4f993c5b9e2b937b", "7a3153b1bbb48a96" ], "state": null, "in_service": false, "id_s": "100021", "calendar_enabled": true, "api_version": null, "backseat_token": null, "backseat_token_updated_at": null } ], "pagination": { "previous": null, "next": null, "current": 1, "per_page": 2, "count": 2, "pages": 1 }, "count": 1 }

mobile_enabled

GET /api/1/vehicles/{vehicle_tag}/mobile_enabled

授权范围: vehicle_cmds

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/mobile_enabled' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/mobile_enabled", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/mobile_enabled")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles/{vehicle_tag}/mobile_enabled", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回车辆是否启用移动端设备(如APP)访问。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "reason": "", "result": true } }

nearby_charging_sites

GET /api/1/vehicles/{vehicle_tag}/nearby_charging_sites

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/nearby_charging_sites' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/nearby_charging_sites", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/nearby_charging_sites")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles/{vehicle_tag}/nearby_charging_sites", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回车辆当前位置附近的充电站。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
count 查询 integer 返回总数
radius 查询 integer 半径(英里)
detail 查询 boolean 包括站点详细信息
点击查看成功回复{ "response": { "congestion_sync_time_utc_secs": 1693588513, "destination_charging": [ { "location": { "lat": 37.409314, "long": -122.123068 }, "name": "Hilton Garden Inn Palo Alto", "type": "destination", "distance_miles": 1.35024, "amenities": "restrooms,wifi,lodging" }, { "location": { "lat": 37.407771, "long": -122.120076 }, "name": "Dinah's Garden Hotel & Poolside Restaurant", "type": "destination", "distance_miles": 1.534213, "amenities": "restrooms,restaurant,wifi,cafe,lodging" } ], "superchargers": [ { "location": { "lat": 37.399071, "long": -122.111216 }, "name": "Los Altos, CA", "type": "supercharger", "distance_miles": 2.202902, "available_stalls": 12, "total_stalls": 16, "site_closed": false, "amenities": "restrooms,restaurant,wifi,cafe,shopping", "billing_info": "" }, { "location": { "lat": 37.441734, "long": -122.170202 }, "name": "Palo Alto, CA - Stanford Shopping Center", "type": "supercharger", "distance_miles": 2.339135, "available_stalls": 11, "total_stalls": 20, "site_closed": false, "amenities": "restrooms,restaurant,wifi,cafe,shopping", "billing_info": "" } ], "timestamp": 1693588576552 } }

options

GET /api/1/dx/vehicles/options

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/vehicles/options' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/vehicles/options", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/vehicles/options")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/dx/vehicles/options", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回车辆选项详细信息。(暂未开放,即将推出)

参数

姓名 类型 必需的 描述
vin 查询 string Vin
点击查看成功回复{ "response": { "codes": [ { "code": "$MT315", "displayName": "Long Range All-Wheel Drive", "isActive": true }, { "code": "$PPSW", "colorCode": "PPSW", "displayName": "Pearl White Multi-Coat", "isActive": true }, { "code": "$W40B", "displayName": "18’’ Aero Wheels", "isActive": true }, { "code": "$IPB0", "displayName": "All Black Premium Interior", "isActive": true }, { "code": "$APBS", "displayName": "Basic Autopilot", "isActive": true }, { "code": "$APF2", "displayName": "Full Self-Driving Capability", "isActive": true }, { "code": "$SC04", "displayName": "Supercharger Network Access + Pay-as-you-go", "isActive": true } ] } }

recent_alerts

GET /api/1/vehicles/{vehicle_tag}/recent_alerts

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/recent_alerts' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/recent_alerts", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/recent_alerts")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles/{vehicle_tag}/recent_alerts", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

最近警报列表

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "recent_alerts": [ { "name": "Name_Of_The_Alert", "time": "2021-03-19T22:01:15.101+00:00", "audience": [ "service-fix", "customer" ], "user_text": "additional description text" } ] } }

release_notes

GET /api/1/vehicles/{vehicle_tag}/release_notes

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/release_notes' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/release_notes", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/release_notes")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles/{vehicle_tag}/release_notes", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回固件的版本信息

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
staged 查询 boolean returns upcoming software update release notes when set to true
language 查询 integer language locale
点击查看成功回复{ "response": { "response": { "release_notes": [ { "title": "Minor Fixes", "subtitle": "Some more info", "description": "This release contains minor fixes and improvements", "customer_version": "2022.42.0", "icon": "release_notes_icon", "image_url": "https://vehicle-files.teslamotors.com/release_notes/d0fa3e08a458696e6464a46c938ffc0a", "light_image_url": "https://vehicle-files.teslamotors.com/release_notes/9a122cff8916fffcb61cfd65a15c276f" } ] } } }

service_data

GET /api/1/vehicles/{vehicle_tag}/service_data

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/service_data' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/service_data", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/service_data")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles/{vehicle_tag}/service_data", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

获取有关车辆维护状态的信息。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "service_status": "in_service", "service_etc": "2023-05-02T17:10:53-10:00", "service_visit_number": "SV12345678", "status_id": 8 } }

share_invites

GET /api/1/vehicles/{vehicle_tag}/invitations

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/invitations' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/invitations", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/invitations")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles/{vehicle_tag}/invitations", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回车辆的有效共享邀请。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 string 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": [ { "id": 429509621657, "owner_id": 429511308124, "share_user_id": null, "product_id": "TEST00000000VIN01", "state": "pending", "code": "aqwl4JHU2q4aTeNROz8W9SpngoFvj-ReuDFIJs6-YOhA", "expires_at": "2023-06-29T00:42:00.000Z", "revoked_at": null, "borrowing_device_id": null, "key_id": null, "product_type": "vehicle", "share_type": "customer", "share_user_sso_id": null, "active_pubkeys": [ null ], "id_s": "429509621657", "owner_id_s": "429511308124", "share_user_id_s": "", "borrowing_key_hash": null, "vin": "TEST00000000VIN01", "share_link": "https://www.tesla.com/_rs/1/aqwl4JHU2q4aTeNROz8W9SpngoFvj-ReuDFIJs6-YOhA" } ], "pagination": { "previous": null, "next": null, "current": 1, "per_page": 25, "count": 1, "pages": 1 }, "count": 1 }

share_invites create

POST /api/1/vehicles/{vehicle_tag}/invitations

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/invitations' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/invitations", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/invitations")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/invitations", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
  • 每个邀请链接仅供一次性使用,并在24小时后过期。
  • 使用邀请的帐户将获得Tesla应用程序对车辆的驾驶员访问权限,从而可以执行以下操作:
    • 查看车辆的实时位置。
    • 发送远程命令。
    • 将用户的特斯拉个人资料下载到车辆
  • 要删除访问权限,请使用撤销API
  • 如果用户没有安装Tesla应用程序,他们将被转跳至网页获得更多指引。
  • 当用户靠近车辆时,可以使用Tesla应用程序将手机设置为钥匙。
  • Tesla应用程序访问权限提供驾驶员权限,但不包含所有所有者功能。
  • 一次最多可以添加五个驾驶员。
  • 该API不需要车辆在线。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 string 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "id": 429509621657, "owner_id": 429511308124, "share_user_id": null, "product_id": "TEST00000000VIN01", "state": "pending", "code": "aqwl4JHU2q4aTeNROz8W9SpngoFvj-ReuDFIJs6-YOhA", "expires_at": "2023-06-29T00:42:00.000Z", "revoked_at": null, "borrowing_device_id": null, "key_id": null, "product_type": "vehicle", "share_type": "customer", "share_user_sso_id": null, "active_pubkeys": [ null ], "id_s": "429509621657", "owner_id_s": "429511308124", "share_user_id_s": "", "borrowing_key_hash": null, "vin": "TEST00000000VIN01", "share_link": "https://www.tesla.com/_rs/1/aqwl4JHU2q4aTeNROz8W9SpngoFvj-ReuDFIJs6-YOhA" } }

share_invites redeem

POST /api/1/invitations/redeem

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/invitations/redeem' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/invitations/redeem", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/invitations/redeem")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/invitations/redeem", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

兑换分享邀请。兑换后,该帐户将可以在Tesla应用程序中访问车辆。

参数

姓名 类型 必需的 描述
code 正文 string invitation code
点击查看成功回复{ "response": { "vehicle_id_s": "88850", "vin": "5YJY000000NEXUS01" } }

share_invites revoke

POST /api/1/vehicles/{vehicle_tag}/invitations/{id}/revoke

授权范围: vehicle_cmds

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/invitations/{id}/revoke' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/invitations/{id}/revoke", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/invitations/{id}/revoke")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/invitations/{id}/revoke", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

撤销共享邀请。这会使共享无效并使链接无效。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 string 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
id 路径 string 将被撤销的功效邀请的id
点击查看成功回复{ "response": true }

signed_command

POST /api/1/vehicles/{vehicle_tag}/signed_command

授权范围: 以下之一 - vehicle_cmds, vehicle_charging_cmds, vehicle_device_data

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/signed_command' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/signed_command", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/signed_command")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/signed_command", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

向车辆发送特斯拉车辆命令协议。请参阅车辆命令SDK了解更多信息。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
routable_message 正文 string Base64 encoded Tesla Vehicle Command Protocol message.
点击查看成功回复{ "response": "base64_response" }

subscriptions

GET /api/1/subscriptions

授权范围: user_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/subscriptions' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/subscriptions", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/subscriptions")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/subscriptions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回此移动设备当前订阅推送通知的车辆列表

参数

姓名 类型 必需的 描述
device_token 查询 string APNS设备的令牌或者是GCM的注册id
device_type 查询 string 设备类型,例如 'android', 'ios-development', 'ios-enterprise', 'ios-beta', 'ios-production'
点击查看成功回复{ "vehicle": { "ids": [ 100021 ], "count": 1 }, "energy_site": { "ids": [ 429500927973 ], "count": 1 } }

subscriptions create

POST /api/1/subscriptions

授权范围: user_data

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/subscriptions' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/subscriptions", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/subscriptions")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/subscriptions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

允许移动设备指定从哪些车辆接收推送通知。当从移动设备呼叫时,仅提供移动设备希望订阅的车辆 ID 就足够了。

参数

姓名 类型 必需的 描述
device_token 查询 string APNS设备的令牌或者是GCM的注册id
device_type 查询 string 设备类型,例如 'android', 'ios-development', 'ios-enterprise', 'ios-beta', 'ios-production'
点击查看成功回复{ "vehicle": { "ids": [ 100021 ], "count": 1 }, "energy_site": { "ids": [ 429500927973 ], "count": 1 } }

vehicle

GET /api/1/vehicles/{vehicle_tag}

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles/{vehicle_tag}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回车辆信息

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "id": 100021, "vehicle_id": 99999, "vin": "TEST00000000VIN01", "color": null, "access_type": "OWNER", "display_name": "Owned", "option_codes": "TEST0,COUS", "granular_access": { "hide_private": false }, "tokens": [ "4f993c5b9e2b937b", "7a3153b1bbb48a96" ], "state": null, "in_service": false, "id_s": "100021", "calendar_enabled": true, "api_version": null, "backseat_token": null, "backseat_token_updated_at": null } }

vehicle_data

GET /api/1/vehicles/{vehicle_tag}/vehicle_data

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/vehicle_data' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/vehicle_data", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/vehicle_data")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicles/{vehicle_tag}/vehicle_data", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

对车辆进行实时呼叫。如果车辆离线,可能会返回缓存的数据。对于运行固件版本2023.38+的车辆,需要location_data来获取车辆位置。这将导致位置共享图标显示在车辆UI上。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
endpoints 查询 string 采用URL编码、分号分隔值的字符串。可以有包含多个以下值:'charge_state', 'climate_state', 'closures_state', 'drive_state', 'gui_settings', 'location_data', 'vehicle_config', 'vehicle_state', 'vehicle_data_combo'
点击查看成功回复{ "response": { "id": 100021, "user_id": 800001, "vehicle_id": 99999, "vin": "TEST00000000VIN01", "color": null, "access_type": "OWNER", "granular_access": { "hide_private": false }, "tokens": [ "4f993c5b9e2b937b", "7a3153b1bbb48a96" ], "state": null, "in_service": false, "id_s": "100021", "calendar_enabled": true, "api_version": 54, "backseat_token": null, "backseat_token_updated_at": null, "charge_state": { "battery_heater_on": false, "battery_level": 42, "battery_range": 133.99, "charge_amps": 48, "charge_current_request": 48, "charge_current_request_max": 48, "charge_enable_request": true, "charge_energy_added": 48.45, "charge_limit_soc": 90, "charge_limit_soc_max": 100, "charge_limit_soc_min": 50, "charge_limit_soc_std": 90, "charge_miles_added_ideal": 202, "charge_miles_added_rated": 202, "charge_port_cold_weather_mode": false, "charge_port_color": "<invalid>", "charge_port_door_open": false, "charge_port_latch": "Engaged", "charge_rate": 0, "charger_actual_current": 0, "charger_phases": null, "charger_pilot_current": 48, "charger_power": 0, "charger_voltage": 2, "charging_state": "Disconnected", "conn_charge_cable": "<invalid>", "est_battery_range": 143.88, "fast_charger_brand": "<invalid>", "fast_charger_present": false, "fast_charger_type": "<invalid>", "ideal_battery_range": 133.99, "managed_charging_active": false, "managed_charging_start_time": null, "managed_charging_user_canceled": false, "max_range_charge_counter": 0, "minutes_to_full_charge": 0, "not_enough_power_to_heat": null, "off_peak_charging_enabled": false, "off_peak_charging_times": "all_week", "off_peak_hours_end_time": 360, "preconditioning_enabled": false, "preconditioning_times": "all_week", "scheduled_charging_mode": "Off", "scheduled_charging_pending": false, "scheduled_charging_start_time": null, "scheduled_departure_time": 1634914800, "scheduled_departure_time_minutes": 480, "supercharger_session_trip_planner": false, "time_to_full_charge": 0, "timestamp": 1692141038420, "trip_charging": false, "usable_battery_level": 42, "user_charge_enable_request": null }, "climate_state": { "allow_cabin_overheat_protection": true, "auto_seat_climate_left": false, "auto_seat_climate_right": false, "auto_steering_wheel_heat": false, "battery_heater": false, "battery_heater_no_power": null, "bioweapon_mode": false, "cabin_overheat_protection": "On", "cabin_overheat_protection_actively_cooling": true, "climate_keeper_mode": "off", "cop_activation_temperature": "High", "defrost_mode": 0, "driver_temp_setting": 21, "fan_status": 0, "hvac_auto_request": "On", "inside_temp": 38.4, "is_auto_conditioning_on": true, "is_climate_on": false, "is_front_defroster_on": false, "is_preconditioning": false, "is_rear_defroster_on": false, "left_temp_direction": -293, "max_avail_temp": 28, "min_avail_temp": 15, "outside_temp": 36.5, "passenger_temp_setting": 21, "remote_heater_control_enabled": false, "right_temp_direction": -276, "seat_heater_left": 0, "seat_heater_rear_center": 0, "seat_heater_rear_left": 0, "seat_heater_rear_right": 0, "seat_heater_right": 0, "side_mirror_heaters": false, "steering_wheel_heat_level": 0, "steering_wheel_heater": false, "supports_fan_only_cabin_overheat_protection": true, "timestamp": 1692141038419, "wiper_blade_heater": false }, "drive_state": { "active_route_latitude": 37.7765494, "active_route_longitude": -122.4195418, "active_route_traffic_minutes_delay": 0, "gps_as_of": 1692137422, "heading": 289, "latitude": 37.7765494, "longitude": -122.4195418, "native_latitude": 37.7765494, "native_location_supported": 1, "native_longitude": -122.4195418, "native_type": "wgs", "power": 1, "shift_state": null, "speed": null, "timestamp": 1692141038420 }, "gui_settings": { "gui_24_hour_time": false, "gui_charge_rate_units": "mi/hr", "gui_distance_units": "mi/hr", "gui_range_display": "Rated", "gui_temperature_units": "F", "gui_tirepressure_units": "Psi", "show_range_units": false, "timestamp": 1692141038420 }, "vehicle_config": { "aux_park_lamps": "NaPremium", "badge_version": 0, "can_accept_navigation_requests": true, "can_actuate_trunks": true, "car_special_type": "base", "car_type": "modely", "charge_port_type": "US", "cop_user_set_temp_supported": true, "dashcam_clip_save_supported": true, "default_charge_to_max": false, "driver_assist": "TeslaAP3", "ece_restrictions": false, "efficiency_package": "MY2021", "eu_vehicle": false, "exterior_color": "MidnightSilver", "exterior_trim": "Black", "exterior_trim_override": "", "has_air_suspension": false, "has_ludicrous_mode": false, "has_seat_cooling": false, "headlamp_type": "Premium", "interior_trim_type": "Black2", "key_version": 2, "motorized_charge_port": true, "paint_color_override": "19,20,22,0.8,0.04", "performance_package": "Base", "plg": true, "pws": true, "rear_drive_unit": "PM216MOSFET", "rear_seat_heaters": 1, "rear_seat_type": 0, "rhd": false, "roof_color": "RoofColorGlass", "seat_type": null, "spoiler_type": "None", "sun_roof_installed": null, "supports_qr_pairing": false, "third_row_seats": "None", "timestamp": 1692141038420, "trim_badging": "74d", "use_range_badging": true, "utc_offset": -25200, "webcam_selfie_supported": true, "webcam_supported": true, "wheel_type": "Apollo19" }, "vehicle_state": { "api_version": 54, "autopark_state_v3": "ready", "autopark_style": "dead_man", "calendar_supported": true, "car_version": "2023.7.20 7910d26d5c64", "center_display_state": 0, "dashcam_clip_save_available": false, "dashcam_state": "Unavailable", "df": 0, "dr": 0, "fd_window": 0, "feature_bitmask": "15dffbff,0", "fp_window": 0, "ft": 0, "homelink_device_count": 3, "homelink_nearby": false, "is_user_present": false, "last_autopark_error": "no_error", "locked": true, "media_info": { "a2dp_source_name": "Pixel 6", "audio_volume": 2.6667, "audio_volume_increment": 0.333333, "audio_volume_max": 10.333333, "media_playback_status": "Playing", "now_playing_album": "KQED", "now_playing_artist": "PBS Newshour on KQED FM", "now_playing_duration": 0, "now_playing_elapsed": 0, "now_playing_source": "13", "now_playing_station": "88.5 FM KQED", "now_playing_title": "PBS Newshour" }, "media_state": { "remote_control_enabled": true }, "notifications_supported": true, "odometer": 15720.074889, "parsed_calendar_supported": true, "pf": 0, "pr": 0, "rd_window": 0, "remote_start": false, "remote_start_enabled": true, "remote_start_supported": true, "rp_window": 0, "rt": 0, "santa_mode": 0, "sentry_mode": false, "sentry_mode_available": true, "service_mode": false, "service_mode_plus": false, "smart_summon_available": true, "software_update": { "download_perc": 0, "expected_duration_sec": 2700, "install_perc": 1, "status": "", "version": " " }, "speed_limit_mode": { "active": false, "current_limit_mph": 85, "max_limit_mph": 120, "min_limit_mph": 50, "pin_code_set": false }, "summon_standby_mode_enabled": false, "timestamp": 1692141038419, "tpms_hard_warning_fl": false, "tpms_hard_warning_fr": false, "tpms_hard_warning_rl": false, "tpms_hard_warning_rr": false, "tpms_last_seen_pressure_time_fl": 1692136878, "tpms_last_seen_pressure_time_fr": 1692136878, "tpms_last_seen_pressure_time_rl": 1692136878, "tpms_last_seen_pressure_time_rr": 1692136878, "tpms_pressure_fl": 3.1, "tpms_pressure_fr": 3.1, "tpms_pressure_rl": 3.15, "tpms_pressure_rr": 3, "tpms_rcp_front_value": 2.9, "tpms_rcp_rear_value": 2.9, "tpms_soft_warning_fl": false, "tpms_soft_warning_fr": false, "tpms_soft_warning_rl": false, "tpms_soft_warning_rr": false, "valet_mode": false, "valet_pin_needed": true, "vehicle_name": "grADOFIN", "vehicle_self_test_progress": 0, "vehicle_self_test_requested": false, "webcam_available": true } } }

vehicle_subscriptions

GET /api/1/vehicle_subscriptions

授权范围: user_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicle_subscriptions' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicle_subscriptions", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicle_subscriptions")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/vehicle_subscriptions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回此移动设备当前订阅推送通知的车辆列表。

参数

姓名 类型 必需的 描述
device_token 查询 string 输入APNS的设备令牌或者GCM注册id
device_type 查询 string 设备类型,例如 'android', 'ios-development', 'ios-enterprise', 'ios-beta', 'ios-production'
点击查看成功回复{ "response": [ 100021 ], "count": 1 }

vehicle_subscriptions set

POST /api/1/vehicle_subscriptions

授权范围: user_data

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicle_subscriptions' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicle_subscriptions", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicle_subscriptions")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicle_subscriptions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

允许移动设备指定从哪些车辆接收推送通知。仅提供移动设备希望订阅的车辆ID就足够了。

参数

姓名 类型 必需的 描述
device_token 查询 string 输入APNS的设备令牌或者GCM注册id
device_type 查询 string 设备类型,例如 'android', 'ios-development', 'ios-enterprise', 'ios-beta', 'ios-production'
点击查看成功回复{ "response": [], "count": 0 }

wake_up

POST /api/1/vehicles/{vehicle_tag}/wake_up

授权范围: vehicle_device_data

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/wake_up' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'POST',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/wake_up", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles/{vehicle_tag}/wake_up")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("POST", "/api/1/vehicles/{vehicle_tag}/wake_up", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

将车辆从睡眠状态唤醒,睡眠状态能最大限度减少闲置能耗。

参数

姓名 类型 必需的 描述
vehicle_tag 路径 integer 车辆id或者VIN,这个值可以从/api/1/vehicles端点获取
点击查看成功回复{ "response": { "id": 100021, "user_id": 800001, "vehicle_id": 99999, "vin": "TEST00000000VIN01", "color": null, "access_type": "OWNER", "granular_access": { "hide_private": false }, "tokens": [ "4f993c5b9e2b937b", "7a3153b1bbb48a96" ], "state": null, "in_service": false, "id_s": "100021", "calendar_enabled": true, "api_version": null, "backseat_token": null, "backseat_token_updated_at": null } }

warranty_details

GET /api/1/dx/warranty/details

授权范围: vehicle_device_data

curl --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $TESLA_API_TOKEN" \
  'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/warranty/details' 
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", `Bearer ${process.env.TESLA_API_TOKEN}`);

const requestOptions = {
   method: 'GET',
   headers: myHeaders,
   redirect: 'follow'
};

fetch("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/warranty/details", requestOptions)
   .then(response => response.json())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"

url = URI("https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/dx/warranty/details")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer ENV_TESLA_API_TOKEN"

response = https.request(request)
puts response.read_body

import os
import http.client
import json

conn = http.client.HTTPSConnection("fleet-api.prd.cn.vn.cloud.tesla.cn")
payload = ''
headers = {
   'Content-Type': 'application/json',
   'Authorization': 'Bearer ENV_TESLA_API_TOKEN'
}
conn.request("GET", "/api/1/dx/warranty/details", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回车辆的保修信息。

参数

姓名 类型 必需的 描述
vin 查询 string VIN
点击查看成功回复{ "response": { "activeWarranty": [ { "warrantyType": "NEW_MFG_WARRANTY", "warrantyDisplayName": "Basic Vehicle Limited Warranty", "expirationDate": "2025-10-21T00:00:00Z", "expirationOdometer": 50000, "odometerUnit": "MI", "warrantyExpiredOn": null, "coverageAgeInYears": 4 }, { "warrantyType": "BATTERY_WARRANTY", "warrantyDisplayName": "Battery Limited Warranty", "expirationDate": "2029-10-21T00:00:00Z", "expirationOdometer": 120000, "odometerUnit": "MI", "warrantyExpiredOn": null, "coverageAgeInYears": 8 }, { "warrantyType": "DRIVEUNIT_WARRANTY", "warrantyDisplayName": "Drive Unit Limited Warranty", "expirationDate": "2029-10-21T00:00:00Z", "expirationOdometer": 120000, "odometerUnit": "MI", "warrantyExpiredOn": null, "coverageAgeInYears": 8 } ], "upcomingWarranty": [], "expiredWarranty": [] } }

常问问题

为什么有些调用会返回429?

这意味着该帐户已达到端点的请求速率限制。检查Retry-After请求标头(header, 以秒为单位)以确定何时发出下一个请求。请参阅有关响应代码的更多信息

为什么某些车辆呼叫会返回408?

这往往意味着设备处于离线状态。该设备有互联网连接吗?如果是这样,它是否处于睡眠状态(节省能源),在这种情况下可能需要唤醒它。

当我收到403 Unauthorized missing scopes 错误时,这意味着什么?

所提供的令牌不具有当前资源所需的授权范围。请查看端点的权限要求并确保令牌具有这些授权范围。如果令牌不是使用所需授权范围创建的,这说明所有者需要明确授予所需授权范围作为授权流程的一部分。

为什么我对新用户的 API 请求返回“未知用户”?

在代表帐户提出请求之前,帐户所有者必须至少登录Tesla移动应用程序一次。

为什么授权请求失败?

请重新阅读授权部分并完全按照示例进行操作。

我的身份验证请求返回 "We don't recognize this client_id and client_secret combination".

确保您遵循 授权 部分中给出的示例。

为什么我的请求中没有refresh_token?

根据授权范围部分,必须请求“offline_access”范围才能获取刷新令牌。

为什么我的刷新令牌突然失效了?

刷新令牌是一次性使用的,有效期为 3 个月。当您使用刷新令牌执行令牌交换时,请确保保存新的刷新令牌以供下次交换使用。

车队Telemetry

针对实时数据传输以及性能考量,车辆可以直接流式传输数据到您的服务器。请参阅https://developer.tesla.cn上的开发者账户上的信息, 以及参考开源服务器上的配置步骤: https://github.com/teslamotors/fleet-telemetry.

公告和API变更日志

2024-03-26:关闭旧版车辆 API 端点

Fleet API 是 Tesla 官方的第三方 API,也是唯一受支持的车辆交互 API。可用端点列表可以在此处找到 FleetAPI:区域要求。从 2024 年 4 月开始,任何不属于此列表的车辆 API 将被逐步淘汰。根据 Fleet API 政策,继续使用不受支持的 API 将导致撤销 Fleet API 访问权限。

2024-02-02:公钥必须保持可用以保证配对连续性

随着 Tesla 移动应用程序 4.30.0 的发布,车辆配对 将需要该应用程序公钥保留托管在用于应用程序注册的“/.well-known/”路径中。这是一项安全改进,其中包括车辆交互信任链中的合作伙伴域。请参阅 check_csr 脚本,了解测试已注册公钥在应用程序域上是否存在的示例。

2024-02-01:Auth访问令牌政策变更

作为安全性改进的一部分,获取新的刷新令牌现在将使用户的先前的刷新令牌及其关联的访问令牌失效。

2023-11-17: Rest API 车辆命令端点弃用时间表 [行动项目]

请使用SDK将任何调用或集成命令API (Command API) 的程序迁移至特斯拉车辆命令协议 (Tesla Vehicle Command Protocol)。

日期 变更
11月 2023 在此日期之后,新交付的车辆*将仅支持Tesla车辆命令协议
11月 - 12月 2023 对于过去30天内未使用 REST API 的现有客户车辆,REST API 将不再提供支持
1月 2024 所有车辆*都需要Tesla车辆命令协议。REST API 将被完全弃用

*注:车辆账户暂不参与这些更改,变更日期将另行通知。2021 年之前的 Model S/X 不包括在这些变化中。

若向尚未安装特斯拉车辆命令协议(Tesla Vehicle Command Protocol)的车辆发送REST API命令,Fleet API 会返回以下错误:"Tesla Vehicle Command Protocol required, please refer to the documentation here: https://developer.tesla.com/docs/fleet-api#2023-10-09-rest-api-vehicle-commands-endpoint-deprecation-warning"

2023-10-24: 固件版本2023.38+的车辆数据更新

运行固件版本2023.38+的车辆默认不会在车辆数据中返回位置信息。需要该信息的开发人员需要将“location_data”参数添加到查询中,请参阅此处. 这将导致位置共享图标显示在车辆UI上。

重要提示:不建议定期获取车辆数据, 请查看车队Telemetry以满足流数据需求。

2023-10-09: Rest API车辆命令端点 - 弃用警告

随着Tesla车辆命令SDK的发布,对现有REST API车辆命令端点的支持也会结束。从2024年开始,大多数车辆将需要通过Tesla车辆命令SDK发送命令。

为了让开发更便捷,以及加速向Tesla车辆命令SDK的过渡,建议开发者使用Tesla http代理 。如果适用,代理会将Rest API HTTP命令转换为签名命令。配置完成后,开发人员只需将其应用程序指向代理,而无需对其应用程序进行任何代码更改。

2023-10-09: 特斯拉车辆命令 SDK

Tesla车辆命令SDK提供用于向车辆发送命令的端到端身份验证。这是向车辆发送命令的推荐方式。

我们鼓励安全专家更深入地研究该协议并在Github提供反馈. 要报告安全问题,请按照https://www.tesla.cn/legal/security上的说明进行操作。

帮助和支持

发送电子邮件至 fleetapisupport@tesla.com 获取开发人员支持。请包含应用程序 client_id、用例描述、任何示例日志或curl 语句以及包括 x-txid 标头的服务器响应。

请确保不要通过电子邮件共享任何 API 令牌、OAuthToken 或任何凭据。特斯拉不需要密码或令牌来帮助诊断问题。