Is this page helpful?
76x
001921
2024-11-27

API II

This article gives a brief introduction to the API II of RFEM 6.

What is an API?

An API (Application Programming Interface) is an interface through which different software applications can communicate with each other. An API defines rules for the exchange of information between programs.

With API II, it is possible to access the functions of RFEM 6 / RSTAB 9 with self-programmed software. For example, it is possible to generate models, create loads, start the calculation, and finally, read the results.

RFEM 6 / RSTAB 9 already has an API, the Web Service Interface (API I). This will also be maintained. Therefore, it is not absolutely necessary to convert the existing software to API II.

If new functionalities are added in RFEM 6 / RSTAB 9, they are only available in API II. API I remains "frozen" at the current level.

What are the technical differences from the "old" API?

First of all, both interfaces are based on Webservice technology. RFEM 6 / RSTAB 9 communicates with the client software via HTTP (or HTTPS) protocol.

With API I, the client and server exchange messages in SOAP format. API II uses the gRPC protocol instead.

SOAP exchanges messages in XML format. Communication using SOAP has a relatively high overhead.

In contrast, gRPC exchanges messages in a lightweight, buffer-based binary format. This is much more efficient than text-based formats like XML or JSON.

gRPC uses the newer HTTP/2 protocol, which also makes transmission more efficient.

The new API II allows multiple objects to be combined into a list and then transferred. This means that only a few API calls are required, rather than a large number of small ones. This also increases efficiency. The example below shows how this batch technique works.

All these efficiency measures mean that communication via the new API II is about 10 times faster than via API I.

API II allows the same code to run on three different platforms without any modifications.

  1. As a stand-alone Python program that accesses a locally or network-installed RFEM 6 from the "outside".
  2. In the internal script console of RFEM 6.
  3. In the Dlubal cloud.

Stand-Alone Program

Normal RFEM 6 is installed on your computer. Your Python program communicates with RFEM via API II.

Script Console

Your script will be executed directly in the scripting console of RFEM.

Dlubal Cloud

For this application, RFEM does not have to be installed locally at all. You write your application program that communicates with a server in the Dlubal Cloud. Your application program generates structural and loading data on the server. The calculation is performed on the server. Your application program reads the results from the calculation and evaluates them.

What has changed in the billing process?

A monthly usage fee was charged for using the old API I. This was independent of actual use.

The new API II changes this to a usage-based billing model. This means that there is a charge for calling certain API functions. This will be charged in Dlubal credits. These can be purchased in the webshop.

Generating API Key

To use API II, an API key is required in addition to the Webservice subscription. An API key is a piece of text used for identification and authentication.

The user can generate API keys in the Extranet.

Each of the generated API keys is assigned to a “company”. This means that any user assigned to the company can use the keys.

It is possible and often useful to generate multiple API keys. No additional costs will be charged. For example, it makes sense to generate a separate key for each project. This way, the user can distinguish between the individual projects in their internal accounting.

Installation of Interface

The package for the interface is available via PiPI. Run the following command to install the package:

pip install dlubal.api

Program Example

A small example demonstrates the use of the new API II. A cantilever beam consisting of an IPE 200 is created.

Here is the program code:

import dlubal.api.rfem as rfem

with rfem.Application() as rfem_app:

    rfem_app.create_model(name='cantilever')
    rfem_app.delete_all_objects()

    inf = float('inf')

    structure = [
        rfem.structure_core.Material(
            no=1,
            name='S235'
        ),
        rfem.structure_core.Section(
            no=1,
            name='IPE 200',
            material=1
        ),
        rfem.structure_core.Node(
            no=1
        ),
        rfem.structure_core.Node(
            no=2,
            coordinate_1=6.0
        ),
        rfem.structure_core.Line(
            no=1,
            definition_nodes=[1,2]
        ),
        rfem.structure_core.Member(
            no=1,
            line=1,
            section_start=1
        ),
        rfem.types_for_nodes.NodalSupport(
            no=1,
            nodes=[1],
            spring_x=inf,
            spring_y=inf,
            spring_z=inf,
            rotational_restraint_x=inf,
            rotational_restraint_y=inf,
            rotational_restraint_z=inf
        ),
    ]

    rfem_app.create_object_list(structure)

First, the RFEM library is imported.

The instance <code>rfem_app</code> of this class is created using the <code>with</code> command. The API key can be provided as an argument of <code>rfem.Application()</code>. However, we do not recommend this for security reasons. Instead, the API key should be stored in the config.ini file. How this works exactly is explained in the detailed documentation of API II:

In the next line, a new RFEM model is created using the <code>rfem_app.create_model(name='cantilever')</code> method. The model name is transferred as a parameter.

In the next few lines of code, the new API II differs fundamentally from the “old” approach in API I. First of all, the structure elements are defined in the structure list. Then, these are transferred together with the command <code>rfem_app.create_object_list(structure)</code>.


Author

Mr. Faulstich is responsible for the quality assurance of the RFEM program and provides customer support.

Links


;