You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/dev/reference/apis/fleet.md
+40-3
Original file line number
Diff line number
Diff line change
@@ -43,10 +43,18 @@ The fleet management API supports the following methods:
43
43
44
44
## Establish a connection
45
45
46
-
To use the Viam fleet management API, you first need to instantiate a [`ViamClient`](https://python.viam.dev/autoapi/viam/app/viam_client/index.html#viam.app.viam_client.ViamClient) and then instantiate an [`AppClient`](https://python.viam.dev/autoapi/viam/app/app_client/index.html#viam.app.app_client.AppClient).
47
-
See the following example for reference.
46
+
To use the Viam fleet management API, you first need to instantiate a `ViamClient` and then instantiate an `AppClient`.
48
47
49
-
You can create an [API key](/manage/manage/access/) on your settings page.
48
+
You will also need an API key and API key ID to authenticate your session.
49
+
To get an API key (and corresponding ID), you have two options:
50
+
51
+
-[Create an API key using the Viam app](/operate/control/api-keys/#add-an-api-key)
52
+
-[Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key)
53
+
54
+
The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates an `AppClient`:
// Replace "<API-KEY-ID>" (including brackets) with your machine's
100
+
const API_KEY_ID ="<API-KEY-ID>";
101
+
// Replace "<API-KEY>" (including brackets) with your machine's API key
102
+
const API_KEY ="<API-KEY>";
103
+
const opts:VIAM.ViamClientOptions= {
104
+
serviceHost: "https://app.viam.com:443",
105
+
credentials: {
106
+
type: "api-key",
107
+
authEntity: API_KEY_ID,
108
+
payload: API_KEY,
109
+
},
110
+
};
111
+
112
+
const client =awaitVIAM.createViamClient(opts);
113
+
returnclient;
114
+
}
115
+
116
+
const viamClient =awaitconnect();
117
+
const appClient =appClient.appClient;
118
+
```
119
+
120
+
{{% /tab %}}
121
+
{{< /tabs >}}
122
+
86
123
Once you have instantiated an `AppClient`, you can run the following [API methods](#api) against the `AppClient` object (named `fleet` in the examples).
0 commit comments