> 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.3-en/api.md).

# API

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

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

## Service request

### EDItranG Req Function

Sends 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 have the following values

| INITE\_EDITRANG\_REQ   | Initialize emission  |
| ---------------------- | -------------------- |
| LOADE\_EDITRANG\_REQ   | Load emission        |
| SEND\_EDITRANG\_REQ    | Emit                 |
| ENDE\_EDITRANG\_REQ    | Interrupt emission   |
| 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

| *COD* | *ID*               | *MESSAGE*                                                                                                                                                          |
| ----- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 0     |                    | Successful result                                                                                                                                                  |
| 62    | NO\_TAMPON         | Incorrect TAMPON format                                                                                                                                            |
| 64    | OPEN\_IN           | Error opening application file to be emitted.                                                                                                                      |
| 65    | OPEN\_OUT          | Error opening 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 without loaded records.                                                                                                                                |
| 70    | ALLOC\_ERROR       | Internal error: memory management.                                                                                                                                 |
| 71    | SAVE\_REL          | Error saving transmitted file information.                                                                                                                         |
| 73    | WRITE\_OUT         | Error writing application file to be received.                                                                                                                     |
| 74    | SEQUENCE\_CSB      | Incorrect CSB file: sequence error.                                                                                                                                |
| 75    | TOTAL\_FILES       | Incorrect CSB file: error in the total number of files.                                                                                                            |
| 76    | TYPE\_FILE         | Incorrect CSB file: unknown file format.                                                                                                                           |
| 77    | LENGTH\_CSBREC     | Incorrect CSB file: error in file length.                                                                                                                          |
| 78    | HASH\_ERROR        | Error calculating/validating hash of transmitted file.                                                                                                             |
| 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 those actually unloaded. |
| 80    | TOTAL\_CSBRECS     | Incorrect 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 those actually unloaded.               |
| 82    | SYNCS\_CSB         | Mismatch in the number of synchronizations in CSB.                                                                                                                 |
| 83    | CFG\_LENGTH        | Application file with fewer records than specified in the profile. Check the characteristics of the files to be emitted.                                           |
| 84    | STS\_ERROR         | Error accessing 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        | The Presentation profile does not exist.                                                                                                                           |
| 88    | EXEC\_CONVER       | Generic error in conversion to CSB process.                                                                                                                        |
| 89    | EXEC\_CARGADOR     | Error in TAMPON load/unload process.                                                                                                                               |
| 90    | CFG\_NO\_FILES     | None of the files specified in the profile as emission files exist or could be found.                                                                              |
| 91    | USER\_SCRIPT       | Error running user script.                                                                                                                                         |
| 93    | PROFILES           | Presentation profile incompatible with load/unload process.                                                                                                        |
| 94    | CANCELED\_REQ      | Transmission cancelled.                                                                                                                                            |
| 95    | PROC\_ERROR        | Internal error: process creation.                                                                                                                                  |
| 96    | RUNTIME\_EXCEPT    | Internal error: "runtime exception".                                                                                                                               |
| 97    | NO\_LICENSE        | License issue to perform any of the required functions.                                                                                                            |
| 98    | CRYPT\_ERROR       | Error in cryptographic processing of the data.                                                                                                                     |
| 99    | HDRFILE            | Internal error: invalid control headers.                                                                                                                           |
| 200   | NO\_ACK            | Remote unload 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 buffer. Triggers previous.                                                                                                            |
| 121   | LIBERACION\_P      | Exception - Incorrect remote buffer. No previous exists.                                                                                                           |
| 122   | LIBERACION\_P      | Exception - Incorrect remote buffer. Previous in possible execution                                                                                                |
| 123   | LIBERACION\_P      | Exception - Incorrect remote buffer. Incorrect exchange session number                                                                                             |
| 124   | LIBERACION\_P      | Exception - Incorrect remote buffer. Total number of records                                                                                                       |
| 130   | LIBERACION\_P      | Exception - Network disconnection.                                                                                                                                 |
| 140   | LIBERACION\_P      | Exception - Too many retries to emit.                                                                                                                              |
| 160   | LIBERACION\_P      | Exception - Totals mismatch.                                                                                                                                       |
| 170   | LIBERACION\_P      | Exception - Too many synchronization retries.                                                                                                                      |
| 190   | LIBERACION\_P      | Exception - Too many end-of-emission retries.                                                                                                                      |
| 240   | LIBERACION\_P      | Exception - Profiles.                                                                                                                                              |
| 250   | LIBERACION\_P      | Exception - TAMPON file unavailable.                                                                                                                               |

### GetErrText Function

Transforms the function's return codes *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 status 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 **editranG** API can be invoked from any directory. To do this, it is only necessary to modify the PATH environment variable to include the directory where the DLLs that implement the API are located.

When the editran system to which requests are made is 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;\<editran-server-ip>

## Programming example

### C, C++ environment

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

* *egreq.c*: source file that shows how to use the API to generate a utility that launches emissions/receptions through editran.
* *example.sln, example.vcproj*: Microsoft Visual Studio 2008 project files used to build the sample program. To do this, open the example.snl file, select in *"Build > Configuration Manager"* as the active configuration ***"Release"***. To generate the application, in 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 the applications that use the API are built with a later version of the compiler, when running the application the following system error occurs:

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

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

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

![sample property pages](https://780925830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiQfLim2uDaLOZRkgWkOk%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 = "Presentacion01"

  lWait = 1

  lVerbose =1

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

  'I replace the error code with text through 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 · Editran/API components

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 most up-to-date 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 information about exports 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/example: files with the source code and the project needed to generate the [sample program](#ejemplo-de-programación).


---

# 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.3-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.
