---
tags: Rapi Document English
---
# Rapi API Document (Python)
## Requirment
1. Selenium Server (Grid) (Version recommend >= 4.8)
2. [Rapi-runner](https://github.com/RapiTest/rapi-runner/releases)
3. Install Rapi API
```bash
$ pip install rapi-api
```
## Rapi Config Document
* Before using the Rapi API, you need to know our Rapi runner config file schema. You can learn more about it [here](https://hackmd.io/@Rapi/rapi-runner-config-file).
## Quick Start
```python
import rapi_api
from rapi_api import ConfigBuilder, Rapi
config = ConfigBuilder() \
.setTestSuites(["test1.json"]) \
.addBrowser("http://url.to.selenium.server", {
"browserName": "firefox",
}).build()
rapi = Rapi(
"path/to/rapi/runner", config)
report = rapi.run()
print(report.json)
```
---
# API
## Rapi
### `createRapi(runnerPath, config)`
#### Description
Create a rapi object by giving the executable rapi-runner path and config
#### Parameters
* runnerPath: The executable rapi-runner path
* config: Config create by ConfigBuilder or config file.
#### Example
```python
config = createConfig("path/to/config.json");
rapi = createRapi(
"path/to/rapi/runner",
config
);
```
### `run()`
#### Description
The function will run the test depend on the config you set, after finish the test it will pass the report back.
#### Example
```python
config = createConfig("path/to/config.json");
rapi = createRapi(
"path/to/rapi/runner",
config
);
report = rapi.run();
```
---
## Config
### `createConfig(filePath)`
#### Description
It will create a Config object base on the input file
#### Example
```python
// generate the config base on the config file
config1 = createConfigFromFile("/path/to/config.json")
```
---
## ConfigBuilder
The config format is define in [Rapi Config File Format](https://hackmd.io/@sideex/book/%2F%40sideex%2Frunner#Appendix-A---SideeX-Runner-Config-File-Format)
### `setPlay(options)`
#### Description
Set Config object's play config
#### Example
```python
config.setPlay(noLog=true)
```
### `setTestSuites(testSuites: list)`
#### Example
```python
config.setTestSuites(["path/to/test1.json","path/to/test2.json"]);
```
### `setReport(snapshot=None, snapshotQuality=None, type: SnapshotStatus = None)`
#### Example
```python
config.setReport(snapshotQuality=100)
```
### `setWebdriveri18n(i18n: dict)`
#### Example
```python
config.setWebdriveri18n({"ja": "./ja.json"})
```
### `setWebdriverConfig(webdriverConfig: list)`
#### Example
```python
config.setWebdriverConfig([{
"serverUrl": "http://localhost:4444",
"type": "selenium",
"browsers": [Browser.CHROME],
}])
```
### `setVariables(variables: list)`
#### Example
```python
config.setVariables(["path/to/variables1.json","path/to/variables2.json"]);
```
### `setDataDriven(dataDriven: list)`
#### Example
```python
config.setDataDriven(["path/to/dataDriven1.json","path/to/dataDriven2.json"]);
```
## Report Format
```json=
{
version: {
"sideex": [
3,
7,
3
],
"format": [
1,
0,
1
]
},
"reports":[
{
title: "20221006 12-46-49",
sessionId: "",
type: "chrome",
browser: "chrome 103.0.5060.134",
platform: "linux",
deviceName: "unknown",
lang: null,
inputFile: "/home/fourcolor/Documents/sideex/sideex-2021/modules/main/dist/test-jobs/214e8cd6-94db-4b32-993a-8cf9af0aa04f/inputs/suites/test1.json",
startTime: "20221006 12:46:49",
endTime: "20221006 12:47:02",
failureCaseNum: 0,
failureSuiteNum: 0,
successCaseNum: 1,
successSuiteNum: 1,
logs: [
{
type: "info",
message: "Playing test suite Untitled Test Suite 2"
},
],
status: "completed",
suites: [
{
title: "Untitled Test Suite 2",
idText: "suite-20",
status: "success",
cases: [
0
]
}
],
cases: [
{
title: "Untitled Test Case 2",
idText: "case-20",
suiteIdText": "suite-20",
status: "success",
localVars: [],
globalVars: [],
records: [
{
"name": "open",
"target": "https://sideex.io/",
"value": "",
"status": "success",
"time": 4175,
"valData": []
},
{
"name": "setViewportSize",
"target": "",
"value": "1848,948",
"status": "warn",
"time": 744,
"valData": []
},
...
]
}
],
snapshot: {
"image-162": {
//base64 image
}
}
},
{
...
}
]
}
```