> For the complete documentation index, see [llms.txt](https://docs.editran.onesait.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.editran.onesait.com/documentacion-editran/open-v5.2.1-en/api.md).

# API

The application programming interface based on the module of *editranG*, from Indra's communications platform, allows application developers to access all the services provided by the platform.

This API incorporates the same functionality offered from the operator menu of *editranG*, thus allowing manual operation to be replaced by an application program.

## Service request

### EDItranG Req Function

Performs the request to **editranG** for the given presentation and waits for the result of that request if 'bWait' is not zero.

* Function declaration in C, C++

```c
Int EDItranG_Req (char *Request, char \*Presentation, int bWait, int
bVerbose);
```

* Function declaration in Visual Basic

```vb
Declare Function EDItranG_Req Lib \"libedi_g\" Alias \"\_EDItranG_Req\"
(ByVal txtRequest As String, ByVal txtPresentation As String, ByVal
bWait As Long, ByVal bVerbose As Long) As Long
```

#### Parameters

* Request - Operation to perform, it can take the following values

| INITE\_EDITRANG\_REQ   | Initialize transmission |
| ---------------------- | ----------------------- |
| LOADE\_EDITRANG\_REQ   | Load transmission       |
| SEND\_EDITRANG\_REQ    | Send                    |
| ENDE\_EDITRANG\_REQ    | Interrupt transmission  |
| INITR\_EDITRANG\_REQ   | Initialize reception    |
| UNLOADR\_EDITRANG\_REQ | Unload reception        |
| RECV\_EDITRANG\_REQ    | Receive                 |
| ENDR\_EDITRANG\_REQ    | Interrupt reception     |

* Presentation - identifier of the presentation on which to make the request.
* bWait - Wait for response.
* bVerbose - Verbose mode.

#### Return values

| *CODE* | *ID*               | *MESSAGE*                                                                                                                                                                 |
| ------ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 0      |                    | Successful result                                                                                                                                                         |
| 62     | NO\_TAMPON         | Incorrect TAMPON format                                                                                                                                                   |
| 64     | OPEN\_IN           | Error opening the application file to be sent.                                                                                                                            |
| 65     | OPEN\_OUT          | Error opening the application file to be received.                                                                                                                        |
| 66     | READ\_CTRL         | Error reading control information in TAMPON or CSB.                                                                                                                       |
| 67     | WRITE\_CTRL        | Error writing control information in TAMPON or CSB.                                                                                                                       |
| 68     | WRITE\_DATA        | Error writing data in TAMPON or CSB.                                                                                                                                      |
| 69     | ZERO\_REC          | TAMPON file with no records loaded.                                                                                                                                       |
| 70     | ALLOC\_ERROR       | Internal error: memory management.                                                                                                                                        |
| 71     | SAVE\_REL          | Error saving information about transmitted files.                                                                                                                         |
| 73     | WRITE\_OUT         | Error writing the application file to be received.                                                                                                                        |
| 74     | SEQUENCE\_CSB      | Erroneous CSB file: sequence error.                                                                                                                                       |
| 75     | TOTAL\_FILES       | Erroneous CSB file: error in total number of files.                                                                                                                       |
| 76     | TYPE\_FILE         | Erroneous CSB file: unknown file format.                                                                                                                                  |
| 77     | LENGTH\_CSBREC     | Erroneous CSB file: error in file length.                                                                                                                                 |
| 78     | HASH\_ERROR        | Error calculating/validating hash of transmitted files.                                                                                                                   |
| 79     | SIZE\_FILERECS     | Mismatch in the number of records in the application file. The total number of records indicated in the CSB control fields does not match the number actually downloaded. |
| 80     | TOTAL\_CSBRECS     | Erroneous CSB file: error in total number of records.                                                                                                                     |
| 81     | SIZE\_FILEBYTES    | Mismatch in the total bytes of the application file. The number of bytes indicated in the CSB control fields does not match the number actually downloaded.               |
| 82     | SYNCS\_CSB         | Mismatch in the number of synchronizations in CSB.                                                                                                                        |
| 83     | CFG\_LENGTH        | Application file with a record shorter than the one specified in the profile. Check the characteristics of the files to be sent.                                          |
| 84     | STS\_ERROR         | Error accessing the editran/G status file.                                                                                                                                |
| 85     | OPEN\_CSB          | Error opening/creating CSB file.                                                                                                                                          |
| 86     | NO\_PERFILG\_LOCAL | No local editran/G profile exists.                                                                                                                                        |
| 87     | NO\_PERFILG        | No Presentation profile exists.                                                                                                                                           |
| 88     | EXEC\_CONVER       | Generic error in CSB conversion process.                                                                                                                                  |
| 89     | EXEC\_CARGADOR     | Error in the TAMPON load/unload process.                                                                                                                                  |
| 90     | CFG\_NO\_FILES     | None of the files specified in the profile as emission files exist or can be found.                                                                                       |
| 91     | USER\_SCRIPT       | Error executing user script.                                                                                                                                              |
| 93     | PROFILES           | Presentation profile incompatible with load/unload process.                                                                                                               |
| 94     | CANCELED\_REQ      | Transmission canceled.                                                                                                                                                    |
| 95     | PROC\_ERROR        | Internal error: process creation.                                                                                                                                         |
| 96     | RUNTIME\_EXCEPT    | Internal error: "runtime exception".                                                                                                                                      |
| 97     | NO\_LICENSE        | License problem for performing one of the required functions.                                                                                                             |
| 98     | CRYPT\_ERROR       | Error in the cryptographic processing of data.                                                                                                                            |
| 99     | HDRFILE            | Internal error: invalid control headers.                                                                                                                                  |
| 200    | NO\_ACK            | Remote download could not be confirmed.                                                                                                                                   |
| 201    | NO\_STATE          | Request incompatible with the transmission state.                                                                                                                         |
| 104    | LIBERACION\_P      | Exception - Abort                                                                                                                                                         |
| 110    | LIBERACION\_P      | Exception - Operator                                                                                                                                                      |
| 120    | LIBERACION\_P      | Exception - Incorrect remote TAMPON. Launches previous.                                                                                                                   |
| 121    | LIBERACION\_P      | Exception - Incorrect remote TAMPON. No previous exists.                                                                                                                  |
| 122    | LIBERACION\_P      | Exception - Incorrect remote TAMPON. Previous in possible execution                                                                                                       |
| 123    | LIBERACION\_P      | Exception - Incorrect remote TAMPON. Incorrect exchange session number                                                                                                    |
| 124    | LIBERACION\_P      | Exception - Incorrect remote TAMPON. Total number of records                                                                                                              |
| 130    | LIBERACION\_P      | Exception - Network disconnection.                                                                                                                                        |
| 140    | LIBERACION\_P      | Exception - Excess retries for sending.                                                                                                                                   |
| 160    | LIBERACION\_P      | Exception - Totals mismatch.                                                                                                                                              |
| 170    | LIBERACION\_P      | Exception - Excess synchronization retries.                                                                                                                               |
| 190    | LIBERACION\_P      | Exception - Excess retries for end of transmission.                                                                                                                       |
| 240    | LIBERACION\_P      | Exception - Profiles.                                                                                                                                                     |
| 250    | LIBERACION\_P      | Exception - TAMPON file not available.                                                                                                                                    |

### GetErrText Function

Converts the return codes of the function *EDItranG\_Req* into text.

The function *GetErrText* is suitable for use in C or C++ programs or other Windows programming languages such as Visual Basic.

* Function declaration in C, C++:

```c
void GetErrText (int nError, char \*szError);
```

* Function declaration in Visual Basic:

```vb
Declare Sub GetErrText Lib \"libedi_g\" Alias \"\_GetErrText\" (ByVal
nError As Long, ByVal strError As String)
```

### EDItranIsAlive Function

Indicates the state of the editran system. The function returns 0 if the system is inactive and 1 if it is ready to receive requests.

* Function declaration in C, C++:

```c
int EDItranIsAlive (void);
```

## Runtime environment

Applications that use the API of **editranG** can be invoked from any directory. To do so, it is only necessary to modify the PATH environment variable so that it includes the directory where the DLLs implementing the API are located.

When the editran system to which requests are made is located on a remote system, it is necessary to define the IP address to connect to. In these cases, in the folder containing the editran DLLs */API* create a text file named *distributed.cfg* with the following content:

editrang;\<ip-editran-server>

## Programming example

### C, C++ environment

In editran/API an example of using the API in the C programming language is provided. It is located in the folder *example* and contains:

* *egreq.c*: source file showing how to use the API to generate a utility that sends/transmits and receives via editran.
* *ejemplo.sln, ejemplo.vcproj*: Microsoft Visual Studio 2008 project files with which to build the example program. To do so, open the file ejemplo.snl, select in *"Build > Configuration Manager"* as active configuration ***"Release"***. To build the application, on the menu bar select *"Build > Build Solution"*.

#### Dependencies

The DLLs delivered in the API were generated with Microsoft Visual Studio 2008, so they depend on the CRT (C run-time) library MSVCR90.dll. If applications that use the API are generated with a newer version of the compiler, when running the application a system error occurs:

![Error example](https://2807498471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2W4cn5C1WDTJzDOR25es%2Fuploads%2Fgit-blob-2f06145b2a86478953326ecb05ec609e3d9ae3f3%2Fejemplo_error.png?alt=media)

To solve it, the application must include the manifest file that describes that dependency. To include it, for example, in a Visual Studio 2015 project do:

* In the dialog "**Property Pages"** of the project, click on **"Manifest Tool"**, select **"Input and Output"**, in the field **"Additional Manifest Files"** add the file *bin\lib\libedi\_g.manifest* of the API.

![example property pages](https://2807498471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2W4cn5C1WDTJzDOR25es%2Fuploads%2Fgit-blob-4e80c40f8767cc7711a251b8a2344e303042d48e%2Fproperties_pages.png?alt=media)

### Visual Basic environment

* Ediapi.frm

```vb
Private Sub btnEjecutar_Click()
  Dim nRet As Integer
  Dim strError As String
  Dim txtRequest as String
  Dim txtPresentation as String
  Dim lWait as Long
  Dim lVerbose as Long

  'I reserve memory and assign variables
  strError = Space(500)
  txtRequest = "InitE"
  txtPresentation = "Presentation01"

  lWait = 1

  lVerbose =1

  'Call to the DLL function
  nRet = EDItranG_Req(txtRequest, txtPresentation, lWait, lVerbose)

  'I replace the error code with text using another call to the DLL
  GetErrText nRet, strError

  MsgBox ("Return: " & nRet & ". " & strError)

End Sub
```

* Module1.bas

```vb
Attribute VB_Name = "Module1"

' Global declarations of the DLL functions

Declare Function EDItranG_Req Lib "libedi_g" Alias "_EDItranG_Req" (ByVal txtRequest As String, ByVal txtPresentation As String, ByVal bWait As Long, ByVal bVerbose As Long) As Long

Declare Sub GetErrText Lib "libedi_g" Alias "_GetErrText" (ByVal nError As Long, ByVal strError As String)
```

## Onesait Components · Editran/API

To download the software, go to the [official Editran product page](https://www.onesait.com/editran/resources).

In the Resources > *Windows > Software > Core Modules* you will find the link to the zip file with the latest editran\*/API\* software.

* Once uncompressed, the downloaded software is structured according to the following directory tree:

```txt
home-api-editran
 |-- bin
 |    |-- lib
 |
 |-- include
 |-- example
```

* home-api-editran: created by the user as the root directory of the editran API software.
* home-api-editran/bin: DLLs that implement the functionality of the editran API.
* home-api-editran/bin/lib: import library with the export information for other C/C++ programs.
* home-api-editran/include: .h files with the C declaration of the interface described in this document.
* home-api-editran/ejemplo: files with the source code and the project needed to generate the example program in section 3.1.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.editran.onesait.com/documentacion-editran/open-v5.2.1-en/api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
