dimo-python-sdk 0.0.1__tar.gz → 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/PKG-INFO +69 -62
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/README.md +67 -60
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/dimo/__init__.py +1 -1
- dimo_python_sdk-0.0.4/dimo/api/__init__.py +23 -0
- dimo_python_sdk-0.0.4/dimo/api/auth.py +130 -0
- dimo_python_sdk-0.0.4/dimo/api/device_data.py +147 -0
- dimo_python_sdk-0.0.4/dimo/api/device_definitions.py +30 -0
- dimo_python_sdk-0.0.4/dimo/api/devices.py +254 -0
- dimo_python_sdk-0.0.4/dimo/api/events.py +14 -0
- dimo_python_sdk-0.0.4/dimo/api/token_exchange.py +29 -0
- dimo_python_sdk-0.0.4/dimo/api/trips.py +23 -0
- dimo_python_sdk-0.0.4/dimo/api/user.py +53 -0
- dimo_python_sdk-0.0.4/dimo/api/valuations.py +32 -0
- dimo_python_sdk-0.0.4/dimo/api/vehicle_signal_decoding.py +90 -0
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/dimo/constants.py +3 -3
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/dimo/dimo.py +30 -37
- dimo_python_sdk-0.0.4/dimo/environments.py +30 -0
- dimo_python_sdk-0.0.4/dimo/errors.py +32 -0
- dimo_python_sdk-0.0.4/dimo/graphql/__init__.py +4 -0
- {dimo_python_sdk-0.0.1/dimo → dimo_python_sdk-0.0.4/dimo/graphql}/identity.py +65 -81
- {dimo_python_sdk-0.0.1/dimo → dimo_python_sdk-0.0.4/dimo/graphql}/telemetry.py +28 -37
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/dimo/request.py +11 -6
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/dimo_python_sdk.egg-info/PKG-INFO +69 -62
- dimo_python_sdk-0.0.4/dimo_python_sdk.egg-info/SOURCES.txt +28 -0
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/dimo_python_sdk.egg-info/requires.txt +1 -1
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/pyproject.toml +2 -2
- dimo_python_sdk-0.0.1/dimo/auth.py +0 -85
- dimo_python_sdk-0.0.1/dimo/device_data.py +0 -118
- dimo_python_sdk-0.0.1/dimo/device_definitions.py +0 -39
- dimo_python_sdk-0.0.1/dimo/devices.py +0 -252
- dimo_python_sdk-0.0.1/dimo/environments.py +0 -30
- dimo_python_sdk-0.0.1/dimo/events.py +0 -13
- dimo_python_sdk-0.0.1/dimo/test.py +0 -92
- dimo_python_sdk-0.0.1/dimo/token_exchange.py +0 -22
- dimo_python_sdk-0.0.1/dimo/trips.py +0 -18
- dimo_python_sdk-0.0.1/dimo/user.py +0 -53
- dimo_python_sdk-0.0.1/dimo/valuations.py +0 -32
- dimo_python_sdk-0.0.1/dimo/vehicle_signal_decoding.py +0 -99
- dimo_python_sdk-0.0.1/dimo_python_sdk.egg-info/SOURCES.txt +0 -26
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/LICENSE +0 -0
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/dimo_python_sdk.egg-info/dependency_links.txt +0 -0
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/dimo_python_sdk.egg-info/top_level.txt +0 -0
- {dimo_python_sdk-0.0.1 → dimo_python_sdk-0.0.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dimo-python-sdk
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: DIMO SDK in Python
|
|
5
5
|
Author-email: Barrett Kowalsky <barrettkowalsky@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/DIMO-Network/dimo-python-sdk
|
|
@@ -13,7 +13,7 @@ Requires-Python: >=3.8
|
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: requests>=2.30.0
|
|
16
|
-
Requires-Dist: web3
|
|
16
|
+
Requires-Dist: web3==6.20.0
|
|
17
17
|
|
|
18
18
|
# DIMO Python Developer SDK
|
|
19
19
|
|
|
@@ -33,6 +33,19 @@ Coming Soon
|
|
|
33
33
|
|
|
34
34
|
Please visit the DIMO [Developer Documentation](https://docs.dimo.zone/developer-platform) to learn more about building on DIMO and detailed information on the API.
|
|
35
35
|
|
|
36
|
+
|
|
37
|
+
### Developer License
|
|
38
|
+
|
|
39
|
+
In order to build on DIMO, you’ll need to get a [DIMO Developer License](https://docs.dimo.zone/developer-platform/getting-started/developer-license) via the [DIMO Dev Console](https://console.dimo.xyz/sign-up). The DIMO Developer license is our approach and design to a more secured, decentralized access control. As a developer, you will need to perform the following steps:
|
|
40
|
+
|
|
41
|
+
1. Sign Up for an Account - You can use your Google, Github, or supported Web3 wallet to register.
|
|
42
|
+
2. Complete Registration - Enter the details of the application that you’re building.
|
|
43
|
+
3. Connect Your Wallet - In the console dashboard, connect your Web3 wallet. This will be the wallet that will pay & act as the holder of the developer license. NOTE: You must have some DIMO tokens, as well as some MATIC (for gas), to pay for the developer license.
|
|
44
|
+
4. Create An App - Click “Create App”, fill out the form & select your preferred environment (at this time, please select “Production” until we’re ready to launch our Sandbox environment), then hit “Create Application”. Finally, set a spending limit for your connected wallet.
|
|
45
|
+
5. Finish Configuring Your Application - Once your project is initialized, you’ll use your connected wallet to generate an API Key and any optional Redirect URIs.
|
|
46
|
+
|
|
47
|
+
If you prefer a video overview on getting setup within the DIMO Dev Console, check out our [DIMO Developer Workshop](https://youtu.be/VefEIQUlOUI?si=Am5h_cekMVJcXELM&t=373).
|
|
48
|
+
|
|
36
49
|
## How to Use the SDK
|
|
37
50
|
|
|
38
51
|
Importing the SDK:
|
|
@@ -53,15 +66,6 @@ or
|
|
|
53
66
|
dimo = DIMO("Dev")
|
|
54
67
|
```
|
|
55
68
|
|
|
56
|
-
### Developer License
|
|
57
|
-
|
|
58
|
-
As part of the authentication process, you will need to register a set of `client_id` and `redirect_uri` (aka `domain`) on the DIMO Network. The [DIMO Developer License](https://docs.dimo.zone/developer-platform/getting-started/developer-license) is our approach and design to a more secured, decentralized access control. As a developer, you will need to perform the following steps:
|
|
59
|
-
|
|
60
|
-
1. [Approving the Dev License to use of $DIMO](https://docs.dimo.zone/developer-platform/getting-started/developer-license/licensing-process#step-1-approving-the-dev-license-to-use-of-usddimo)
|
|
61
|
-
2. [Issue the Dev License](https://docs.dimo.zone/developer-platform/getting-started/developer-license/licensing-process#step-2-issue-the-dev-license) (Get a `client_id` assigned to you)
|
|
62
|
-
3. [Configuring the Dev License](https://docs.dimo.zone/developer-platform/getting-started/developer-license/licensing-process#step-3-configuring-the-dev-license) (Set `redirect_uri` aka `domain`)
|
|
63
|
-
4. [Enable Signer(s)](https://docs.dimo.zone/developer-platform/getting-started/developer-license/licensing-process#step-4-enable-signer-s), the `private_key` of this signer will be required for API access
|
|
64
|
-
|
|
65
69
|
### DIMO Streams
|
|
66
70
|
|
|
67
71
|
Coming Soon
|
|
@@ -86,22 +90,22 @@ NOTE: The signer wallet here is recommended to be different from the spender or
|
|
|
86
90
|
The SDK offers 3 basic functions that maps to the steps listed in [Wallet-based Authentication Flow](https://docs.dimo.zone/developer-platform/getting-started/authentication/wallet-based-authentication-flow): `generate_challenge`, `sign_challenge`, and `submit_challenge`. You can use them accordingly depending on how you build your application.
|
|
87
91
|
|
|
88
92
|
```python
|
|
89
|
-
challenge =
|
|
90
|
-
client_id
|
|
91
|
-
domain
|
|
92
|
-
address
|
|
93
|
+
challenge = dimo.auth.generate_challenge(
|
|
94
|
+
client_id = '<client_id>',
|
|
95
|
+
domain = '<domain>',
|
|
96
|
+
address = '<address>'
|
|
93
97
|
)
|
|
94
98
|
|
|
95
|
-
signature =
|
|
96
|
-
message
|
|
97
|
-
private_key
|
|
99
|
+
signature = dimo.auth.sign_challenge(
|
|
100
|
+
message = challenge['challenge'],
|
|
101
|
+
private_key = '<private_key>'
|
|
98
102
|
)
|
|
99
103
|
|
|
100
|
-
tokens =
|
|
101
|
-
client_id
|
|
102
|
-
domain
|
|
103
|
-
state
|
|
104
|
-
signature
|
|
104
|
+
tokens = dimo.auth.submit_challenge(
|
|
105
|
+
client_id = '<client_id>',
|
|
106
|
+
domain = '<domain>',
|
|
107
|
+
state = challenge['state'],
|
|
108
|
+
signature = signature
|
|
105
109
|
)
|
|
106
110
|
```
|
|
107
111
|
|
|
@@ -110,31 +114,24 @@ The SDK offers 3 basic functions that maps to the steps listed in [Wallet-based
|
|
|
110
114
|
As mentioned earlier, this is the streamlined function call to directly get the `access_token`. The `address` field in challenge generation is omitted since it is essentially the `client_id` of your application per Developer License:
|
|
111
115
|
|
|
112
116
|
```python
|
|
113
|
-
auth_header =
|
|
114
|
-
client_id
|
|
115
|
-
domain
|
|
116
|
-
private_key
|
|
117
|
+
auth_header = dimo.auth.get_token(
|
|
118
|
+
client_id = '<client_id>',
|
|
119
|
+
domain = '<domain>',
|
|
120
|
+
private_key = '<private_key>'
|
|
117
121
|
)
|
|
118
122
|
|
|
119
123
|
# Store the access_token from the auth_header dictionary
|
|
120
124
|
access_token = auth_header["access_token"]
|
|
121
125
|
```
|
|
122
126
|
|
|
123
|
-
##### (Option 3) Credentials.json File
|
|
124
|
-
|
|
125
|
-
Coming Soon
|
|
126
|
-
|
|
127
127
|
### Querying the DIMO REST API
|
|
128
128
|
|
|
129
|
-
The SDK
|
|
129
|
+
The SDK uses the [requests](https://requests.readthedocs.io/en/latest/) library for making HTTP requests. You can perform a query like so:
|
|
130
130
|
|
|
131
131
|
```python
|
|
132
|
-
|
|
133
|
-
device_makes =
|
|
132
|
+
def get_device_makes():
|
|
133
|
+
device_makes = dimo.device_definitions.list_device_makes()
|
|
134
134
|
# Do something with the response
|
|
135
|
-
|
|
136
|
-
if __name__ == "__main__":
|
|
137
|
-
asyncio.run(main())
|
|
138
135
|
```
|
|
139
136
|
|
|
140
137
|
#### Query Parameters
|
|
@@ -142,7 +139,7 @@ if __name__ == "__main__":
|
|
|
142
139
|
For query parameters, simply feed in an input that matches with the expected query parameters:
|
|
143
140
|
|
|
144
141
|
```python
|
|
145
|
-
|
|
142
|
+
dimo.device_definitions.get_by_mmy(
|
|
146
143
|
make="<vehicle_make>",
|
|
147
144
|
model="<vehicle_model>",
|
|
148
145
|
year=2024
|
|
@@ -154,7 +151,7 @@ await dimo.device_definitions.get_by_mmy(
|
|
|
154
151
|
Path parameters work similarly - simply feed in an input, such as id.
|
|
155
152
|
|
|
156
153
|
```python
|
|
157
|
-
|
|
154
|
+
dimo.device_definitions.get_by_id(id='26G4j1YDKZhFeCsn12MAlyU3Y2H')
|
|
158
155
|
```
|
|
159
156
|
|
|
160
157
|
#### Body Parameters
|
|
@@ -165,12 +162,26 @@ As the 2nd leg of the API authentication, applications may exchange for short-li
|
|
|
165
162
|
|
|
166
163
|
For the end users of your application, they will need to share their vehicle permissions via the DIMO Mobile App or through your own implementation of privilege sharing functions - this should be built on the [`setPrivilege` function of the DIMO Vehicle Smart Contract](https://polygonscan.com/address/0xba5738a18d83d41847dffbdc6101d37c69c9b0cf#writeProxyContract).
|
|
167
164
|
|
|
168
|
-
Typically, any endpoints that uses a NFT `tokenId` in path parameters will require privilege tokens. You can
|
|
165
|
+
Typically, any endpoints that uses a NFT `tokenId` in path parameters will require privilege tokens. You can use this flow to obtain a privilege token.
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
|
|
169
|
+
get_priv_token = dimo.token_exchange.exchange(
|
|
170
|
+
access_token,
|
|
171
|
+
# The access token you received using either the three step function calls, or the .get_token() shortcut
|
|
172
|
+
privileges=[1, 3, 4],
|
|
173
|
+
# The privileges you've set for this vehicle, in list format (e.g. [1, 3, 4]) – see: https://docs.dimo.org/developer-platform/api-references/token-exchange-api/token-exchange-endpoints
|
|
174
|
+
token_id="<token_id>"
|
|
175
|
+
# The Vehicle NFT Token ID that you are requesting permission to
|
|
176
|
+
)
|
|
177
|
+
privileged_token = get_priv_token['token']
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Once you have the privilege token, you can pipe it through to corresponding endpoints like so:
|
|
169
181
|
|
|
170
182
|
```python
|
|
171
|
-
privilege_token = await dimo.token_exchange.exchange(access_token, privileges=[1,3,4], token_id=<vehicle_token_id>)
|
|
172
183
|
|
|
173
|
-
|
|
184
|
+
dimo.device_data.get_vehicle_status(token=privilege_token, vehicle_id=<vehicle_token_id>)
|
|
174
185
|
```
|
|
175
186
|
|
|
176
187
|
### Querying the DIMO GraphQL API
|
|
@@ -182,9 +193,9 @@ The SDK accepts any type of valid custom GraphQL queries, but we've also include
|
|
|
182
193
|
The GraphQL entry points are designed almost identical to the REST API entry points. For any GraphQL API that requires auth headers (Telemetry API for example), you can use the same pattern as you would in the REST protected endpoints.
|
|
183
194
|
|
|
184
195
|
```python
|
|
185
|
-
privilege_token =
|
|
196
|
+
privilege_token = dimo.token_exchange.exchange(access_token, privileges=[1,3,4], token_id=<vehicle_token_id>)
|
|
186
197
|
|
|
187
|
-
telemetry =
|
|
198
|
+
telemetry = dimo.telemetry.query(
|
|
188
199
|
token=privilege_token,
|
|
189
200
|
query= """
|
|
190
201
|
query {
|
|
@@ -207,7 +218,7 @@ my_query = """
|
|
|
207
218
|
}
|
|
208
219
|
"""
|
|
209
220
|
|
|
210
|
-
total_network_vehicles =
|
|
221
|
+
total_network_vehicles = dimo.identity.query(query=my_query)
|
|
211
222
|
```
|
|
212
223
|
|
|
213
224
|
#### Built in graphQL Queries: Identity API (Common Queries)
|
|
@@ -219,7 +230,7 @@ Returns the first 10 vehicles
|
|
|
219
230
|
_Example:_
|
|
220
231
|
|
|
221
232
|
```python
|
|
222
|
-
first_10_vehicles =
|
|
233
|
+
first_10_vehicles = dimo.identity.count_dimo_vehicles()
|
|
223
234
|
```
|
|
224
235
|
|
|
225
236
|
##### .list_vehicle_definitions_per_address()
|
|
@@ -229,7 +240,7 @@ Requires an **address** and a **limit**. Returns vehicle definitions (limited by
|
|
|
229
240
|
_Example:_
|
|
230
241
|
|
|
231
242
|
```python
|
|
232
|
-
my_vehicle_definitions =
|
|
243
|
+
my_vehicle_definitions = dimo.identity.list_vehicle_definitions_per_address(
|
|
233
244
|
address = "<0x address>",
|
|
234
245
|
limit = 10
|
|
235
246
|
)
|
|
@@ -242,7 +253,7 @@ Requires an **address** and a **limit**. Returns the makes, models, and years(li
|
|
|
242
253
|
_Example:_
|
|
243
254
|
|
|
244
255
|
```python
|
|
245
|
-
my_mmy =
|
|
256
|
+
my_mmy = dimo.identity.mmy_by_owner(
|
|
246
257
|
address = "<0x address>",
|
|
247
258
|
limit = 10
|
|
248
259
|
)
|
|
@@ -255,7 +266,7 @@ Requires an **address** a **vehicle_limit**, and a **privileges_limit**. Returns
|
|
|
255
266
|
_Example:_
|
|
256
267
|
|
|
257
268
|
```python
|
|
258
|
-
my_vehicle_id_and_privileges =
|
|
269
|
+
my_vehicle_id_and_privileges = dimo.identity.list_vehicle_definitions_per_address(
|
|
259
270
|
address = "<0x address>",
|
|
260
271
|
vehicle_limit = 4,
|
|
261
272
|
privileges_limit = 4,
|
|
@@ -269,7 +280,7 @@ Requires a **dev_address**, **owner_address**, and **limit**. Returns the Token
|
|
|
269
280
|
_Example:_
|
|
270
281
|
|
|
271
282
|
```python
|
|
272
|
-
my_vehicle_definitions =
|
|
283
|
+
my_vehicle_definitions = dimo.identity.list_token_ids_granted_to_dev_by_owner(
|
|
273
284
|
dev_address = "<0x dev address>",
|
|
274
285
|
owner_address = "0x owner address>",
|
|
275
286
|
limit = 10
|
|
@@ -283,7 +294,7 @@ Requires an **address** and **limit**. Returns a list of DCNs attached to the ve
|
|
|
283
294
|
_Example:_
|
|
284
295
|
|
|
285
296
|
```python
|
|
286
|
-
my_vehicle_definitions =
|
|
297
|
+
my_vehicle_definitions = dimo.identity.dcn_by_owner(
|
|
287
298
|
address = "<0x address>",
|
|
288
299
|
limit = 10
|
|
289
300
|
)
|
|
@@ -296,7 +307,7 @@ Requires a **token_id**. Returns the make, model, year and Token IDs for a given
|
|
|
296
307
|
_Example:_
|
|
297
308
|
|
|
298
309
|
```python
|
|
299
|
-
my_mmy_token_id =
|
|
310
|
+
my_mmy_token_id = dimo.identity.mmy_by_token_id(token_id=21957)
|
|
300
311
|
```
|
|
301
312
|
|
|
302
313
|
##### .rewards_by_owner
|
|
@@ -306,7 +317,7 @@ Requires an **address**. Returns the rewards data for a given owner.
|
|
|
306
317
|
_Example:_
|
|
307
318
|
|
|
308
319
|
```python
|
|
309
|
-
my_rewards =
|
|
320
|
+
my_rewards = dimo.identity.rewards_by_owner(address="<0x address>")
|
|
310
321
|
```
|
|
311
322
|
|
|
312
323
|
##### .rewards_history_by_owner
|
|
@@ -316,7 +327,7 @@ Requires an **address** and **limit**. Returns the rewards history data for a gi
|
|
|
316
327
|
_Example:_
|
|
317
328
|
|
|
318
329
|
```python
|
|
319
|
-
my_rewards_history =
|
|
330
|
+
my_rewards_history = dimo.identity.rewards_history_by_owner(address="<0x address>", limit=50)
|
|
320
331
|
```
|
|
321
332
|
|
|
322
333
|
#### Built in graphQL Queries: Telemetry API (Common Queries)
|
|
@@ -330,7 +341,7 @@ Requires a **privilege_token** and **token_id**. Returns latest vehicle signals
|
|
|
330
341
|
_Example:_
|
|
331
342
|
|
|
332
343
|
```python
|
|
333
|
-
my_latest_signals =
|
|
344
|
+
my_latest_signals = dimo.telemetry.get_signals_latest(
|
|
334
345
|
token=my_privileged_token, token_id=12345)
|
|
335
346
|
```
|
|
336
347
|
|
|
@@ -341,7 +352,7 @@ Requires a **privilege_token**, **token_id**, **start_date**, and **end_date**.
|
|
|
341
352
|
_Example:_
|
|
342
353
|
|
|
343
354
|
```python
|
|
344
|
-
my_daily_signals =
|
|
355
|
+
my_daily_signals = dimo.telemetry.get_daily_signals_autopi(
|
|
345
356
|
token=my_privileged_token,
|
|
346
357
|
token_id=12345,
|
|
347
358
|
start_date="2024-07-04T18:00:00Z",
|
|
@@ -355,7 +366,7 @@ Requires a **privilege_token**, **token_id**, **start_date**, and **end_date**.
|
|
|
355
366
|
_Example:_
|
|
356
367
|
|
|
357
368
|
```python
|
|
358
|
-
my_daily_avg_speed =
|
|
369
|
+
my_daily_avg_speed = dimo.telemetry.get_daily_avg_speed(
|
|
359
370
|
token=my_privileged_token,
|
|
360
371
|
token_id=12345,
|
|
361
372
|
start_date="2024-07-04T18:00:00Z",
|
|
@@ -369,7 +380,7 @@ Requires a **privilege_token**, **token_id**, **start_date**, and **end_date**.
|
|
|
369
380
|
_Example:_
|
|
370
381
|
|
|
371
382
|
```python
|
|
372
|
-
my_daily_max_speed =
|
|
383
|
+
my_daily_max_speed = dimo.telemetry.get_daily_max_speed(
|
|
373
384
|
token=my_privileged_token,
|
|
374
385
|
token_id=12345,
|
|
375
386
|
start_date="2024-07-04T18:00:00Z",
|
|
@@ -379,7 +390,3 @@ my_daily_max_speed = await dimo.telemetry.get_daily_max_speed(
|
|
|
379
390
|
## How to Contribute to the SDK
|
|
380
391
|
|
|
381
392
|
You can read more about contributing [here](https://github.com/DIMO-Network/dimo-python-sdk/blob/dev-barrettk/CONTRIBUTING.md)
|
|
382
|
-
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
```
|
|
@@ -16,6 +16,19 @@ Coming Soon
|
|
|
16
16
|
|
|
17
17
|
Please visit the DIMO [Developer Documentation](https://docs.dimo.zone/developer-platform) to learn more about building on DIMO and detailed information on the API.
|
|
18
18
|
|
|
19
|
+
|
|
20
|
+
### Developer License
|
|
21
|
+
|
|
22
|
+
In order to build on DIMO, you’ll need to get a [DIMO Developer License](https://docs.dimo.zone/developer-platform/getting-started/developer-license) via the [DIMO Dev Console](https://console.dimo.xyz/sign-up). The DIMO Developer license is our approach and design to a more secured, decentralized access control. As a developer, you will need to perform the following steps:
|
|
23
|
+
|
|
24
|
+
1. Sign Up for an Account - You can use your Google, Github, or supported Web3 wallet to register.
|
|
25
|
+
2. Complete Registration - Enter the details of the application that you’re building.
|
|
26
|
+
3. Connect Your Wallet - In the console dashboard, connect your Web3 wallet. This will be the wallet that will pay & act as the holder of the developer license. NOTE: You must have some DIMO tokens, as well as some MATIC (for gas), to pay for the developer license.
|
|
27
|
+
4. Create An App - Click “Create App”, fill out the form & select your preferred environment (at this time, please select “Production” until we’re ready to launch our Sandbox environment), then hit “Create Application”. Finally, set a spending limit for your connected wallet.
|
|
28
|
+
5. Finish Configuring Your Application - Once your project is initialized, you’ll use your connected wallet to generate an API Key and any optional Redirect URIs.
|
|
29
|
+
|
|
30
|
+
If you prefer a video overview on getting setup within the DIMO Dev Console, check out our [DIMO Developer Workshop](https://youtu.be/VefEIQUlOUI?si=Am5h_cekMVJcXELM&t=373).
|
|
31
|
+
|
|
19
32
|
## How to Use the SDK
|
|
20
33
|
|
|
21
34
|
Importing the SDK:
|
|
@@ -36,15 +49,6 @@ or
|
|
|
36
49
|
dimo = DIMO("Dev")
|
|
37
50
|
```
|
|
38
51
|
|
|
39
|
-
### Developer License
|
|
40
|
-
|
|
41
|
-
As part of the authentication process, you will need to register a set of `client_id` and `redirect_uri` (aka `domain`) on the DIMO Network. The [DIMO Developer License](https://docs.dimo.zone/developer-platform/getting-started/developer-license) is our approach and design to a more secured, decentralized access control. As a developer, you will need to perform the following steps:
|
|
42
|
-
|
|
43
|
-
1. [Approving the Dev License to use of $DIMO](https://docs.dimo.zone/developer-platform/getting-started/developer-license/licensing-process#step-1-approving-the-dev-license-to-use-of-usddimo)
|
|
44
|
-
2. [Issue the Dev License](https://docs.dimo.zone/developer-platform/getting-started/developer-license/licensing-process#step-2-issue-the-dev-license) (Get a `client_id` assigned to you)
|
|
45
|
-
3. [Configuring the Dev License](https://docs.dimo.zone/developer-platform/getting-started/developer-license/licensing-process#step-3-configuring-the-dev-license) (Set `redirect_uri` aka `domain`)
|
|
46
|
-
4. [Enable Signer(s)](https://docs.dimo.zone/developer-platform/getting-started/developer-license/licensing-process#step-4-enable-signer-s), the `private_key` of this signer will be required for API access
|
|
47
|
-
|
|
48
52
|
### DIMO Streams
|
|
49
53
|
|
|
50
54
|
Coming Soon
|
|
@@ -69,22 +73,22 @@ NOTE: The signer wallet here is recommended to be different from the spender or
|
|
|
69
73
|
The SDK offers 3 basic functions that maps to the steps listed in [Wallet-based Authentication Flow](https://docs.dimo.zone/developer-platform/getting-started/authentication/wallet-based-authentication-flow): `generate_challenge`, `sign_challenge`, and `submit_challenge`. You can use them accordingly depending on how you build your application.
|
|
70
74
|
|
|
71
75
|
```python
|
|
72
|
-
challenge =
|
|
73
|
-
client_id
|
|
74
|
-
domain
|
|
75
|
-
address
|
|
76
|
+
challenge = dimo.auth.generate_challenge(
|
|
77
|
+
client_id = '<client_id>',
|
|
78
|
+
domain = '<domain>',
|
|
79
|
+
address = '<address>'
|
|
76
80
|
)
|
|
77
81
|
|
|
78
|
-
signature =
|
|
79
|
-
message
|
|
80
|
-
private_key
|
|
82
|
+
signature = dimo.auth.sign_challenge(
|
|
83
|
+
message = challenge['challenge'],
|
|
84
|
+
private_key = '<private_key>'
|
|
81
85
|
)
|
|
82
86
|
|
|
83
|
-
tokens =
|
|
84
|
-
client_id
|
|
85
|
-
domain
|
|
86
|
-
state
|
|
87
|
-
signature
|
|
87
|
+
tokens = dimo.auth.submit_challenge(
|
|
88
|
+
client_id = '<client_id>',
|
|
89
|
+
domain = '<domain>',
|
|
90
|
+
state = challenge['state'],
|
|
91
|
+
signature = signature
|
|
88
92
|
)
|
|
89
93
|
```
|
|
90
94
|
|
|
@@ -93,31 +97,24 @@ The SDK offers 3 basic functions that maps to the steps listed in [Wallet-based
|
|
|
93
97
|
As mentioned earlier, this is the streamlined function call to directly get the `access_token`. The `address` field in challenge generation is omitted since it is essentially the `client_id` of your application per Developer License:
|
|
94
98
|
|
|
95
99
|
```python
|
|
96
|
-
auth_header =
|
|
97
|
-
client_id
|
|
98
|
-
domain
|
|
99
|
-
private_key
|
|
100
|
+
auth_header = dimo.auth.get_token(
|
|
101
|
+
client_id = '<client_id>',
|
|
102
|
+
domain = '<domain>',
|
|
103
|
+
private_key = '<private_key>'
|
|
100
104
|
)
|
|
101
105
|
|
|
102
106
|
# Store the access_token from the auth_header dictionary
|
|
103
107
|
access_token = auth_header["access_token"]
|
|
104
108
|
```
|
|
105
109
|
|
|
106
|
-
##### (Option 3) Credentials.json File
|
|
107
|
-
|
|
108
|
-
Coming Soon
|
|
109
|
-
|
|
110
110
|
### Querying the DIMO REST API
|
|
111
111
|
|
|
112
|
-
The SDK
|
|
112
|
+
The SDK uses the [requests](https://requests.readthedocs.io/en/latest/) library for making HTTP requests. You can perform a query like so:
|
|
113
113
|
|
|
114
114
|
```python
|
|
115
|
-
|
|
116
|
-
device_makes =
|
|
115
|
+
def get_device_makes():
|
|
116
|
+
device_makes = dimo.device_definitions.list_device_makes()
|
|
117
117
|
# Do something with the response
|
|
118
|
-
|
|
119
|
-
if __name__ == "__main__":
|
|
120
|
-
asyncio.run(main())
|
|
121
118
|
```
|
|
122
119
|
|
|
123
120
|
#### Query Parameters
|
|
@@ -125,7 +122,7 @@ if __name__ == "__main__":
|
|
|
125
122
|
For query parameters, simply feed in an input that matches with the expected query parameters:
|
|
126
123
|
|
|
127
124
|
```python
|
|
128
|
-
|
|
125
|
+
dimo.device_definitions.get_by_mmy(
|
|
129
126
|
make="<vehicle_make>",
|
|
130
127
|
model="<vehicle_model>",
|
|
131
128
|
year=2024
|
|
@@ -137,7 +134,7 @@ await dimo.device_definitions.get_by_mmy(
|
|
|
137
134
|
Path parameters work similarly - simply feed in an input, such as id.
|
|
138
135
|
|
|
139
136
|
```python
|
|
140
|
-
|
|
137
|
+
dimo.device_definitions.get_by_id(id='26G4j1YDKZhFeCsn12MAlyU3Y2H')
|
|
141
138
|
```
|
|
142
139
|
|
|
143
140
|
#### Body Parameters
|
|
@@ -148,12 +145,26 @@ As the 2nd leg of the API authentication, applications may exchange for short-li
|
|
|
148
145
|
|
|
149
146
|
For the end users of your application, they will need to share their vehicle permissions via the DIMO Mobile App or through your own implementation of privilege sharing functions - this should be built on the [`setPrivilege` function of the DIMO Vehicle Smart Contract](https://polygonscan.com/address/0xba5738a18d83d41847dffbdc6101d37c69c9b0cf#writeProxyContract).
|
|
150
147
|
|
|
151
|
-
Typically, any endpoints that uses a NFT `tokenId` in path parameters will require privilege tokens. You can
|
|
148
|
+
Typically, any endpoints that uses a NFT `tokenId` in path parameters will require privilege tokens. You can use this flow to obtain a privilege token.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
|
|
152
|
+
get_priv_token = dimo.token_exchange.exchange(
|
|
153
|
+
access_token,
|
|
154
|
+
# The access token you received using either the three step function calls, or the .get_token() shortcut
|
|
155
|
+
privileges=[1, 3, 4],
|
|
156
|
+
# The privileges you've set for this vehicle, in list format (e.g. [1, 3, 4]) – see: https://docs.dimo.org/developer-platform/api-references/token-exchange-api/token-exchange-endpoints
|
|
157
|
+
token_id="<token_id>"
|
|
158
|
+
# The Vehicle NFT Token ID that you are requesting permission to
|
|
159
|
+
)
|
|
160
|
+
privileged_token = get_priv_token['token']
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Once you have the privilege token, you can pipe it through to corresponding endpoints like so:
|
|
152
164
|
|
|
153
165
|
```python
|
|
154
|
-
privilege_token = await dimo.token_exchange.exchange(access_token, privileges=[1,3,4], token_id=<vehicle_token_id>)
|
|
155
166
|
|
|
156
|
-
|
|
167
|
+
dimo.device_data.get_vehicle_status(token=privilege_token, vehicle_id=<vehicle_token_id>)
|
|
157
168
|
```
|
|
158
169
|
|
|
159
170
|
### Querying the DIMO GraphQL API
|
|
@@ -165,9 +176,9 @@ The SDK accepts any type of valid custom GraphQL queries, but we've also include
|
|
|
165
176
|
The GraphQL entry points are designed almost identical to the REST API entry points. For any GraphQL API that requires auth headers (Telemetry API for example), you can use the same pattern as you would in the REST protected endpoints.
|
|
166
177
|
|
|
167
178
|
```python
|
|
168
|
-
privilege_token =
|
|
179
|
+
privilege_token = dimo.token_exchange.exchange(access_token, privileges=[1,3,4], token_id=<vehicle_token_id>)
|
|
169
180
|
|
|
170
|
-
telemetry =
|
|
181
|
+
telemetry = dimo.telemetry.query(
|
|
171
182
|
token=privilege_token,
|
|
172
183
|
query= """
|
|
173
184
|
query {
|
|
@@ -190,7 +201,7 @@ my_query = """
|
|
|
190
201
|
}
|
|
191
202
|
"""
|
|
192
203
|
|
|
193
|
-
total_network_vehicles =
|
|
204
|
+
total_network_vehicles = dimo.identity.query(query=my_query)
|
|
194
205
|
```
|
|
195
206
|
|
|
196
207
|
#### Built in graphQL Queries: Identity API (Common Queries)
|
|
@@ -202,7 +213,7 @@ Returns the first 10 vehicles
|
|
|
202
213
|
_Example:_
|
|
203
214
|
|
|
204
215
|
```python
|
|
205
|
-
first_10_vehicles =
|
|
216
|
+
first_10_vehicles = dimo.identity.count_dimo_vehicles()
|
|
206
217
|
```
|
|
207
218
|
|
|
208
219
|
##### .list_vehicle_definitions_per_address()
|
|
@@ -212,7 +223,7 @@ Requires an **address** and a **limit**. Returns vehicle definitions (limited by
|
|
|
212
223
|
_Example:_
|
|
213
224
|
|
|
214
225
|
```python
|
|
215
|
-
my_vehicle_definitions =
|
|
226
|
+
my_vehicle_definitions = dimo.identity.list_vehicle_definitions_per_address(
|
|
216
227
|
address = "<0x address>",
|
|
217
228
|
limit = 10
|
|
218
229
|
)
|
|
@@ -225,7 +236,7 @@ Requires an **address** and a **limit**. Returns the makes, models, and years(li
|
|
|
225
236
|
_Example:_
|
|
226
237
|
|
|
227
238
|
```python
|
|
228
|
-
my_mmy =
|
|
239
|
+
my_mmy = dimo.identity.mmy_by_owner(
|
|
229
240
|
address = "<0x address>",
|
|
230
241
|
limit = 10
|
|
231
242
|
)
|
|
@@ -238,7 +249,7 @@ Requires an **address** a **vehicle_limit**, and a **privileges_limit**. Returns
|
|
|
238
249
|
_Example:_
|
|
239
250
|
|
|
240
251
|
```python
|
|
241
|
-
my_vehicle_id_and_privileges =
|
|
252
|
+
my_vehicle_id_and_privileges = dimo.identity.list_vehicle_definitions_per_address(
|
|
242
253
|
address = "<0x address>",
|
|
243
254
|
vehicle_limit = 4,
|
|
244
255
|
privileges_limit = 4,
|
|
@@ -252,7 +263,7 @@ Requires a **dev_address**, **owner_address**, and **limit**. Returns the Token
|
|
|
252
263
|
_Example:_
|
|
253
264
|
|
|
254
265
|
```python
|
|
255
|
-
my_vehicle_definitions =
|
|
266
|
+
my_vehicle_definitions = dimo.identity.list_token_ids_granted_to_dev_by_owner(
|
|
256
267
|
dev_address = "<0x dev address>",
|
|
257
268
|
owner_address = "0x owner address>",
|
|
258
269
|
limit = 10
|
|
@@ -266,7 +277,7 @@ Requires an **address** and **limit**. Returns a list of DCNs attached to the ve
|
|
|
266
277
|
_Example:_
|
|
267
278
|
|
|
268
279
|
```python
|
|
269
|
-
my_vehicle_definitions =
|
|
280
|
+
my_vehicle_definitions = dimo.identity.dcn_by_owner(
|
|
270
281
|
address = "<0x address>",
|
|
271
282
|
limit = 10
|
|
272
283
|
)
|
|
@@ -279,7 +290,7 @@ Requires a **token_id**. Returns the make, model, year and Token IDs for a given
|
|
|
279
290
|
_Example:_
|
|
280
291
|
|
|
281
292
|
```python
|
|
282
|
-
my_mmy_token_id =
|
|
293
|
+
my_mmy_token_id = dimo.identity.mmy_by_token_id(token_id=21957)
|
|
283
294
|
```
|
|
284
295
|
|
|
285
296
|
##### .rewards_by_owner
|
|
@@ -289,7 +300,7 @@ Requires an **address**. Returns the rewards data for a given owner.
|
|
|
289
300
|
_Example:_
|
|
290
301
|
|
|
291
302
|
```python
|
|
292
|
-
my_rewards =
|
|
303
|
+
my_rewards = dimo.identity.rewards_by_owner(address="<0x address>")
|
|
293
304
|
```
|
|
294
305
|
|
|
295
306
|
##### .rewards_history_by_owner
|
|
@@ -299,7 +310,7 @@ Requires an **address** and **limit**. Returns the rewards history data for a gi
|
|
|
299
310
|
_Example:_
|
|
300
311
|
|
|
301
312
|
```python
|
|
302
|
-
my_rewards_history =
|
|
313
|
+
my_rewards_history = dimo.identity.rewards_history_by_owner(address="<0x address>", limit=50)
|
|
303
314
|
```
|
|
304
315
|
|
|
305
316
|
#### Built in graphQL Queries: Telemetry API (Common Queries)
|
|
@@ -313,7 +324,7 @@ Requires a **privilege_token** and **token_id**. Returns latest vehicle signals
|
|
|
313
324
|
_Example:_
|
|
314
325
|
|
|
315
326
|
```python
|
|
316
|
-
my_latest_signals =
|
|
327
|
+
my_latest_signals = dimo.telemetry.get_signals_latest(
|
|
317
328
|
token=my_privileged_token, token_id=12345)
|
|
318
329
|
```
|
|
319
330
|
|
|
@@ -324,7 +335,7 @@ Requires a **privilege_token**, **token_id**, **start_date**, and **end_date**.
|
|
|
324
335
|
_Example:_
|
|
325
336
|
|
|
326
337
|
```python
|
|
327
|
-
my_daily_signals =
|
|
338
|
+
my_daily_signals = dimo.telemetry.get_daily_signals_autopi(
|
|
328
339
|
token=my_privileged_token,
|
|
329
340
|
token_id=12345,
|
|
330
341
|
start_date="2024-07-04T18:00:00Z",
|
|
@@ -338,7 +349,7 @@ Requires a **privilege_token**, **token_id**, **start_date**, and **end_date**.
|
|
|
338
349
|
_Example:_
|
|
339
350
|
|
|
340
351
|
```python
|
|
341
|
-
my_daily_avg_speed =
|
|
352
|
+
my_daily_avg_speed = dimo.telemetry.get_daily_avg_speed(
|
|
342
353
|
token=my_privileged_token,
|
|
343
354
|
token_id=12345,
|
|
344
355
|
start_date="2024-07-04T18:00:00Z",
|
|
@@ -352,7 +363,7 @@ Requires a **privilege_token**, **token_id**, **start_date**, and **end_date**.
|
|
|
352
363
|
_Example:_
|
|
353
364
|
|
|
354
365
|
```python
|
|
355
|
-
my_daily_max_speed =
|
|
366
|
+
my_daily_max_speed = dimo.telemetry.get_daily_max_speed(
|
|
356
367
|
token=my_privileged_token,
|
|
357
368
|
token_id=12345,
|
|
358
369
|
start_date="2024-07-04T18:00:00Z",
|
|
@@ -362,7 +373,3 @@ my_daily_max_speed = await dimo.telemetry.get_daily_max_speed(
|
|
|
362
373
|
## How to Contribute to the SDK
|
|
363
374
|
|
|
364
375
|
You can read more about contributing [here](https://github.com/DIMO-Network/dimo-python-sdk/blob/dev-barrettk/CONTRIBUTING.md)
|
|
365
|
-
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from .auth import Auth
|
|
2
|
+
from .device_data import DeviceData
|
|
3
|
+
from .device_definitions import DeviceDefinitions
|
|
4
|
+
from .devices import Devices
|
|
5
|
+
from .events import Events
|
|
6
|
+
from .token_exchange import TokenExchange
|
|
7
|
+
from .trips import Trips
|
|
8
|
+
from .user import User
|
|
9
|
+
from .valuations import Valuations
|
|
10
|
+
from .vehicle_signal_decoding import VehicleSignalDecoding
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"Auth",
|
|
14
|
+
"DeviceData",
|
|
15
|
+
"DeviceDefinitions",
|
|
16
|
+
"Devices",
|
|
17
|
+
"Events",
|
|
18
|
+
"TokenExchange",
|
|
19
|
+
"Trips",
|
|
20
|
+
"User",
|
|
21
|
+
"Valuations",
|
|
22
|
+
"VehicleSignalDecoding",
|
|
23
|
+
]
|