1. Support
  2. Knowledge base
  3. Infra
  4. Uptrends Infra API

API

The Uptrends Infra API allows you to programmatically obtain measured data in your account, like device statuses and sensor values. The API specification can be found in the Swagger environment for Infra.

Prerequisites

To use the Uptrends Infra API you need the following:

  1. The username and password of an Uptrends Infra user
  2. Access to the Swagger environment for Infra
  3. An API account

Registering an API account

  1. Go to the Swagger page, and expand the POST /Register method.
  2. Click the Try it out button to start creating an API account.
  3. Click on the Execute button.
  4. Your browser will now ask for your Uptrends Infra operator login credentials. Fill in the e-mail address and password that you normally use to access Uptrends Infra and click OK.
  5. After the login credentials of your Uptrends Infra account were verified, the Response body contains values for “U” and “P”.
    { "U": "usernamehere", "P": "passwordhere" }
    These are the credentials of your new API account.
  6. Copy and paste the Response body information or click the Download button within the Response body to save these credentials and keep them in a safe place. Use them as authentication for all other API calls.

Accessing the API

The API can be accessed at the specified base URL using the HTTPS protocol. The available endpoints and methods are described in the Swagger environment for Infra. This environment also allows you to execute API methods.

All API operations require HTTP Basic Authentication to get access to the information. The API account that you registered contains the authentication credentials.

Please note that all operations are executed within the authorization context of the user who created the API account. Therefore, you can perform the same actions as the user would be able to, when logged into the website.

Content type

You may specify an Accept header in the HTTP request, in order to receive the most appropriate content type for your application. Available content types are:

  • Accept: application/json
  • Accept: application/xml

All examples here are based on the application/json content type.

Defining a period of time

Many API operations have a period parameter, which allows you to specify a specific period. If that’s the case, you can specify any of the following literals: CurrentDay, CurrentWeek, CurrentMonth, CurrentYear, PreviousDay, PreviousWeek, PreviousMonth, PreviousYear, Last24Hours, Last48Hours, Last7Days, Last30Days, Last60Days, Last90Days, Last365Days, Last3Months, Last6Months, Last12Months, Last24Months.

It is also possible to define a custom period, using a start and end date. You should use the following format: yyyymmdd-yyyymmdd. A period from May 10, 2014 until May 20, 2014 would therefore be formatted as: “20140510-20140520”.

Examples of API usage

Get account info

This operation returns basic account information.

URL/v1/account
MethodGET
CredentialsAny valid API account
Parametersnone
ReturnsAn object containing properties:
  • AccountName: The name of the current account
  • UserName: The name of the current user

Example

The URL https://api.uptrendsinfra.com/v1/account yields:

{"AccountName":"1234565","UserName":"Michael Johnson"}

Get device group data

This operation returns current status data about the specified device group (or the “All devices” group, if no group is specified).

URL /v1/DeviceGroupData
Method GET
Credentials Any valid API account
Parameters see table below
Returns see table below

Parameters

Name Required/Optional Default value Comment
DeviceGroup Optional All devices ID of the device group
ShowDetailInfo Optional True Indication whether current values of the first two sensors must be returned.
SortOrder Optional ByStatus Sort order. Allowed values are ByStatus and Alphabetical.
StatusFilter Optional All Filter by status. Allowed values are All, Errors, ErrorsAndWarnings, NoData
GroupFilter Optional ItemsOnly Filter groups or devices. Allowed values are All, GroupsOnly, ItemsOnly
Skip Optional 0 Skip/Take are used in conjunction with each other to determine the “page” of requested data.
Take Optional 10
Period Optional Last24Hours The period to be used to calculate the Uptime percentage. See Defining a period of time for details.

Returns

An object containing properties:

Count The total number of items in the group
Status The current status of the group. Possible values are Error, Warning, OK, Unknown.
Devices A list of member items (devices or groups) in the group.

Each item has the following properties:

Id The ID of the item
Name The name of the item
Type The type of the item (either Device or Group)
Status The current status of the item (Error, Warning, OK, or Unknown)
Uptime The uptime of the item during the specified period
FriendlyUptime The uptime, formatted per the user’s preferences
DataFeeds A list of datafeeds for this item

Each datafeed has the following properties:

Id The ID of the datafeed
Name The name of the datafeed
Type The datatype of the datafeed
Status The current status of the datafeed (Error, Warning, OK, or Unknown)
Value The last value of the datafeed
FriendlyUptime The last value, formatted per the user’s preferences

Example

The URL https://api.uptrendsinfra.com/v1/devicegroupdata yields:

{ 
    "Status": "Error", 
    "Count": 2, 
    "Devices": [ 
        { 
            "Id": "d8b4a807-9d67-49bf-8d30-cf3c5a0d8c1c", 
            "Type": "Device", 
            "Name": "Server 1", 
            "Status": "OK", 
            "Uptime": 100.0, 
            "FriendlyUptime": "100.00", 
            "DataFeeds": [ 
                { 
                    "Id": "1c28fe8c-2245-45de-af5c-4e6b14108701:0", 
                    "Name": "CPU Load%", 
                    "Status": "OK", 
                    "Type": "Double", 
                    "Value": "8.1535912", 
                    "FriendlyValue": "8.15" 
                }, 
                { 
                    "Id": "b6f0b8a8-82dd-4040-8818-a4f7309fcb32:0", 
                    "Name": "Memory available", 
                    "Status": "OK", 
                    "Type": "Double", 
                    "Value": "1636", 
                    "FriendlyValue": "1,636" 
                } 
            ] 
        }, 
        { 
            "Id": "c6db88b2-856a-46be-b5cf-3ecd162607f8", 
            "Type": "Device", 
            "Name": "Server 2", 
            "Status": "Error", 
            "Uptime": 45.33, 
            "FriendlyUptime": "45.33", 
            "DataFeeds": [ 
                { 
                    "Id": "194e4c4d-4de9-4bf0-b6f2-1f72b43b9d09:0", 
                    "Name": "CPU Load%", 
                    "Status": "OK", 
                    "Type": "Double", 
                    "Value": "2.93857122", 
                    "FriendlyValue": "2.93" 
                }, 
                { 
                    "Id": "ee391ea7-0921-4fdc-b904-7321368518c6:0", 
                    "Name": "Memory available", 
                    "Status": "OK", 
                    "Type": "Double", 
                    "Value": "2477", 
                    "FriendlyValue": "2,477" 
                } 
            ] 
        } 
    ] 
} 
] 
} 

You may also specify any combination of parameters, e.g:

  • To obtain information for a specific device group, sorted alphabetically: https://api.uptrendsinfra.com/v1/devicegroupdata?SortOrder=Alphabetical&DeviceGroup=de7f11df-d284-4fb8-9e45-c2958313cf0e
  • To obtain the third page of 20 items: https://api.uptrendsinfra.com/v1/devicegroupdata?Skip=40&Take=20
  • To obtain only the items that are in error: https://api.uptrendsinfra.com/v1/devicegroupdata?StatusFilter=Errors
By using the Uptrends website, you consent to the use of cookies in accordance with our Cookie Policy.