# HTTP

## Base URL

The structure of the base URL will be:

http://`ip-address-of-host-machine`:4001/api/`project-id`/

For all requests to H2R Graphics, use the following base url, as seen in the Launcher window.



**For example...**

If the Rundown URL is `http://192.168.8.153:4001/rundown/ABCD/`

The base URL is `http://192.168.8.153:4001/api/ABCD/`

## Companion

Learn how to take full advantage of this API here:

{% content-ref url="companion" %}
[companion](companion)
{% endcontent-ref %}

## URIs

Most HTTP methods below will rely on a URI and a JSON object.

Keep in mind that the fastest way to to this information is within the **Rundown**, by right-clicking on any graphic that you want to show/hide/update.

![Right-clicking on a graphic](https://487176000-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Mgpg8bODu8UEZd66d9q%2F-MhSRKXj1hworbod-ds2%2F-MhSSJM8px1pM-MHt_aP%2FScreenshot%202021-08-19%20at%2010.08.55.png?alt=media\&token=00bdbd42-96ba-4345-81da-128a6366fd48)

## Run

<mark style="color:green;">`POST`</mark> `http://base_url/run`

{% tabs %}
{% tab title="200 " %}
```
```
{% endtab %}
{% endtabs %}

## Clear all graphics

<mark style="color:green;">`POST`</mark> `http://base_url/clear`

{% tabs %}
{% tab title="200 " %}
```
```
{% endtab %}
{% endtabs %}

## Show a graphic

<mark style="color:green;">`POST`</mark> `http://base_url/graphic/<graphic-id>/show`

**Pro tip:** Right-click any graphic on your rundown to `Copy "Show" URI`.

{% tabs %}
{% tab title="200 " %}
```
```
{% endtab %}
{% endtabs %}

## Hide a graphic

<mark style="color:green;">`POST`</mark> `http://base_url/graphic/<graphic-id>/hide`

**Pro tip:** Right-click any graphic on your rundown to `Copy "Hide" URI`.

{% tabs %}
{% tab title="200 " %}
```
```
{% endtab %}
{% endtabs %}

## Update contents of a graphic

<mark style="color:green;">`POST`</mark> `http://base_url/graphic/<graphic-id>/update`

**Pro tip:** Right-click any graphic on your rundown to `Copy "Update" URL` and to `Copy body JSON`.

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
| body | object |             |

{% tabs %}
{% tab title="200 " %}
```
```
{% endtab %}
{% endtabs %}

## Update score graphic

<mark style="color:green;">`POST`</mark> `http://base_url/graphic/<graphic-id>/updateScore/<team>/<level>/<type>/<amount>`

**team** is the number of the team, likely `1` or `2`.\
**level** is the score to update. Likely `1`, `2`, `3` or `4`.\
**type** is a string depending on how the score should change. Either `set`, `up` or `down`.\
**amount** is the number to set, increment or decrement to score by.\
\
**Example**: `graphic/1234/updateScore/1/1/up/10`\
This would affect team 1, level 1, and add 10 points to the score.

{% tabs %}
{% tab title="200 " %}
```
```
{% endtab %}
{% endtabs %}

### Text variables

## Update Variable Text

<mark style="color:green;">`POST`</mark> `http://base_url/updateVariableText/<variable-text-id>`

#### Request Body

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| text<mark style="color:red;">\*</mark> | String |             |

![Example companion button for updating a Text variable](https://487176000-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mgpg8bODu8UEZd66d9q%2Fuploads%2F8a9ImslYOk97nI8qnacq%2Fupdate-variable-text.jpg?alt=media\&token=cbd832d5-0cab-41dc-9501-b4465c4463e5)

### Variable list

## Select a row on a variable list

<mark style="color:green;">`POST`</mark> `http://base_url/updateVariableList/1/selectRow/next`

Replace `next` with `previous` or `<number>` to select a specific row.

### Outputs

## Open an output with HTTP

<mark style="color:green;">`POST`</mark> `http://base_url/output/<output_number>/open`

#### Path Parameters

| Name                                             | Type   | Description  |
| ------------------------------------------------ | ------ | ------------ |
| output\_number<mark style="color:red;">\*</mark> | String | 1, 2, 3 or 4 |

### Speaker Timer

## Run/resume a Speaker Timer

<mark style="color:green;">`POST`</mark> `http://base_url/graphic/<graphic_id>/timer/run`

## Pause a Speaker Timer

<mark style="color:green;">`POST`</mark> `http://base_url/graphic/<graphic_id>/timer/pause`

## Reset a Speaker Timer to it's original duration

<mark style="color:green;">`POST`</mark> `http://base_url/graphic/<graphic_id>/timer/reset`

## Add/remove time from a running Speaker Timer

<mark style="color:green;">`POST`</mark> `http://base_url/graphic/<graphic_id>/timer/jump/<amount_in_seconds>`

**When paused** the time will be added/removed from the duration.

**When playing** the time will be added/removed from the active time left.

#### Path Parameters

| Name                                                     | Type   | Description                                                                                            |
| -------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------ |
| \<amount\_in\_seconds><mark style="color:red;">\*</mark> | Number | <p><strong>10</strong> would add 10 seconds.</p><p><strong>-10</strong> would subtract 10 seconds.</p> |

## Set the duration of the Speaker Timer and reset it.&#x20;

<mark style="color:green;">`POST`</mark> `http://base_url/graphic/<graphic_id>/timer/duration/<amount_in_seconds>`
