##  [SCADE API-tools Companion Article](/blog/scade-api-tools-companion-article) 

In this article, we'll take a look at Ansys SCADE API Tools ([GitHub link](https://github.com/ansys/scade-apitools)), designed to simplify usage of the SCADE Python APIs.

### The vanilla SCADE Python API

Most Ansys products come packaged with Python APIs (as part of the [PyAnsys](https://developer.ansys.com/pyansys) initiative). These open-source libraries allow engineers to interact programmatically with Ansys products, integrating them into their workflows.

Ansys SCADE is no exception. Its Python API allows users to:

- Walk through SCADE models and modify them using code
- Access generated artefacts (mapping files, test results, model coverage...)

If you're interested in using the SCADE Python API, we've already written an article on [getting started](https://ansyskm.ansys.com/forums/topic/using-the-scade-python-apis-from-your-favorite-ide/) with your favorite IDE.

### Introducing `ansys-scade-apitools`

We are pleased to announce the release of `ansys-scade-apitools`, a Python package that extends the standard SCADE Python API.

Its goal is to make the SCADE API easier to use by adding a collection of high-level functions that accomplish complex operations without exposing low-level concepts to the user.

Key benefits are:

- Simplified configuration to run Python code from your preferred IDE.
- High-level, Pythonic APIs allow creating models, automatically handling intermediate elements and their consistency.

The package is structured into five modules:

- `create`: collection of functions for creating or updating SCADE models. This includes creating types, operators, interfaces and other constructs.
- `expr`: collection of functions for accessing expressions. This covers walking through a model's operators and expressions.
- `info`: provides information on the current version of SCADE.
- `prop`: collection of functions for the storage of settings and properties.
- `query`: collection of queries about SCADE Suite types.

#### Some examples

The examples below illustrate a couple of the numerous functions exposed by API Tools.

**Example 1**: accessing an If expression with a Python script ([link](https://apitools.scade.docs.pyansys.com/version/stable/_examples/expr_access.html))

- SCADE Diagram:

![](https://developer.ansys.com/sites/default/files/inline-images/scade-010-example-1-diagram.png)

- Python code:

```python
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.expr import IfThenElseOp, accessor
# load the Scade model
model = get_sessions()[0].model
# retrieve the equation defining 'expression'
equation = model.get_object_from_path('Access::IfThenElseOp/expression=')
# get an accessor for the equation's expression
ex = accessor(equation.right)
# check the type of the wrapped expression
assert isinstance(ex, IfThenElseOp)
# dump the fields of the expression
output('kind: %s\n' % ex.code)
output('instance name: %s\n' % ex.name)
# the 'if' flow is a local variable, dump the name
output('condition: %s\n' % ex.if_.path.name)
# the 'then' flows are local variables, dump the name
output('then: [%s]\n' % ','.join([_.path.name for _ in ex.then]))
# the 'else' flows are local variables, dump the name
output('else: [%s]\n' % ','.join([_.path.name for _ in ex.else_]))

```



- Output:

```python
kind: Eck.IF
instance name: 1
condition: i
then: [t]
else: [e]

```



**Example 2**: printing SCADE version properties with a Python script ([link](https://apitools.scade.docs.pyansys.com/version/stable/_examples/info.html))

- Python code:

```python
from scade import output
from ansys.scade.apitools.info.install import get_scade_properties
for property, value in get_scade_properties().items():
    output('%s: %s\n' % (property, value))

```



- Output:

```bash
RELEASE: 2023 R2
BUILD_NUMBER: 20230526T185112
RELEASE_DATE: May 26, 2023
RELEASE_COPYRIGHT: (C) 2023 ANSYS, Inc. […]
COPYRIGHT_END_DATE: 2023
RELEASE_INTERNAL: 23.2
INSTALL_FOLDER: v232
SCADE_STUDIO_NUMBER: 23200

```



The library has many more functions than illustrated in this short article. You may find them described in the [Examples section](https://apitools.scade.docs.pyansys.com/version/stable/examples/create.html) of our online docs.

### Ready to try it out?

If you're interested in using Ansys SCADE API Tools, our [online docs](https://apitools.scade.docs.pyansys.com/version/stable/index.html) are a great starting point. The package is published on PyPI (Python Package Index) as [ansys-scade-apitools](https://pypi.org/project/ansys-scade-apitools/).

If you wish to look under the hood and/or contribute, sources are available on the dedicated Ansys GitHub [repository](https://github.com/ansys/scade-apitools).

### About the author

![](https://developer.ansys.com/sites/default/files/inline-images/scade-010-author_0.png)

**François Couadau** ([LinkedIn](https://www.linkedin.com/in/fcouadau/)) is a Senior Product Manager at Ansys. He works on embedded HMI software aspects in the SCADE and Scade One products. His past experience includes distributed systems and telecommunications.