Skip to content

Web API

The LOGINventory Web API can be used to query data from the LOGINventory database using HTTP Requests. This type of interface is suitable for various application scenarios, e.g. to fetch individual live data with another system directly from LOGINventory, to perform mass exports to third party systems, or to write data from third party applications directly into LOGINventory. Possible scenarios are described in more detail below.

There are two different variants of the Web API:

  • the General REST API (General Web API) allows full access to all LOGINventory data. If this API has been activated, all data can be accessed by a user who has the LOGINventory authorization level Administrator, without having to define endpoints for this purpose.
  • Using Web API endpoints to be created explicitly, it is possible to define exactly which users are allowed to access which data with read rights via the respective endpoint. This allows access to be restricted to certain devices or certain properties of these devices, for example.

Important

The supported commands for retrieving / writing data via the General Web API including sample requests and sample responses can be found in our Postman Collection.

Prerequisites

In order for the Web API to be accessible, the Web Viewer has to be published. If the Web Viewer was already published in a version that did not include the Web API functionality, it may be necessary to republish the Web Viewer. However, this is also checked when enable a Web API endpoint.

Activating the General Web API

Only if the checkmark to enable the General Web API has been set in the application-specific settings is it possible to access it. The box is not checked by default.

Setting up Web API Endpoints

Only users who have the LOGINventory permission level Administrator can create or edit endpoints.

To enable access via the Web API, a Web API endpoint must be published.

Important

A Web API endpoint defines the "entry point" for accesses. The query on which the endpoint is defined thus determines what data can be queried via the API. Likewise, the result sets of the queries below the entry point are also accessible through the end point, so that data on multiple 1:n relationships can also be retrieved from the database.

Activate a Web API Endpoint

Web API endpoints can be positioned on all queries in the tree structure. The result set of the query determines which data is accessible via the endpoint.

To set up the endpoint on a query, the ribbon menu Node Properties can be used to navigate to the tab Web API.

This menu then provides options to enable the endpoint, assign a unique name, and optionally specify a filter path.

The assigned name is then also found in the Web API URL under which the data can be retrieved. The URL can be copied to the clipboard by clicking the corresponding button.

Info

Optionally, there is also the possibility to create a URL in this dialog with the help of the Filter Pattern Generator, which contains a filter. A filter condition can be created which is then "translated" into the URL. This function can be useful to connect third party systems that should not retrieve the complete result set, but e.g. only the data for a specific device.However, the Filter Pattern Generator does not have to be used to create a filtered URL. If you are familiar with the syntax, you can likewise add filters to the URL when retrieving the data, without first creating them in the generator.

Definition of the Data Structure

As mentioned at the beginning, the data available through the Web API endpoint is the data contained in the result set of the query. This means that both the column selection of the query, and filter conditions defined in the Query Editor are respected.

Info

User defined layout customizations, like column orders, hiding columns or filters in the data view, have no influence on the data available via the endpoint.

If there are other queries below the query on which the endpoint was set up, then the result sets of those queries are also available through the endpoint. In this way, several 1:n relationships to the base table of the query can also be retrieved via the endpoint, e.g. for a device both device detail (1:1 relationship) and information about the software packages present there (1:n relationship) and the installed memory modules (1:n relationship).

Important

Below Device queries only queries whose base table has a direct navigation to the Device entity can be used. These are mostly queries whose base table ends with Info, e.g. SoftwarePackageInfo or MemoryModuleInfo. All queries that are located in the tree structure below Software, Hardware or Configuration in the subfolder "Query Lists" meet this criterion. Therefore, if necessary, these queries can be copied under the query node with the endpoint. Other queries to which there is no direct navigation, e.g. with base table SoftwarePackage can be inserted in the tree structure below a node with endpoint, but a JSON export is not possible. Whether the export works can be tested in LOGINventory by selecting the option Json Export in the ribbon menu Quick Export on the node with the endpoint and the export runs through without error message.

Overview of Enabled Endpoints

All enabled endpoints are listed below the Web API Endpoints node. From here it is also possible to edit the endpoints or deactivate them again if no access should be possible through them anymore.

Access to the Web API

Using HTTP requests, data can be retrieved from an enabled Web API endpoint. For example, the response in JSON format looks like the following:

[
    {
        "DeviceInfo": {
            "ChassisType": "Rack Mount Chassis"
        },
        "LastInventory": {
            "Ip": "192.168.200.26",
            "Timestamp": "2022-06-02T10:56:28.763"
        },
        "Name": "DEKAN",
        "Software-Pakete": [
            {
                "Name": "HP Officejet Pro 8620 Basic Device Software",
                "Version": "32.3.198.49673"
            },
            {
                "Name": "HP Officejet Pro 8620 Help",
                "Version": "32.0.0"
            }
        ],
        "RAM-Module": [
            {
                "Name": "PROC 1 DIMM 2A",
                "SerialNumber": "61FF05E6",
                "Size": 16384,
                "Speed": "1333"
            },
            {
                "Name": "PROC 1 DIMM 1D",
                "SerialNumber": "CC176230",
                "Size": 2048,
                "Speed": "1333"
            }
        ]
    },
...

Testing the Connection Using a Web Browser

Using a web browser, the corresponding endpoint URL can also be accessed if the user used (or the user logged in in the case of Windows authentication) is authorized to do so.

Authentication

Warning

After publishing the web viewer, only "ASP.NET Identity Switching" and "Windows Authentication" are enabled by default. If the client you are using does not support Windows authentication, you may still need to enable "Basic Authentication" in the IIS settings (running inetmgr) for the LOGINventory page.

Access to the Web API can be authorized using standard authentication (Basic Authentication) - i.e. user name and password - or integrated Windows authentication. The used user must be authorized on the query in LOGINventory itself (= the query must be shared with the user), so that the data can be retrieved.

Info

If no roles have been assigned in LOGINventory, any user can access all data in LOGINventory and thus retrieve data via a Web API endpoint.

A user who is not authorized to access the corresponding query will not be able to retrieve data via the endpoint and receives an error message.

To allow connection without username and password, Anonymous authentication can be enabled in the IIS settings (running inetmgr).

General Web API: Syntax and Examples

To access the General Web API a URL like http://my-loginventory-server/LOGINventory9/api/v1/ is used, whereas accessing endpoints still additionally contains the strings data/endpoint-name, e.g. http://my-loginventory-server/LOGINventory9/api/data/endpoint1.

As with queries, a request to the General Web API must also include a base table. Commonly used base tables are

  • Device to query scanned devices
  • PeripheralDevice to query peripheral devices
  • HardwareAsset to query both Devices and PeripheralDevices (see class hierarchy "HardwareAsset")
  • User for querying data about users
  • SoftwarePackage for querying data about software packages
  • UserAccount for querying data about user accounts according to Active Directory

The base table is appended to the URL.

Additionally

  • select only certain entries by appending their ID with a /.
  • add filter conditions by adding filter={Condition} as a parameter.
  • select only specific properties by adding select=PROPERTIE(S) as a parameter.
  • paths can be specified if there are multiple paths between two entities by appending (Path=PATHNAME) as navigation parameter.

Tip

Instead of assembling the URL yourself, it is often much easier to navigate to a corresponding query in LOGINventory: In the Node Properties (accessed via the Node Properties ribbon menu in the Web API tab), a URL can be copied directly there, respecting the selection of properties, filters, and paths:

For an API request that returns the same result set as the "Windows Clients" query, the URL is http://VT-WINDOWS10/LOGINventory9/api/v1/Device?filter={"Device":"[OperatingSystem.OperatingSystem.Platform] = 'Windows' And [OperatingSystem.OperatingSystem.Name] Not Like '%Server%' And [LastInventory.Method] <> 'EAS'"}&select=Archived,DeviceInfo.ChassisType,LastInventory.Ip,DeviceInfo.MemorySizeGB,Meta.Modified,Name,Cpu.Cpu.Name,HardwareProduct.HardwareProduct.Name,OperatingSystem.OperatingSystem.Name,Owner.Name,OperatingSystem.ReleaseID,SerialNumber,LastInventory.Timestamp,DeviceInfo.VmRunsOnHost

Important

The supported commands for retrieving / writing data via the General Web API including sample requests and sample responses can be found in our Postman Collection as well as in the following documentation.

Application Scenarios

Mass Export to Other Systems

In order to use data from LOGINventory in a third-party system (e.g. a CMDB for modeling dependencies between systems), various export mechanisms are available. Compared to the csv export, the export via Web API endpoint offers the possibility to export several 1:n relationships in one data set, so that e.g. the data for all installed software packages, connected monitors and partition assignments can also be queried for a device. Furthermore, not only a schedule-controlled push of the data, but also a pull of the data is possible. To prepare such an export, you can proceeded e.g. as follows:

  1. a new query structure is defined in LOGINventory that contains exactly the columns that are to be exported to the third party system. If several 1:n relationships to a device are to be exported, corresponding queries are created below the first query (see Definition of the data structure).
  2. a new Web API endpoint is set up on the new query via the Node Properties.
  3. the third party system imports the data periodically via HTTP GET request, updating the internal dataset as needed.

Live Connection of Individual Datasets

In order to retrieve additional information from the inventory in a third-party system (e.g. a helpdesk), which also displays data on computers like LOGINventory, it is suitable to connect both systmes using HTTP requests. Both variants of the Web API are suitable for this purpose:

Using the General Web API

All data records can be accessed via the General Web API without having to define an endpoint in LOGINventory beforehand. For example, additional properties such as model, serial number, operating system name, etc. could be retrieved for a device name and processed further in a third-party system.

Likewise, data from third-party systems can be written directly to LOGINventory, e.g.

  • if a new device has been ordered, it can be created directly in LOGINventory and the invoice can be linked.
  • if a ticket is created / edited in a ticket system, relevant information about the ticket can be stored in a lifecycle entry in LOGINventory.
  • if the status of a device is updated in another system, this can be written directly to a Custom Property.
  • if a device is deleted or archived in another system, this can also be done automatically in LOGINventory.

Using a Web API Endpoint

  1. a new query is defined in LOGINventory that contains exactly the columns that should be displayed in the third party system, e.g. name of the device (Device.Name), operating system (OperatingSystem.Name), IP address (LastInventory.IP), location (Custom property Custom.Location) and date of last boot (OperatingSystem.LastBoot). No filtering is needed in the query itself.
  2. a new Web API endpoint is set up on this query via the Node properties.
  3. in the helpdesk the name of the affected device is already known; the other values should be dynamically queried "live" from LOGINventory. This means that the results of all devices should not be queried, but only those of a specific device. For this purpose, the Filter Pattern Generator can be used to generate a URL that filters on a specific device (e.g. Device.Name = PC123). The generated URL can be used by the third party system to retrieve the data of the device 'PC123'.
  4. to retrieve the data of another device the text 'PC123' in the URL must be replaced by the name of the respective device.

Direct Connection to Other Systems

Does your company use software that should be connected in a similar way as described here? Feel free to contact the manufacturer of the software and establish the contact to us. We are ready to support you with the connection.