---
title: Unified access interface
section: Concepts
weight: 5
description: The universal REST API and query language that give applications a single, standardized way to access the system's data and functions.
related:
  - integration
  - architecture/abstract-data-layer
  - basic-modules/modules
  - data-representation/components
---

import Alert from '@/components/docs/Alert.astro';

## Universal REST API

The system implements a universal REST API that provides a consistent interaction between different systems, applications, and devices. It abstracts away implementation details and provides a standardized way to access the system's data and functions.

The REST API service has the following data-handling characteristics:

- **Uniformity**: All requests and responses follow the same format.
- **Scalability**: Supports a large number of devices and users.
- **Security**: Provides authentication, authorization, and data encryption.
- **Documentation**: Has clear documentation for developers.

The service significantly simplifies further work with data:

- **Simplified integration**: Different systems and devices can interact through a single interface.
- **Hardware abstraction**: Applications do not depend on specific devices or protocols.
- **Centralized management**: All data requests go through a single point of entry.
- **Flexibility**: New features can be added or existing ones modified with ease.

<Alert type="note">
  The REST API service is described in more detail in the [API Reference](/en/api/v1) section.
</Alert>

#### Example of a universal REST API request

Data request:

```bash title="Request example"
GET /api/v1/channel_data?equipment_id=1&archive_type=daily&channel_id=3
```

Response:

```json title="Response example"
[
  {
    "id": 123,
    "equipment_id": 1,
    "seance_id": 2,
    "channel_id": 3,
    "archive_type_id": 4,
    "value": 42.5,
    "event_time": 1739950861
  }
]
```

### Benefits of the universal REST API

The REST API service is a powerful tool that creates a unified data access interface.

It allows you to:

- Abstract away from specific devices and technologies.
- Ensure consistency and ease of use.
- Simplify the integration of new systems and devices.

## Query language

Building on this unified data access interface, the system uses a query language so that users and applications can interact with the database to retrieve, modify, or manage information. A universal query language provides consistency, ease of use, and powerful data-manipulation capabilities.

The query language provides the following capabilities:

- **Simplified data manipulation**: Users can retrieve data without writing complex code.
- **Standardization**: A single language for all data operations.
- **Flexibility**: The ability to run both simple and complex queries.
- **Integration**: Easily integrates with various systems and applications.

### Example query languages used in the system

#### SQL (Structured Query Language)

The _PostgreSQL DBMS_ uses the _SQL_ query language to work with data. It supports basic data-manipulation operations.

An example of an SQL query for data retrieval:

```sql title="example.sql"
SELECT id, channel_id, value
FROM channel_data
WHERE equipment_id = 1 AND archive_type_id = 4;
```

#### REST interface with parameters

The universal _REST API_ implements a _REST_ interface with parameters as part of its interaction with data. This allows the _API_ to use query parameters to filter data.

For example:

```bash title="Request example"
GET /api/v1/channel_data?equipment_id=1&channel_id=101
```

#### Active Record Query Interface

The _Ruby on Rails_ framework implements _Active Record (the Active Record Query Interface)_, which lets you query databases without using SQL.

Here is an example of an _Active Record_ query to retrieve data:

```ruby title="Active record example"
ChannelDatum.where(equipment_id: 1, archive_type_id: 4)
```
