Make your first API call
The Enode API lets you connect to a wide range of green energy hardware. This guide demonstrates linking devices to a user and making your first API call by fetching the user.
Copy linkPrerequisites
Copy linkFetching simulated or real devices
You have one set of credentials for the sandbox
environment and one for the production
environment. Before making any requests, decide whether to fetch mocked or real devices.
- For mocked devices, use the
sandbox
environment - For real devices, use the
production
environment
This guide refers to the sandbox
environment. For real devices, replace sandbox
with production
in URLs. Ensure your client_id
and client_secret
correspond to the chosen environment.
Copy linkStep 1: Get an API access token
First, call the Enode OAuth API using client_id
and client_secret
.
This guide uses cURL for examples, but you can use Postman. To get your access token in Postman, apply these settings. We also maintain an updated Postman collection.
Sample
curl https://oauth.sandbox.enode.io/oauth2/token \
-X POST \
-u {YOUR_CLIENT_ID}:{YOUR_CLIENT_SECRET} \
-d "grant_type=client_credentials"
If you provided the correct values, you should receive a successful response containing an access_token
.
Sample
{
"access_token": "{YOUR_ACCESS_TOKEN}",
"expires_in": 3599,
"scope": "",
"token_type": "bearer"
}
Copy linkStep 2: Create a Link session
Next, use the access_token
to create a LinkAPI session. This grants the user temporary access to Enode Link UI, a web interface for connecting hardware to your app.
Sample
curl https://enode-api.sandbox.enode.io/users/1ab23cd4/link \
-X POST \
-H "Authorization: Bearer {YOUR_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{ "vendorType": "vehicle" }'
In this call, 1ab23cd4
represents your user's userId
. Pass any unique string to identify your user. The API creates a user if they don't exist. Learn more in our API referenceAPI.
With a valid access_token
, you'll receive a successful response containing a linkUrl
.
Link response
{
"linkState": "WFiMjNjZDRANThlZmIyMzMtYTNjNS00NjkwLWEwNmEtMGRhNmJhNWQ0Y2QzOjlkZjVhY2NiMzc1MjcyYzI1YzRlNjY3YzczMTVlNmI2ZGM3ODQwMDExMmRhZjcxNzZjNjk0YzYwZTVkY2Q1MzE=",
"linkUrl": "{YOUR_LINK_URL}"
}
Copy linkStep 3: Link a device through Link UI
Open the linkUrl
from the previous step in your browser and choose any vehicle brand to proceed.
- The
sandbox
environment doesn't authenticate users, allowing any combination of email, password, and two-factor authentication code, as in the example below - The
production
environment does authenticate real users and accepts only valid credentials
Sample
Username: user@example.com
Password: 1234
Two-factor code: 123456
Upon seeing a Connection successful screen, proceed to the next step.
Clicking "Complete" on this screen redirects to about:blank
. To specify a redirect URL, pass a redirectUri
to the Link call from the previous step. Refer to our API referenceAPI for more details.
Copy linkStep 4: Fetch the user
After linking vehicles to your user, fetch the user using the /me
endpoint. Pass an Enode-User-Id
header with the request to refer to your user.
Sample
curl https://enode-api.sandbox.enode.io/me \
-X GET \
-H "Authorization: Bearer {YOUR_ACCESS_TOKEN}" \
-H "Enode-User-Id: 1ab23cd4"
With correct values, you'll receive a response containing the user object. The linkedVendors
array should include the vendor linked in step 3.
Sample
{
"id": "1ab23cd4",
"linkedVendors": [
{
"vendor": "{YOUR_LINKED_VENDOR}", // For example: "TESLA", "VOLKSWAGEN"
"isValid": true
},
// If you linked additional vendors, they will show up here
]
}
Copy linkAll done!
Congratulations on making your first call to the Enode API! To learn more about using our API, you have a couple of options:
Get live data from your linked device
The ins and outs of our endpoints