> For the complete documentation index, see [llms.txt](https://support.marscat.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.marscat.io/development-guide/frontend-development/api-interface/environment-integration.md).

# Environment Integration

## Environment Requirements and Technology Stack

* Frontend Frameworks: React, Vue.js, Native HTML/JavaScript
* Development Requirements: Support for ES6+ syntax and modular development

{% hint style="warning" %}
Important Reminder: The Relayx-api library must run in the RelayX container environment. Please ensure that the deployment environment meets this requirement.
{% endhint %}

## Integration Methods

### Install Dependencies

{% code title="Install" %}

```bash
npm install relayx-api
```

{% endcode %}

### Import Library Files

{% code title="ES Module import" %}

```javascript
import { RelayXClient } from "relayx-api";
```

{% endcode %}

### Native JavaScript Project Integration

{% stepper %}
{% step %}

### Include Script Files — UMD build

Download the UMD build file:

<https://github.com/RelayX-Protocol/RelayX-API/blob/main/dist/relayx-api.umd.js>
{% endstep %}

{% step %}

### Include script in HTML

```html
<script src="path/to/relayx-api.umd.js"></script>
```

{% endstep %}
{% endstepper %}

## API Usage Instructions

### Create Instance

{% code title="Create client instance" %}

```javascript
const relayx = new RelayXClient({timeout:30000});
```

{% endcode %}

Parameter description:

* Pass in a configuration object containing optional parameters
* `timeout`: API call timeout in milliseconds, default 30000 milliseconds

### API Method Calls

{% code title="Example API call" %}

```javascript
let result = await relayx.{cmd}(payload, sign);
```

{% endcode %}

Parameter description:

* `cmd`: The specific API interface method name
* `payload`: The parameter object for the interface call
* `sign`: API authentication signature object (optional parameter)

Return value: All API methods return Promise objects. It is recommended to use async/await syntax to handle asynchronous calls.
