Schneider Electric provides EcoStruxure™ Energy Carbon Emission Data API for getting the CO2 rate in the context of the site to understand measure the impact of the building or industry activity on the environment, and more particularly the greenhouse gas emissions linked to this activity.
This API enables the following features:
- Real-time tracking of CO2 emissions
- Historical emission data analysis
- Integration with existing sustainability tools
- Access to global CO2 rates for comparison
The API provides an endpoint for listing all the sites that you have access to. This is useful for initially discovering what site IDs are available for further data extraction.
curl -X GET "https://api.exchange.se.com/ecostruxure/carbon-emission/v1/sites" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Fetching Carbon Emission Data for a Specific Site
Once you have a list of site IDs, you can use another API endpoint to fetch the carbon emission data for a specific site.
curl -X GET "https://api.exchange.se.com/ecostruxure/carbon-emission/v1/sites/YOUR_SITE_ID/carbon-emissions" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
By following these steps, you can programmatically list all the sites available to you and then, using a specific site ID, fetch the corresponding carbon emission data. This allows you to understand the carbon footprint of individual sites and take informed actions towards reducing greenhouse gas emissions.
This API supports the following authentication mechanism:
OAuth2 Authorization Code Flow
This authorization schema is intended for ISV applications that have obtained authorization from a Schneider Electric customer. Follow the steps below to initiate the authorization process, obtain an access token, and refresh the token as needed.
Step 1: Initiate Authorization and Consent Flow
Firstly, your application should initiate the Authorization and Consent flow by calling the Authorize Endpoint.
curl -X GET "https://api.exchange.se.com/ecostruxure/v1/oauth/authorize" \ -d "client_id=YOUR_CLIENT_ID" \ -d "response_type=code" \ -d "redirect_uri=YOUR_REDIRECT_URI" \ -d "scope=required_scope1 required_scope2" \ -d "state=YOUR_STATE_STRING"
Upon successful authorization and user consent, you'll be redirected to the
redirect_uri you provided, and an authorization code will be appended as a query parameter.
Step 2: Exchange Authorization Code for Token
Once you have received the authorization code, you need to exchange it for an access token by calling the Token Endpoint.
curl -X POST "https://api.exchange.se.com/ecostruxure/v1/oauth/token" \ -d "grant_type=authorization_code" \ -d "code=RECEIVED_AUTHORIZATION_CODE" \ -d "redirect_uri=YOUR_REDIRECT_URI" \ -d "client_id=YOUR_CLIENT_ID" \ -d "client_secret=YOUR_CLIENT_SECRET"
This will return an
access_token and a
Step 3: Refresh the Token
access_token will be valid for 1 hour. To get a new one without requiring the user to log in again, use the
curl -X POST "https://api.exchange.se.com/ecostruxure/v1/oauth/token" \ -d "grant_type=refresh_token" \ -d "refresh_token=YOUR_REFRESH_TOKEN" \ -d "client_id=YOUR_CLIENT_ID" \ -d "client_secret=YOUR_CLIENT_SECRET"
By following these steps, your ISV application can securely interact with Schneider Electric's API services, with the proper authorizations in place.
Personal Access Token Flow
This authorization mechanism is intended for end users who are using the API to access their own data in Schneider Electric's ecosystem. Upon purchasing the API, end users can generate a Personal Access Token directly from the Exchange DevPortal.
How to Generate a Personal Access Token
- Log in to the Exchange DevPortal.
- Navigate to the API product you have subscribed to.
- Locate the "Generate Personal Access Token" section and follow the on-screen instructions to create your token.
How to Use the Personal Access Token
Once you have generated your Personal Access Token, you can use it as a Bearer Token to authorize your API calls.
curl -X GET "https://api.exchange.se.com/ecostruxure/carbon-emission/v1/sites" \ -H "Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN"
Your Personal Access Token serves as a credential that grants you access to your own data. Ensure that you keep it secure and never share it publicly.