Knowledge
homeappabout
English
English
  • Home
  • About Ardexa
    • Our Security Principles
    • What makes us different?
    • Collecting Data
    • Device Remote Control
    • Tunnel (VPN) Access
    • File Transfers
    • Machine Plugins
  • Getting Started
    • What is Ardexa?
    • Connectivity in 60 Seconds
    • The Ardexa Data Store
  • Configure the Edge Device
    • Edge and Cloud Connect
    • Edge Device Configuration
      • ArdexaLinux Operating System
      • Approved Hardware
        • Dell Industrial Computers
          • Dell PowerEdge Installation
        • Advantech Industrial Computers
          • Configuring Advantech Devices
            • UNO-2271G, UNO-2272G
            • UNO-2362G
          • Advantech ArdexaLinux Installation
          • Advantech Serial Driver
        • Siemens Industrial Computers
          • Siemens IPC 127E Installation
          • Siemens IOT2050 ArdexaLinux Installation
        • Raspberry Pi
          • Install the Raspbian Image
          • USB On-The-Go (OTG) support
          • Raspberry Pi 4 EEPROM update
          • Display hardware version of Raspberry Pi
        • Virtual machines
      • Internet Connection
        • Connecting
        • Complex Network Management
      • Networking
        • Network Configuration Using Ardexa Cloud
        • Config Static IP - Manually
        • Add static route
        • Add secondary IP
        • Access via SSH
        • Update password
        • Test Network Access
        • Reconnecting Offline Device
        • Cisco VPN Access
        • USB Tethering
      • Using a local Network Time server (NTP)
      • Serial Communications
        • Testing the serial ports
      • Antivirus
      • Time Zone
    • Connecting to Plant Equipment
      • TCP (Ethernet)
        • Standard Industrial Protocols
        • OPC Protocols
        • Database Protocols
        • PLC Protocols
        • Miscellaneous
      • Serial (RS-485, RS-422, RS-232)
        • Standard Industrial Protocols
        • Proprietary Protocols
      • Others (Bluetooth, etc.)
    • Ardexa Agent
      • Installation (ARM64 or X86/AMD64)
      • Installation Raspberry Pi
      • Install (opkg)
      • Install on Docker
      • Check it's working
      • Increase system limits
      • Data types and formats
        • Decimal
        • CSV file format
      • Scenarios
        • Run
        • How does the UNIX_SOCKET scenario work?
      • Dynamic Configuration
      • Manual Configuration
      • Replacing a Device with a New One
      • Replacing a Device with an Existing One
      • Uninstall
    • Ardexa Machine Plugins
      • Safety & Risk Notice
      • Modbus
        • Modbus Server
        • Modbus Python Plugin
        • Modbus Plugin
      • Programmable Logic Controllers (PLCs)
        • Access to OPC DA Data
        • Installing the OpenOPC utility
        • Mitsubishi PLC Plugin
        • Siemens S7 PLC Plugin
        • Omron PLC Plugin
        • README
      • OPC Plugins
        • OPCUA Plugin
      • Solar Inverter Plugins
        • Satcon Inverters
        • Sungrow Inverters
          • Sungrow SG Grid Scale Inverters
          • Sungrow SG1000MX Inverters
          • Sungrow SG String Inverters
        • Delta Inverters
        • Connecting to Huawei
        • Huawei Logger
        • Huawei Logger
        • ABB Inverters
          • Configuring ABB Inverters
          • ABB Aurora Inverters
          • ABB PowerOne Modbus Inverters
          • ABB Pro 33 Inverters
          • ABB PVS 800 Inverters
          • ABB Trio Inverters
        • SolarEdge Inverters
        • Sunspec Inverters
        • SMA Inverters
          • Connecting SMA Inverters
          • SMA Central Inverters
          • SMA Cluster Controllers
          • SMA "YASDI" Inverters
          • SMA Sunny Tripower (non Sunspec)
          • SMA Power Plant Controllers
          • SMA Central 1850-2750 Inverters
          • SMA Sunny Webbox
        • Kostal Inverters
          • Connecting via Kostal Proprietary Protocol
          • Kostal Proprietary Plugin
          • Kostal Modbus (non Sunspec) Plugin
        • Kaco Inverters
          • Configuring Kaco Inverters
          • Kaco Inverter Plugin
        • SolarMax Inverters
          • Configuring SolarMax Inverters
          • SolarMax Inverter Plugin
        • Refusol Inverters
        • JEMA IFX Inverters
        • Ginglong Solis Inverters
        • Growatt TL3 Inverters
        • HEC Freesun Inverters
        • Next Tracker Plugin
        • Ingecon 100TL Inverters
        • Tristart MPPT Charger
        • Zenergy PID Boxes
        • Eaton Inverters
        • SolarCheck Strings
        • Soltec Trackers
        • GE Inverters
        • TMEIC Solar Ware Ninja Inverters
        • Power Electronics Inverters
        • Ingeteam Inverters
        • Delta Logger
        • FTC Trackers
        • Trina Trackers
        • Solivia Inverters
        • Dunext Inverters
      • Data Logger Plugins
        • Connecting SolarLog
        • SolarLog Logger
        • MaxWeb Logger
        • Gantner Logger
        • MeteoControl Logger
        • Bluelog Logger
        • Kaco proLOG
        • Sinapsi Logger
        • Skylog Logger
        • SMA Sunny Webbox Logger
      • Electricity Meter Plugins
        • Janitza Meters
        • Cube Meters
        • ECS Meters
        • Gavazzi Meters
          • Gavazzi EM24 Meters
          • Gavazzi WM Meters
        • KBR Meters
        • Plus ES Meters
        • RPI Current Transformers
        • Schweitzer Meters
        • Schweitzer Protection Relays
        • Schneider Electric Meters
          • Schneider ION Meters
          • Schneider Sepam Meters
        • Fanox Relay
        • Elspec Meters
        • Landis Gyr Meter
      • Wind Turbines
        • Wind Park Networks
        • Vestas Wind Turbines
          • Vestas ODBC
          • Vestas OPCUA
        • Clavis XML Server
        • Gamesa Wind Turbines
          • Gamesa ODBC Wind Turbines Plugin
          • Gamesa Windnet OPCUA
          • Gamesa Wind Turbines via Config Files
        • Nordex Wind Turbines
          • Nordex OPCXML Wind Turbines Plugin
          • Nordex Plugin ODBC with Config Files
          • Nordex Plugin OPCXML with Config Files
        • Enercon Wind Turbines
          • Enercon Wind Turbines Plugin
          • Enercon Wind Turbines Plugin with Config Files
        • GE ODBC Wind Turbines
        • Senvion Wind Turbines
          • Senvion Wind Turbines Plugin
          • Senvion Plugin with Config Files
        • Siemens Wind Turbines
          • Siemens Wind Turbines
          • Siemens Wind Turbines with Config Files
      • Weather Stations
        • Kipp and Zonen
        • IMT Si-RS485 Sensors
        • Webdom
        • Lufft Weather Stations
        • Campbell Weather Stations
        • DustIQ Soiling Sensors
        • Geonica Weather Stations
        • Groundwork Zenith Meteorological Stations
        • Hukseflux Pyranometers
      • Solar Powered Computers
      • Energy Storage
        • BYD ESS C648
        • BYD ESS
        • NetMan 204
        • Narada Batteries
      • IEC
        • IEC 61850
        • IEC 60870
      • Management Plugins
        • RESI Real Time Clock Plugin
        • Logrotate Plugin
        • Interface Manager Plugin
          • Automatic Modem Connection
          • Manual Modem Connection
          • Troubleshooting Modem Usage
        • Black Box Plugin
        • Log Rotation and Deleting Old Logs
        • Antivirus
        • Backfill
      • Computer Vision
        • Photo Capture Plugin
      • Testing Plugins
        • Dynamic Test
        • JSON Test
        • Ping Test
        • Schema Test
        • Serial Test
        • Solar Demo Plugin
        • Vestas Demo Plugin
        • Service Load Test
        • Resource Usage
        • Edge Statistics
      • Control
        • Ardexa Control Plugin
    • Variable Naming Guide
    • Communications Hardware
      • USB to WIFI Converter
      • Teltonika RUT950 router
      • Huawei E8372 (3G) Modems
      • Modems
  • Ardexa Cloud
    • Ardexa Account
      • Multi-factor Authentication
      • User profile
      • Browsers
      • Navigation
    • Ardexa Remote
      • Install Ardexa Remote
      • Using the Tunnel
      • Using the VPN
      • Troubleshooting
    • Data Access
      • KPIs
      • Users and Permissions
      • Device Groups
      • Limit user access to a subset of devices
      • Limit Access to Searches
      • API Tokens
      • Device access to the API
      • Images
      • Power BI
    • Analysis
      • View Types
      • Charts
      • Formulae
      • Device Logs
    • Searches
      • Creating Searches
      • Sharing Searches
      • CSV Downloads
      • Scheduled Search
      • Search Admin
      • Search Visualisations
      • Search Statistics
      • Search Analysis
      • Audit Logs
      • Other Resources
    • Devices
      • Edge and Cloud Devices
      • Device Summary
      • Device Bulk Actions
      • General Info
      • Remote Shell
      • File Transfer
      • Machine Plugins
      • Manual Configuration
      • Live Feed
      • Network (Edge Devices)
      • Network (Cloud Devices)
      • Discovery
        • Modbus
      • Commands
      • Tunnel (Ardexa Remote)
        • Install ArdexaRemote command line interface (CLI)
      • NAT Gateway
    • Entities
      • What is an entity
      • Create new entity
      • View entities
      • Managing entities
      • Recommendations
    • Standard UI components
    • Dashboards
      • Creating and Editing
      • Card types
        • 📈Chart Card
        • Button Stack
        • Active Incidents
        • Camera Control
        • Command Template
        • Cylinder
        • Energy Summary
        • Energy Tally
        • Gauge
        • Heat Map
        • Indicator light
        • Indicator light table
        • Inverter performance
        • KPI Chart
        • KPI Value
        • Latest Values
        • Link Stack
        • Live Calculation
        • Map
        • Metadata
        • Photo
        • Radial Histogram
        • Remote Web
        • Satellite Image
        • Scatter Plot
        • Single Value
        • Switch Toggle
        • Dynamic Text
        • Static Text
        • Value Table
        • Pie Chart
      • Lookup Table Integration
      • Timeframe and Timezone
    • Alerts
      • Incident Logs
    • Administration
      • Security Services
      • Metadata
      • Workgroup Settings
      • Labelling
      • Moving a Device Across Workgroups
      • External Sources
      • Lookup Table
      • Access Control
    • Energy Solutions
      • Energy Reports
        • Configuring the Daily Energy process
        • Configuring Meter Data
        • Configuring Performance Ratio
          • Irradiation Extract
    • Control
      • Schedules
    • Photos
  • FAQ
    • Difference between "Datetime", "event_time" and "store_time"
    • How can I manually upgrade the agent?
    • What ports does the agent require?
    • Can the agent subscribe to data streams from other agents?
  • Troubleshooting
    • ardpkg error: TypeError: 'NoneType' object is not subscriptable
    • Offline device (Ardexa agent is offline)
      • Remote checks
      • On-site checks
    • Agent continually restarts
    • Workgroup Invitations
    • Slack Invitation
    • Advantech Computer will not connect to the Internet
    • Edge Computer is not fully serviceable
    • The agent won't connect
    • My agent is online, but there is no data in the cloud
    • Agent upgrade failed: Unknown error
    • Device Config Update every log interval
    • Other Agent related issue
    • Running the agent in Debug Mode
    • Agent Maintenance on SysV
    • Connecting a device securely to a network segment that does not have Internet access
    • EXPECT_ERROR: Decimal conversion failed
    • Docker Interface Conflict
    • Failed to fetch...IP Not Found
  • Ardexa API
    • API
      • API Quick Start Guide
      • Python examples
      • Automated API Token Renewal
      • General
        • Issue API token
        • Examine API Token
        • WebSockets
      • Consumer
      • Security
      • Devices
        • Websocket
      • Search
        • API Search Functions
        • Search scrolling
        • Timeframe
        • Consuming data via the API
      • Energy
Powered by GitBook
On this page
  • Workgroup general information
  • Node list
  • Table list
  • Field list within a table
  • Search and Scroll Search
  • Aggregated Search

Was this helpful?

  1. Ardexa API
  2. API

Python examples

In this article you will find examples in python of common use cases for the Ardexa API.

PreviousAPI Quick Start GuideNextAutomated API Token Renewal

Last updated 5 months ago

Was this helpful?

To complete the examples below you will need the following information:

  • or an .

  • Workgroup ID - ID of the workgroup containing the data. This can be found under .

  • Cloud - Cluster hosting the data. "app" for US and "eur1" for Europe. This can be confirmed by checking the first part of the url when accessing the Ardexa platform.

  • Table - Data table storing the data.

    • A list of all available tables can visualized on the selector.

    • The tables where a given node is logging data and the specific fields can be visualized in .

    • A list of tables can be extracted via API (refer to example below)

  • Device ID - ID of the Node to extract data from. This can be found on

  • Source - Source which collected the desired data.

    • A list of available sources can be visualized on to extract data from.

  • Field(s) - Name of the data fields to extract.

    • A list of available fields per source can be visualized on .

    • A list of fields within a table can be extracted via API (refer to example below)

  • Date field - Field selected as timestamp.

    • Check the differences between date fields in our .

    • A list of available date fields can be visualized on the selector.

    For additional information, check the in our knowledge base and the .

Workgroup general information

import json
import requests

TOKEN = "<API or personal token>"
WORKGROUP_ID = "<Workgroup ID>"
CLOUD = "<Cloud>" # Modify according to the server hosting the data, app/eur1/other

headers = {
    "authorization": "Bearer {}".format(TOKEN),
}

r = requests.get("https://{}.ardexa.com/api/v1/orgs/{}".format(CLOUD, WORKGROUP_ID), headers=headers)
results = r.json()
    
print(results)

Node list

import json
import requests

TOKEN = "<API or personal token>"
WORKGROUP_ID = "<Workgroup ID>"
CLOUD = "<Cloud>" # Modify according to the server hosting the data, app/eur1/other

node_names = []

headers = {
    "authorization": "Bearer {}".format(TOKEN),
}

r = requests.get("https://{}.ardexa.com/api/v1/devices/{}".format(CLOUD, WORKGROUP_ID), headers=headers)
results = r.json()

for device in results:
    node_names.append(device["name"])
    
print(node_names)

Table list

import json
import requests

TOKEN = "<API or personal token>"
WORKGROUP_ID = "<Workgroup ID>"
CLOUD = "<Cloud>" # Modify according to the server hosting the data, app/eur1/other

headers = {
    "authorization": "Bearer {}".format(TOKEN),
}

r = requests.get("https://{}.ardexa.com/api/v1/tables/{}".format(CLOUD, WORKGROUP_ID), headers=headers)
results = r.json()
    
print(results)

Field list within a table

import json
import requests

TOKEN = "<API or personal token>"
WORKGROUP_ID = "<Workgroup ID>"
CLOUD = "<Cloud>" # Modify according to the server hosting the data, app/eur1/other

TABLE = "<Table>" # Input table containing the desired data

headers = {
    "authorization": "Bearer {}".format(TOKEN),
}

field_names = []

r = requests.get("https://{}.ardexa.com/api/v1/tables/{}/{}".format(CLOUD, WORKGROUP_ID, TABLE), headers=headers)
results = r.json()

for field in results["fields"]:
    field_names.append(field)
    
print(field_names)

Search and Scroll Search

import json
import requests

TOKEN = "<API or personal token>"
WORKGROUP_ID = "<Workgroup ID>"
CLOUD = "<Cloud>" # Modify according to the server hosting the data, app/eur1/other

TABLE = "<Table>" # Input table containing the desired data
DEVICE_ID = "<Node id>" # Input node to extract data from. This will be applied as a filter
SOURCE = "<Source>" # Input source to extract data from. This will be applied as a filter

headers = {
    "authorization": "Bearer {}".format(TOKEN),
}

# Apply filters to data stored in table <TABLE>, filter by device and source
filters = [{
    "field": "device",
    "operator": "=",
    "value": DEVICE_ID,
}, {
    "field": "source",
    "operator": "IN",
    "value": SOURCE,
}]

# Configure search parameters
params = {
    "dateField": "Datetime",
    "fields": ["Datetime", "device", "source", "Exported Active Energy"], # List of fields to extract 
    "rows": 10000, # maximum of 10000
    "scroll" : True, # enable Scroll search 
    "sort": "Datetime",
    "timeframe": "2025-01-01T00:00:00 until 2025-01-01T23:59:59", #configure timeframe
    "timezone": "Europe/Madrid",
    "filters": map(json.dumps, filters),
}

print("Fetching data...")

# Initial API call
r = requests.get("https://{}.ardexa.com/api/v1/tables/{}/{}/search".format(CLOUD, WORKGROUP_ID, TABLE), params=params, headers=headers)
results = r.json()
print("GOT RESULTS: {} ROWS".format(len(results["records"])))
print(results)

# Additional API calls for Scroll Searching
while 'scroll_id' in results:
    params = { "scroll_id": results["scroll_id"] } # Input Scroll ID as sole parameter
    r = requests.get("https://{}.ardexa.com/api/v1/tables/{}/{}/search/scroll".format(CLOUD, WORKGROUP_ID, TABLE), params=params, headers=headers)
    results = r.json()
    print("GOT RESULTS (scroll): {}".format(len(results["records"])))
    print(results)
    
print("*** Raw data fetch completed ***")

Aggregated Search

import json
import requests

TOKEN = "<API or personal token>"
WORKGROUP_ID = "<Workgroup ID>"
CLOUD = "<Cloud>" # Modify according to the server hosting the data, app/eur1/other

TABLE = "<Table>" # Input table containing the desired data
DEVICE_ID = "<Node id>" # Input node to extract data from. This will be applied as a filter
SOURCE = "<Source>" # Input source to extract data from. This will be applied as a filter

headers = {
    "authorization": "Bearer {}".format(TOKEN),
}

# Configure aggregation parameters
aggs = [{
    "field":"Exported Active Energy",
    "dateField":"Datetime",
    "type":"date_histogram",
    "interval":"15m",
    "groupBy":["source"]
    }]

# Apply filters to data stored in table <TABLE>, filter by device and source
filters = [{
"field": "device",
"operator": "=",
"value": DEVICE_ID,
}, {
    "field": "source",
    "operator": "=",
    "value": SOURCE,
}]
params = {
    "dateField": "Datetime",
    "fields": ["Datetime","device","source", "AC Power"],
    "rows": 0, #Rows must be set to 0 and no Scroll Search must be set.
    "sort": "Datetime",
    "timeframe": "2022-03-01T00:00:00+01:00 until 2024-10-31T23:59:59+01:00",
    "timezone": "Europe/Madrid",
    "filters": map(json.dumps, filters),
    "aggs": map(json.dumps, aggs),
}

print("Fetching data...")

r = requests.get(f"https://{CLOUD}.ardexa.com/api/v1/tables/{WORKGROUP_ID}/{TABLE}/search", params=params, headers=headers)
results = r.json() # Convert the response to JSON
print(results)
    
print("*** Downsampled data fetch completed ***")

Personal API token
issued API token
Admin > Workgroup > Settings
Searches Table dropdown
Analysis upon selecting a source
Devices > "device name" > Manual config > General
Analysis upon selecting the Node
Analysis upon selecting a source
knowledge base article
Analysis Date Field dropdown
API articles
Ardexa Apiary