# API

## 概要

API は Sora に対して HTTP 経由で実行できます。

## 用語

- object- `JSON Object` です
  - [HTTPie](https://httpie.io/) では `key:='{"spam": "egg"}'` のように指定してください

## API の種類

### API

正式リリースされている API

### 実験的 API

仕様が確定していない API

詳細は [実験的 API](EXPERIMENTAL_API.html) をご確認ください。

### 非推奨 API

期限が来たら廃止される API

詳細は [非推奨 API](DEPRECATED_API.html) をご確認ください。

### 廃止 API

廃止された API

詳細は [廃止 API](OBSOLETE_API.html) をご確認ください。

## x-sora-target ヘッダー

API は [DynamoDB や Route53 などの AWS API が独特な仕様なので紹介](https://gist.github.com/voluntas/811240c5b6a169ae1c6ac401e0197417) を参考にしており、 `x-sora-target` というヘッダーを使って実行します。

- 全ての API は POST を使用します
- すべての API の PATH は `/` です
- リクエストの Body には JSON を使用します
- レスポンスの Body には JSON を使用します

## 設定

### api_port

API のポート番号を変更したい場合は `sora.conf` の [api_port](SORA_CONF.html#4adab7) にて、 API のポート番号を設定してください。

デフォルトでは 3000 番を利用します。

```ini
api_port = 3000
```

### api_loopback_address_only

API へのアクセスをループバックアドレスからのみに制限します。
本番環境では可能な限り有効にしてください。

```ini
api_loopback_address_only = true
```

### api_cors_origin

> **警告**
>
> 本番環境ではこの設定は有効にしないでください。

API をクロスドメインで使用したい場合に設定します。

```ini
api_cors_origin = http://127.0.0.1:5000
```

こうすることで、ブラウザで `http://127.0.0.1:5000` から API を叩くことができるようになります。

## HTTPie

ここでの例では HTTPie という Python のライブラリを使用しています。

[As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.](https://github.com/httpie/httpie)

> **注釈**
>
> 時雨堂は HTTPie 作者のスポンサーです

### インストール

- Ubuntu は `apt install httpie` で入ります
- CentOS は `yum install httpie` で入ります
- macOS は `brew install httpie` または `port install httpie` で入ります

詳細は  をご確認下さい。


## シグナリング API


### DisconnectChannel

**x-sora-target**: Sora_20151104.DisconnectChannel

指定したチャネルの接続をすべて切断します。

**リクエスト JSON**

* - キー
  - 型
* - channel_id
  - string
* - reason (オプション)
  - object

`reason` に値を指定した場合、イベントウェブフック `connection.destroyed` の `disconnect_api_reason` および `reason` に指定した値が入ってきます。

```console
$ http POST 127.0.0.1:3000 \
    x-sora-target:Sora_20151104.DisconnectChannel \
    channel_id=sora \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.4.0
x-sora-target: Sora_20151104.DisconnectChannel

{
    "channel_id": "sora"
}


HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 21
content-type: application/json
date: Wed, 07 Jul 2021 05:44:01 GMT
server: Cowboy

{
    "channel_id": "sora"
}
```


### DisconnectClient

**x-sora-target**: Sora_20151104.DisconnectClient

指定したクライアント ID の接続をすべて切断します。

**リクエスト JSON**

* - キー
  - 型
* - channel_id
  - string
* - client_id
  - string
* - reason (オプション)
  - object

`reason` に値を指定した場合、イベントウェブフック `connection.destroyed` の `disconnect_api_reason` および `reason` に指定した値が入ってきます。

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20151104.DisconnectClient \
    channel_id=sora \
    client_id=E2APPNQ9P97Q32V2ABW546SWW8 \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 65
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.4.0
x-sora-target: Sora_20151104.DisconnectClient

{
    "channel_id": "sora",
    "client_id": "E2APPNQ9P97Q32V2ABW546SWW8"
}


HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 62
content-type: application/json
date: Wed, 07 Jul 2021 05:45:09 GMT
server: Cowboy

{
    "channel_id": "sora",
    "client_id": "E2APPNQ9P97Q32V2ABW546SWW8"
}
```


### DisconnectConnection

**x-sora-target**: Sora_20151104.DisconnectConnection

指定したコネクション ID の接続を切断します。

**リクエスト JSON**

* - キー
  - 型
* - channel_id
  - string
* - connection_id
  - string
* - reason (オプション)
  - object

`reason` に値を指定した場合、イベントウェブフック `connection.destroyed` の `disconnect_api_reason` および `reason` に指定した値が入ってきます。

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20151104.DisconnectConnection \
    channel_id=sora \
    connection_id=T34CDBMRJS1B5BVPF17RTBQA3C \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 69
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.4.0
x-sora-target: Sora_20151104.DisconnectConnection

{
    "channel_id": "sora",
    "connection_id": "T34CDBMRJS1B5BVPF17RTBQA3C"
}


HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 66
content-type: application/json
date: Wed, 07 Jul 2021 05:59:41 GMT
server: Cowboy

{
    "channel_id": "sora",
    "connection_id": "T34CDBMRJS1B5BVPF17RTBQA3C"
}
```


### DisconnectChannelByRole

**x-sora-target**: Sora_20201120.DisconnectChannelByRole

指定したチャネルの指定したロールの接続を切断します。

* - キー
  - 型
* - channel_id
  - string
* - role
  - string (sendrecv | sendonly | recvonly)

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20201120.DisconnectChannelByRole \
    channel_id=sora \
    role=sendrecv \
    -vvv
    POST / HTTP/1.1
    Accept: application/json, */*;q=0.5
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Content-Length: 42
    Content-Type: application/json
    Host: 127.0.0.1:3000
    User-Agent: HTTPie/2.2.0
    x-sora-target: Sora_20201120.DisconnectChannelByRole

    {
        "channel_id": "sora",
        "role": "sendrecv"
    }

    HTTP/1.1 200 OK
    access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
    access-control-allow-methods: POST, OPTIONS
    access-control-allow-origin: http://127.0.0.1:5000
    access-control-max-age: 1000
    content-length: 39
    content-type: application/json
    date: Thu, 03 Dec 2020 06:15:25 GMT
    server: Cowboy

    {
        "channel_id": "sora",
        "role": "sendrecv"
    }
```


### ListConnections

**x-sora-target**: Sora_20201013.ListConnections

すべての接続一覧を取得します。

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20201013.ListConnections \
    -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.2.0
x-sora-target: Sora_20201013.ListConnections



HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 908
content-type: application/json
date: Wed, 25 Nov 2020 09:25:07 GMT
server: Cowboy

[
    {
        "audio": {
            "codec_type": "OPUS"
        },
        "channel_id": "akane",
        "client_id": "DV2Z3MSXC50M78Y11ETN3VZ360",
        "created_time": 1642469139980509,
        "bundle_id": "DV2Z3MSXC50M78Y11ETN3VZ360",
        "connection_id": "DV2Z3MSXC50M78Y11ETN3VZ360",
        "multistream": true,
        "role": "sendrecv",
        "simulcast": false,
        "spotlight": false,
        "video": {
            "bit_rate": 1000,
            "codec_type": "VP9"
        }
    },
    {
        "audio": {
            "codec_type": "OPUS"
        },
        "channel_id": "sora",
        "client_id": "DKF93NH82X3BDB0CVKEH32JMVR",
        "created_time": 1642469139980509,
        "bundle_id": "DKF93NH82X3BDB0CVKEH32JMVR",
        "connection_id": "DKF93NH82X3BDB0CVKEH32JMVR",
        "multistream": true,
        "role": "sendrecv",
        "simulcast": false,
        "spotlight": false,
        "video": {
            "bit_rate": 1000,
            "codec_type": "VP9"
        }
    },
    {
        "audio": {
            "codec_type": "OPUS"
        },
        "channel_id": "sora",
        "client_id": "W6725M370N2W301378Y5SFG01C",
        "created_time": 1642469139980509,
        "bundle_id": "W6725M370N2W301378Y5SFG01C",
        "connection_id": "W6725M370N2W301378Y5SFG01C",
        "multistream": true,
        "role": "sendrecv",
        "simulcast": false,
        "spotlight": false,
        "video": {
            "bit_rate": 1000,
            "codec_type": "VP9"
        }
    }
]
```


### ListChannelConnections

**x-sora-target**: Sora_20201013.ListChannelConnections

指定したチャネルの接続一覧を取得します。

* - キー
  - 型
* - channel_id
  - string

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20201013.ListChannelConnections \
    channel_id=sora \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.2.0
x-sora-target: Sora_20201013.ListChannelConnections

{
    "channel_id": "sora"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 605
content-type: application/json
date: Wed, 25 Nov 2020 09:26:00 GMT
server: Cowboy

[
    {
        "audio": {
            "codec_type": "OPUS"
        },
        "channel_id": "sora",
        "client_id": "DKF93NH82X3BDB0CVKEH32JMVR",
        "created_time": 1642469139980509,
        "bundle_id": "DKF93NH82X3BDB0CVKEH32JMVR",
        "connection_id": "DKF93NH82X3BDB0CVKEH32JMVR",
        "multistream": true,
        "role": "sendrecv",
        "simulcast": false,
        "spotlight": false,
        "video": {
            "bit_rate": 1000,
            "codec_type": "VP9"
        }
    },
    {
        "audio": {
            "codec_type": "OPUS"
        },
        "channel_id": "sora",
        "client_id": "W6725M370N2W301378Y5SFG01C",
        "created_time": 1642469139980509,
        "bundle_id": "W6725M370N2W301378Y5SFG01C",
        "connection_id": "W6725M370N2W301378Y5SFG01C",
        "multistream": true,
        "role": "sendrecv",
        "simulcast": false,
        "spotlight": false,
        "video": {
            "bit_rate": 1000,
            "codec_type": "VP9"
        }
    }
]
```


## サイマルキャスト API


### RequestRtpStream

**x-sora-target**: Sora_20201005.RequestRtpStream

指定した視聴者の受信する RTP ストリームの rid をリクエストします。

* - キー
  - 型
* - channel_id
  - string
* - recv_connection_id
  - string
* - send_connection_id (オプション)
  - string
* - rid
  - string (r0 | r1 | r2)

r1 までしか配信されていない場合に、r2 をリクエストした場合は r1 を受信し始めます。


```
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20201005.RequestRtpStream \
    channel_id=sora \
    recv_connection_id=4EVK3MN5Z17GB62RE5TGD045ZM \
    send_connection_id=EKNQ103WRD4ZZ74B6TKRM9YK78 \
    rid=r1 \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 139
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.2.0
x-sora-target: Sora_20201005.RequestRtpStream

{
    "channel_id": "sora",
    "recv_connection_id": "4EVK3MN5Z17GB62RE5TGD045ZM",
    "rid": "r1",
    "send_connection_id": "EKNQ103WRD4ZZ74B6TKRM9YK78"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 132
content-type: application/json
date: Wed, 25 Nov 2020 09:31:11 GMT
server: Cowboy

{
    "channel_id": "sora",
    "recv_connection_id": "4EVK3MN5Z17GB62RE5TGD045ZM",
    "rid": "r1",
    "send_connection_id": "EKNQ103WRD4ZZ74B6TKRM9YK78"
}
```


### ResetRtpStream

**x-sora-target**: Sora_20201005.ResetRtpStream

指定した視聴者の受信する RTP ストリームの rid をリセットします。

* - キー
  - 型
* - channel_id
  - string
* - recv_connection_id
  - string
* - send_connection_id (オプション)
  - string


```
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20201005.ResetRtpStream \
    channel_id=sora \
    recv_connection_id=4EVK3MN5Z17GB62RE5TGD045ZM \
    send_connection_id=EKNQ103WRD4ZZ74B6TKRM9YK78 \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 126
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.2.0
x-sora-target: Sora_20201005.ResetRtpStream

{
    "channel_id": "sora",
    "recv_connection_id": "4EVK3MN5Z17GB62RE5TGD045ZM",
    "send_connection_id": "EKNQ103WRD4ZZ74B6TKRM9YK78"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 121
content-type: application/json
date: Wed, 25 Nov 2020 09:31:57 GMT
server: Cowboy

{
    "channel_id": "sora",
    "recv_connection_id": "4EVK3MN5Z17GB62RE5TGD045ZM",
    "send_connection_id": "EKNQ103WRD4ZZ74B6TKRM9YK78"
}
```


## スポットライト API


### FocusSpotlightFixed

**x-sora-target**: Sora_20200807.FocusSpotlightFixed

指定した Connection ID のクライアントに常にフォーカスが当たるようにします。
これは UnfocusSpotlight API が呼ばれるまで当たり続けます。

* - キー
  - 型
* - channel_id
  - string
* - connection_id
  - string


```
$ http POST 127.0.0.1:3000/ x-sora-target:Sora_20200807.FocusSpotlightFixed \
    channel_id=sora connection_id=7QSNT842FS0J9E6BZDBC2DRYY8 -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 69
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.0.0
x-sora-target: Sora_20200807.FocusSpotlightFixed

{
    "channel_id": "sora",
    "connection_id": "7QSNT842FS0J9E6BZDBC2DRYY8"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 66
content-type: application/json
date: Wed, 09 Sep 2020 08:27:57 GMT
server: Cowboy

{
    "channel_id": "sora",
    "connection_id": "7QSNT842FS0J9E6BZDBC2DRYY8"
}
```


### FocusSpotlight

**x-sora-target**: Sora_20200807.FocusSpotlight

指定した Connection ID のクライアントを強制的にフォーカスが当たった状態にします。

* - キー
  - 型
* - channel_id
  - string
* - connection_id
  - string


```
$ http POST 127.0.0.1:3000/ x-sora-target:Sora_20200807.FocusSpotlight \
    channel_id=sora connection_id=74Z2G1JS7S67DE226T8R1H3YGW -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 69
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.0.0
x-sora-target: Sora_20200807.FocusSpotlight

{
    "channel_id": "sora",
    "connection_id": "74Z2G1JS7S67DE226T8R1H3YGW"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 66
content-type: application/json
date: Wed, 09 Sep 2020 08:33:54 GMT
server: Cowboy

{
    "channel_id": "sora",
    "connection_id": "74Z2G1JS7S67DE226T8R1H3YGW"
}
```


### UnfocusSpotlight

**x-sora-target**: Sora_20200807.UnfocusSpotlight

指定した Connection ID のフォーカスを外します。

この API は FocusSpotlightFixed でフォーカスを当て続けてているのを解除する場合にも利用します。

* - キー
  - 型
* - channel_id
  - string
* - connection_id
  - string


```
$ http POST 127.0.0.1:3000/ x-sora-target:Sora_20200807.UnfocusSpotlight \
    channel_id=sora connection_id=74Z2G1JS7S67DE226T8R1H3YGW -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 69
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.0.0
x-sora-target: Sora_20200807.UnfocusSpotlight

{
    "channel_id": "sora",
    "connection_id": "74Z2G1JS7S67DE226T8R1H3YGW"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 66
content-type: application/json
date: Wed, 09 Sep 2020 08:34:56 GMT
server: Cowboy

{
    "channel_id": "sora",
    "connection_id": "74Z2G1JS7S67DE226T8R1H3YGW"
}
```


### ChangeSpotlightNumber

**x-sora-target**: Sora_20200807.ChangeSpotlightNumber

フォーカスする最大数を変更します。最小は 1 で最大は 8 です

この API でフォーカス最大数を変更した後に、`type:connect` で
`spotlight_number` を指定するクライアントは、 **変更後の値** を指定する必要があります。

* - キー
  - 型
* - channel_id
  - string
* - spotlight_number
  - integer (1 ~ 8)


```
$ http POST 127.0.0.1:3000/ x-sora-target:Sora_20200807.ChangeSpotlightNumber \
    channel_id=sora spotlight_number:=1 -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 45
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.0.0
x-sora-target: Sora_20200807.ChangeSpotlightNumber

{
    "channel_id": "sora",
    "spotlight_number": 1
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 42
content-type: application/json
date: Wed, 09 Sep 2020 08:35:36 GMT
server: Cowboy

{
    "channel_id": "sora",
    "spotlight_number": 1
}
```


### RequestSpotlightRid

**x-sora-target**: Sora_20211215.RequestSpotlightRid

スポットライトのフォーカス時とアンフォーカス時の rid を指定します。
これにより接続時に指定した `spotlight_focurs_rid` と `spotlight_unfocus_rid` の値を変更することができます。

* - キー
  - 型
* - channel_id
  - string
* - recv_connection_id
  - string
* - send_connection_id (オプション)
  - string
* - spotlight_focus_rid
  - string (none | r0 | r1 | r2)
* - spotlight_unfocus_rid
  - string (none | r0 | r1 | r2)


```
$ http POST 127.0.0.1:3000/ x-sora-target:Sora_20211215.RequestSpotlightRid \
    channel_id=sora \
    recv_connection_id=AD0ZWY8W492XV9RQGB40GX5C94 \
    spotlight_focus_rid=none \
    spotlight_unfocus_rid=none \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 138
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.4.0
x-sora-target: Sora_20211215.RequestSpotlightRid

{
    "channel_id": "sora",
    "recv_connection_id": "AD0ZWY8W492XV9RQGB40GX5C94",
    "spotlight_focus_rid": "none",
    "spotlight_unfocus_rid": "none"
}


HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 131
content-type: application/json
date: Tue, 30 Nov 2021 02:20:44 GMT
server: Cowboy

{
    "channel_id": "sora",
    "recv_connection_id": "AD0ZWY8W492XV9RQGB40GX5C94",
    "spotlight_focus_rid": "none",
    "spotlight_unfocus_rid": "none"
}
```


### ResetSpotlightRid

**x-sora-target**: Sora_20211215.ResetSpotlightRid

スポットライトのフォーカス時とアンフォーカス時の rid を接続時に指定した値に戻します。

* - キー
  - 型
* - channel_id
  - string
* - recv_connection_id
  - string
* - send_connection_id (オプション)
  - string


```
$ http POST 127.0.0.1:3000/ x-sora-target:Sora_20211215.ResetSpotlightRid \
    channel_id=sora \
    recv_connection_id=AD0ZWY8W492XV9RQGB40GX5C94 \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 74
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.4.0
x-sora-target: Sora_20211215.ResetSpotlightRid

{
    "channel_id": "sora",
    "recv_connection_id": "AD0ZWY8W492XV9RQGB40GX5C94"
}


HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 71
content-type: application/json
date: Tue, 30 Nov 2021 02:22:17 GMT
server: Cowboy

{
    "channel_id": "sora",
    "recv_connection_id": "AD0ZWY8W492XV9RQGB40GX5C94"
}
```


### BatchRequestSpotlightRid

**x-sora-target**: Sora_20211215.BatchRequestSpotlightRid

スポットライトのフォーカス時とアンフォーカス時の rid を一括で変更します。

* - キー
  - 型
* - channel_id
  - string
* - item_list
  - array

item_list には以下が含まれます。

* - キー
  - 型
* - recv_connection_id
  - string
* - send_connection_id
  - string
* - spotlight_focus_rid
  - string (none | r0 | r1 | r2)
* - spotlight_unfocus_rid
  - string (none | r0 | r1 | r2)


```
$ http POST 127.0.0.1:3000/ x-sora-target:Sora_20211215.BatchRequestSpotlightRid \
    channel_id=sora \
    item_list:='[{"recv_connection_id": "AD0ZWY8W492XV9RQGB40GX5C94", "send_connection_id": "RGEFFZM95S2XN0PC03XNMCRTB0", \
                  "spotlight_focus_rid": "none", "spotlight_unfocus_rid": "none"}, \
                 {"recv_connection_id": "AD0ZWY8W492XV9RQGB40GX5C94", "send_connection_id": "P9AFYE2BQN7JB93Q6GK0VYWGHM", \
                  "spotlight_focus_rid": "none", "spotlight_unfocus_rid": "none"}]' \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 377
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.4.0
x-sora-target: Sora_20211215.BatchRequestSpotlightRid

{
    "channel_id": "sora",
    "item_list": [
        {
            "recv_connection_id": "AD0ZWY8W492XV9RQGB40GX5C94",
            "send_connection_id": "RGEFFZM95S2XN0PC03XNMCRTB0",
            "spotlight_focus_rid": "none",
            "spotlight_unfocus_rid": "none"
        },
        {
            "recv_connection_id": "AD0ZWY8W492XV9RQGB40GX5C94",
            "send_connection_id": "P9AFYE2BQN7JB93Q6GK0VYWGHM",
            "spotlight_focus_rid": "none",
            "spotlight_unfocus_rid": "none"
        }
    ]
}


HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 387
content-type: application/json
date: Tue, 30 Nov 2021 02:29:51 GMT
server: Cowboy

{
    "channel_id": "sora",
    "item_list": [
        {
            "recv_connection_id": "AD0ZWY8W492XV9RQGB40GX5C94",
            "result": "ok",
            "send_connection_id": "RGEFFZM95S2XN0PC03XNMCRTB0",
            "spotlight_focus_rid": "none",
            "spotlight_unfocus_rid": "none"
        },
        {
            "recv_connection_id": "AD0ZWY8W492XV9RQGB40GX5C94",
            "result": "ok",
            "send_connection_id": "P9AFYE2BQN7JB93Q6GK0VYWGHM",
            "spotlight_focus_rid": "none",
            "spotlight_unfocus_rid": "none"
        }
    ]
}
```


## プッシュ API

シグナリングで使用している WebSocket や DataChannel を活用できる API です。
この機能を使うことでアプリケーション側でプッシュの仕組みを用意する必要がなくなります。


### PushChannel

**x-sora-target**: Sora_20160711.PushChannel

指定したチャネル全員にプッシュ通知を送る。

* - キー
  - 型
* - channel_id
  - string
* - data
  - object

data には全員に通知する JSON (object) を指定してください。
クライアントには data に指定した JSON (object) が送られます。

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20160711.PushChannel \
    channel_id=sora \
    data:="{\"spam\": \"egg\"}" \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 47
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20160711.PushChannel

{
    "channel_id": "sora",
    "data": {
        "spam": "egg"
    }
}

HTTP/1.1 200 OK
content-length: 37
content-type: application/json
date: Sun, 24 Jul 2016 06:26:21 GMT
server: Cowboy

{
    "data": {
        "spam": "egg"
    },
    "type": "push"
}
```


### PushClient

**x-sora-target**: Sora_20160711.PushClient

指定したチャネルのクライアントにプッシュ通知を送ります。

* - キー
  - 型
* - channel_id
  - string
* - client_id
  - string
* - data
  - object

複数の接続に同一の `client_id` が指定されていた場合、複数の接続にプッシュ通知が送られます。

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20160711.PushClient \
    channel_id=sora \
    client_id=C0YTCRZM715BKATBXWFPKTYGRM \
    data:="{\"spam\": \"egg\"}" \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 100
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20160711.PushClient

{
    "channel_id": "sora",
    "client_id": "C0YTCRZM715BKATBXWFPKTYGRM",
    "data": {
        "spam": "egg"
    }
}

HTTP/1.1 200 OK
content-length: 37
content-type: application/json
date: Sun, 24 Jul 2016 07:46:31 GMT
server: Cowboy

{
    "data": {
        "spam": "egg"
    },
    "type": "push"
}
```


### PushConnection

**x-sora-target**: Sora_20160711.PushConnection

指定したチャネルの接続にプッシュ通知を送ります。

* - キー
  - 型
* - channel_id
  - string
* - connection_id
  - string
* - data
  - object

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20160711.PushConnection \
    channel_id=sora \
    connection_id=C0YTCRZM715BKATBXWFPKTYGRM \
    data:="{\"spam\": \"egg\"}" \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 100
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20160711.PushConnection

{
    "channel_id": "sora",
    "connection_id": "C0YTCRZM715BKATBXWFPKTYGRM",
    "data": {
        "spam": "egg"
    }
}

HTTP/1.1 200 OK
content-length: 37
content-type: application/json
date: Sun, 24 Jul 2016 07:46:31 GMT
server: Cowboy

{
    "data": {
        "spam": "egg"
    },
    "type": "push"
}
```


### PushChannelByRole

**x-sora-target**: Sora_20201120.PushChannelByRole

指定したチャネルの指定したロールにプッシュ通知を送ります。

* - キー
  - 型
* - channel_id
  - string
* - role
  - string (sendrecv | sendonly | recvonly)
* - data
  - object

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20201120.PushChannelByRole \
    channel_id=sora \
    role=sendrecv \
    data:="{\"spam\": \"egg\"}" \
    -vvv
    POST / HTTP/1.1
    Accept: application/json, */*;q=0.5
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Content-Length: 67
    Content-Type: application/json
    Host: 127.0.0.1:3000
    User-Agent: HTTPie/2.2.0
    x-sora-target: Sora_20201120.PushChannelByRole

    {
        "channel_id": "sora",
        "data": {
            "spam": "egg"
        },
        "role": "sendrecv"
    }

    HTTP/1.1 200 OK
    access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
    access-control-allow-methods: POST, OPTIONS
    access-control-allow-origin: http://127.0.0.1:5000
    access-control-max-age: 1000
    content-length: 37
    content-type: application/json
    date: Thu, 03 Dec 2020 06:16:16 GMT
    server: Cowboy

    {
        "data": {
            "spam": "egg"
        },
        "type": "push"
    }
```


## 録画 API

録画されたファイルは `sora.conf` の `archive_dir` に指定したディレクトリに置かれます。

音声と映像のコーデック指定はシグナリング開始時に指定してください。


### StartRecording

**x-sora-target**: Sora_20161101.StartRecording

指定したチャネルの録画を開始します。

クラスター機能利用時には、クラスター内のどのノードで実行しても開始された録画情報はすべてのノードで共有されます。

* - キー
  - 型
* - channel_id
  - string
* - expire_time
  - integer
* - split_duration (オプション)
  - integer
* - split_only (オプション)
  - boolean
* - metadata (オプション)
  - object

- `expire_time` の範囲は `0` から `86400` までで、秒数を指定してください- expire_time を 0 に指定した場合、録画の期限が無くなります
- `split_only` は `true` か `false` を指定して下さい。指定しない場合は `false` が指定されます
- `split_only` を `true` に指定する場合は `expire_time` は `0` を指定する必要があります
- `split_only` を `true` に指定する場合は `split_duration` を指定する必要があります- `split_duration` は 1 から 86400 までで、秒数を指定して下さい
- `metadata` は JSON オブジェクトを指定してください- この `metadata` は `recording.report` ウェブフックやレポートファイルに含まれるようになります。

#### expire_time が 0

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.StartRecording \
    channel_id=sora \
    expire_time:=0 \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 41
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20161101.StartRecording

{
    "channel_id": "sora",
    "expire_time": 0
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 82
content-type: application/json
date: Wed, 19 Apr 2017 06:35:38 GMT
server: Cowboy

{
    "channel_id": "sora",
    "expire_time": 0,
    "recording_id": "C0YTCRZM715BKATBXWFPKTYGRM"
}
```

#### expire_time が 3600

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.StartRecording \
    channel_id=sora \
    expire_time:=3600 \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 43
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20161101.StartRecording

{
    "channel_id": "sora",
    "expire_time": 3600
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 84
content-type: application/json
date: Wed, 19 Apr 2017 06:37:08 GMT
server: Cowboy

{
    "channel_id": "sora",
    "expire_time": 3600,
    "recording_id": "C0YTCRZM715BKATBXWFPKTYGRM"
}
```

#### split_only が true

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.StartRecording \
    channel_id=sora \
    expire_time:=0 \
    split_duration:=3600 \
    split_only:=true \
    -vvv

POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 84
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.2.0
x-sora-target: Sora_20161101.StartRecording

{
    "channel_id": "sora",
    "expire_time": 0,
    "split_duration": 3600,
    "split_only": true
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 121
content-type: application/json
date: Fri, 04 Dec 2020 03:04:17 GMT
server: Cowboy

{
    "channel_id": "sora",
    "expire_time": 0,
    "recording_id": "MK4J54QBGS4ES0MCSZMF6C9M9M",
    "split_duration": 3600,
    "split_only": true
}
```

#### エラー

- "STARTED-RECORDING"- 指定したチャネル ID で、すでに録画が開始している
  ```console
  $ http POST 127.0.0.1:3000/ \
          x-sora-target:Sora_20161101.StartRecording \
          channel_id=sora \
          expire_time:=3600 \
          -vvv
  POST / HTTP/1.1
  Accept: application/json, */*
  Accept-Encoding: gzip, deflate
  Connection: keep-alive
  Content-Length: 43
  Content-Type: application/json
  Host: 127.0.0.1:3000
  User-Agent: HTTPie/0.9.9
  x-sora-target: Sora_20161101.StartRecording

  {
      "channel_id": "sora",
      "expire_time": 3600
  }

  HTTP/1.1 400 Bad Request
  access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
  access-control-allow-methods: POST, OPTIONS
  access-control-allow-origin: http://127.0.0.1:5000
  access-control-max-age: 1000
  content-length: 34
  content-type: application/json
  date: Wed, 19 Apr 2017 06:44:58 GMT
  server: Cowboy

  {
      "error_type": "STARTED-RECORDING"
  }
  ```
- "NOT-CLUSTER-MAJORITY"- クラスターで過半数以下のグループに所属している


### StopRecording

**x-sora-target**: Sora_20161101.StopRecording

指定したチャネルの録画を停止します。

この API は非同期です。200 が返ってきた場合でも録画ファイルや録画メタデータファイルが生成されていることを保証しません。
イベントウェブフックの [archive.available](EVENT_WEBHOOK.html#de9132) または [recording.report](EVENT_WEBHOOK.html#920a02) の通知を利用してください。

クラスター機能利用時には、クラスター内のどのノードで実行しても録画を停止します。
例えば、StartRecodirng API を実行したノードと StopRecording を実行するノードが異なっていても動作します。

* - キー
  - 型
* - channel_id
  - string

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.StopRecording \
    channel_id=sora \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20161101.StopRecording

{
    "channel_id": "sora"
}

HTTP/1.1 200 OK
content-length: 21
content-type: application/json
date: Fri, 11 Nov 2016 14:29:14 GMT
server: Cowboy

{
    "channel_id": "sora"
}
```

#### エラー

- NOT-STARTED-RECORDING- 指定したチャネルの録画が開始されていない
- "NOT-CLUSTER-MAJORITY"- クラスターで過半数以下のグループに所属している


### GetStartedRecording

**x-sora-target**: Sora_20161101.GetStartedRecording

録画が有効かどうかを確認します。

クラスター機能利用時には、クラスター内のどのノードで実行することができます。
例えば、StartRecodirng API を実行したノードと GetStartedRecording を実行するノードが異なっていても動作します。

* - キー
  - 型
* - channel_id
  - string

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.GetStartedRecording \
    channel_id=sora \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20161101.GetStartedRecording

{
    "channel_id": "sora"
}

HTTP/1.1 200 OK
content-length: 88
content-type: application/json
date: Sat, 19 Nov 2016 13:03:24 GMT
server: Cowboy

{
    "channel_id": "sora",
    "expire_time": 3600,
    "expired_at": 1479563964,
    "start_time": 1479560364
}
```

#### エラー

- NOT-STARTED-RECORDING- 指定したチャネルの録画が開始されていない
  ```console
  $ http POST 127.0.0.1:3000/ \
      x-sora-target:Sora_20161101.GetStartedRecording \
      channel_id=sora \
      -vvv
  POST / HTTP/1.1
  Accept: application/json
  Accept-Encoding: gzip, deflate
  Connection: keep-alive
  Content-Length: 22
  Content-Type: application/json
  Host: 127.0.0.1:3000
  User-Agent: HTTPie/0.9.4
  x-sora-target: Sora_20161101.GetStartedRecording

  {
      "channel_id": "sora"
  }

  HTTP/1.1 400 Bad Request
  content-length: 38
  content-type: application/json
  date: Sat, 19 Nov 2016 13:03:53 GMT
  server: Cowboy

  {
      "error_type": "NOT-STARTED-RECORDING"
  }
  ```
- "NOT-CLUSTER-MAJORITY"- クラスターで過半数以下のグループに所属している


### ListStartedRecording

**x-sora-target**: Sora_20161101.ListStartedRecording

録画が行われているチャネル一覧を取得します。

クラスター機能利用時には、クラスター内のどのノードで実行しても、クラスター内で有効な録画の一覧を取得できます。

```console
$ http POST 127.0.0.1:3000/ \
    "x-sora-target:Sora_20161101.ListStartedRecording" \
    -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.4.0
x-sora-target: Sora_20161101.ListStartedRecording



HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 307
content-type: application/json
date: Tue, 30 Nov 2021 01:13:10 GMT
server: Cowboy

[
    {
        "channel_id": "sora",
        "created_at": 1638234656,
        "expire_time": 3600,
        "expired_at": 1638238256,
        "recording_id": "WWZ61PT4GS03F80F39MCPVSEQR",
        "split_only": false
    },
    {
        "channel_id": "zakuro",
        "created_at": 1638234654,
        "expire_time": 3600,
        "expired_at": 1638238254,
        "recording_id": "Z60BJP5YDN4PD0D7RGM4TFEE48",
        "split_only": false
    }
]
```

#### エラー

- "NOT-CLUSTER-MAJORITY"- クラスターで過半数以下のグループに所属している


### ListArchiving

**x-sora-target**: Sora_20161101.ListArchiving

現在録画中の状態を取得します。

> **注釈**
>
> クラスター機能利用時であっても、API を実行したノードで録画中の状態のみを取得します。
> クラスター内で録画中のすべてを取得したい場合はすべてのノードに ListArchiving API を実行する必要があります。

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.ListArchiving \
    -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/1.0.2
x-sora-target: Sora_20161101.ListArchiving



HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 218
content-type: application/json
date: Mon, 15 Apr 2019 08:39:20 GMT
server: Cowboy

[
    {
        "audio": {
            "codec_type": "OPUS"
        },
        "channel_id": "sora",
        "client_id": "C0YTCRZM715BKATBXWFPKTYGRM",
        "bundle_id": "C0YTCRZM715BKATBXWFPKTYGRM",
        "connection_id": "C0YTCRZM715BKATBXWFPKTYGRM",
        "seconds": 146,
        "video": {
            "bit_rate": 1000,
            "codec_type": "VP9"
        }
    }
]
```

- seconds は録画を開始してからの経過時間(秒)です
- video が設定されていない場合は `"video": false` という値が入ってきます
- audio が設定されていない場合は `"audio": false` という値が入ってきます


## 統計 API

### 統計項目一覧

**説明が書いていないものは項目名そのままの内容になります**

- timestamp- API を取得した時点の UTC 時間 RFC3339 形式
- channel_id
- client_id
- bundle_id
- connection_id
- simulcast- r0- rtp- total_decrypt_skipped_srtp
      - tocal_decrypt_skipped_audio_srtp
      - tocal_decrypt_skipped_video_srtp
      - total_received_rtp
      - total_received_rtp_byte_size
      - total_received_rtp_padding
      - total_received_rtp_padding_size
      - total_received_rtp_red
      - total_received_rtp_red_rtx
      - total_received_rtp_red_ulpfec
      - total_received_rtp_rtx
    - rtp_hdr_ext- total_received_rtp_hdr_ext_abs_send_time
      - total_received_rtp_hdr_ext_audio_level
      - total_received_rtp_hdr_ext_av1_rtp_sepc
      - total_received_rtp_hdr_ext_color_space
      - total_received_rtp_hdr_ext_inband_cn
      - total_received_rtp_hdr_ext_playout_delay
      - total_received_rtp_hdr_ext_sdes_mid
      - total_received_rtp_hdr_ext_sdes_repaired_rtp_stream_id
      - total_received_rtp_hdr_ext_sdes_rtp_stream_id
      - total_received_rtp_hdr_ext_toffset
      - total_received_rtp_hdr_ext_transport_wide_cc
      - total_received_rtp_hdr_ext_unknown
      - total_received_rtp_hdr_ext_video_content_type
      - total_received_rtp_hdr_ext_video_orientation
      - total_received_rtp_hdr_ext_video_timeing
  - r1- r0 と同様
  - r2- r0 と同様
- spotlight- total_spotlight_focus_failed
  - total_spotlight_unfocus_audio_no_room
  - total_spotlight_unfocus_audio_out_packet
  - total_spotlight_unfocus_audio_publish
- dtls- total_received_dtls- 受信した DTLS パケットの総数
  - total_sent_dtls- 送信した DTLS パケットの総数
- network_status- unstable_level- API を取得した時点の不安定レベル
- signaling- total_received_signaling_pong
  - total_sent_signaling_ping
- packet_loss_simulator- total_dropped_received_rtp- 受信したがパケロスシミュレータが落とした RTP パケットの総数
  - total_dropped_sent_rtp- 送信したがパケロスシミュレータが落とした RTP パケットの総数
  - total_dropped_received_data_channel- 受信したがパケロスシミュレータが落とした DataChannel パケットの総数
  - total_dropped_sent_data_channel- 送信したがパケロスシミュレータが落とした DataChannel パケットの総数
- rtp- total_generic_nack_cache_hit- 再送要求に答えた総数
  - total_generic_nack_cache_miss- 再送要求に答えられなかった総数
  - total_pli_trigger- 再送要求が限界に来たため全画面要求(PLI) を送信した総数
  - total_received
  - total_received_byte_size
  - total_received_rtp
  - total_received_rtp_byte_size
  - total_received_rtp_red
  - total_received_rtp_red_rtx
  - total_received_rtp_red_ulpfec
  - total_received_rtp_rtx
  - total_sent
  - total_sent_byte_size
  - total_sent_rtp
  - total_sent_rtp_byte_size
  - total_decrypt_skipped_srtp- 復号をスキップした SRTP 総数
  - total_decrypt_skipped_video_srtp- 復号をスキップした映像 SRTP 総数
  - total_decrypt_skipped_audio_srtp- 復号をスキップした音声 SRTP 総数
  - total_received_srtp_invalid
  - total_received_rtp_padding
  - total_received_rtp_padding_size
  - total_received_intra_frame- I フレームを受信した総数
  - total_ulpfec_recovered- ULPFEC を利用して損失パケットを回復した総数
- rtp_hdr_ext- total_received_rtp_hdr_ext_abs_send_time
  - total_received_rtp_hdr_ext_audio_level
  - total_received_rtp_hdr_ext_av1_rtp_sepc
  - total_received_rtp_hdr_ext_color_space
  - total_received_rtp_hdr_ext_inband_cn
  - total_received_rtp_hdr_ext_playout_delay
  - total_received_rtp_hdr_ext_sdes_mid
  - total_received_rtp_hdr_ext_sdes_repaired_rtp_stream_id
  - total_received_rtp_hdr_ext_sdes_rtp_stream_id
  - total_received_rtp_hdr_ext_toffset
  - total_received_rtp_hdr_ext_transport_wide_cc
  - total_received_rtp_hdr_ext_unknown
  - total_received_rtp_hdr_ext_video_content_type
  - total_received_rtp_hdr_ext_video_orientation
  - total_received_rtp_hdr_ext_video_timeing
  - total_sent_rtp_hdr_ext_abs_send_time
  - total_sent_rtp_hdr_ext_audio_level
  - total_sent_rtp_hdr_ext_av1_rtp_sepc
  - total_sent_rtp_hdr_ext_color_space
  - total_sent_rtp_hdr_ext_inband_cn
  - total_sent_rtp_hdr_ext_playout_delay
  - total_sent_rtp_hdr_ext_sdes_mid
  - total_sent_rtp_hdr_ext_sdes_repaired_rtp_stream_id
  - total_sent_rtp_hdr_ext_sdes_rtp_stream_id
  - total_sent_rtp_hdr_ext_toffset
  - total_sent_rtp_hdr_ext_transport_wide_cc
  - total_sent_rtp_hdr_ext_unknown
  - total_sent_rtp_hdr_ext_video_content_type
  - total_sent_rtp_hdr_ext_video_orientation
  - total_sent_rtp_hdr_ext_video_timeing
- rtcp- total_received_rtcp
  - total_received_rtcp_bye
  - total_received_rtcp_byte_size
  - total_received_rtcp_psfb_afb
  - total_received_rtcp_psfb_fir
  - total_received_rtcp_psfb_pli
  - total_received_rtcp_rr
  - total_received_rtcp_rtpfb_generic_nack
  - total_received_rtcp_rtpfb_tmmbn
  - total_received_rtcp_rtpfb_tmmbr
  - total_received_rtcp_rtpfb_transport_wide
  - total_received_rtcp_sdes
  - total_received_rtcp_sr
  - total_received_rtcp_unknown
  - total_received_rtcp_xr
  - total_sent_rtcp
  - total_sent_rtcp_bye
  - total_sent_rtcp_byte_size
  - total_sent_rtcp_psfb_afb
  - total_sent_rtcp_psfb_fir
  - total_sent_rtcp_psfb_pli
  - total_sent_rtcp_rr
  - total_sent_rtcp_rtpfb_generic_nack
  - total_sent_rtcp_rtpfb_tmmbn
  - total_sent_rtcp_rtpfb_tmmbr
  - total_sent_rtcp_rtpfb_transport_wide
  - total_sent_rtcp_sdes
  - total_sent_rtcp_sr
  - total_sent_rtcp_unknown
  - total_sent_rtcp_xr
- turn- total_received_turn_unknown_stun
  - total_received_turn_invalid_stun
  - total_received_unknown_channel_number
  - total_received_expired_channel_number
  - total_received_allocate_request
  - total_received_binding_request
  - total_received_channel_bind_request
  - total_received_channel_data
  - total_received_create_permission_request
  - total_received_refresh_request
  - total_received_send_indication
  - total_received_turn_binding_error
  - total_received_turn_binding_request
  - total_received_turn_binding_success
  - total_received_turn_unknown
  - total_sent_allocate_error
  - total_sent_allocate_success
  - total_sent_binding_error
  - total_sent_binding_success
  - total_sent_channel_bind_error
  - total_sent_channel_bind_success
  - total_sent_channel_data
  - total_sent_create_permission_error
  - total_sent_create_permission_success
  - total_sent_data_indication
  - total_sent_refresh_error
  - total_sent_refresh_success
  - total_sent_turn_binding_error
  - total_sent_turn_binding_request
  - total_sent_turn_binding_success
  - total_sent_turn_unknown
- data_channel- signaling- ordered
    - max_packet_life_time
    - max_retransmits
    - protocol
    - direction
    - compress
    - total_data_channel_abandon_message
    - total_data_channel_retransmit_message
    - total_data_channel_open_message
    - total_data_channel_ack_message
    - total_received_data_channel_message
    - total_received_data_channel_message_byte_size
    - total_sent_data_channel_message
    - total_sent_data_channel_message_byte_size
  - notify- signaling と同様
  - push- signaling と同様
  - stats- signaling と同様
  - e2ee- signaling と同様
  - # から始まるメッセージング用ラベル- signaling と同様
- sctp- total_received_invalid_sctp
  - total_received_sctp
  - total_received_sctp_byte_size
  - total_received_sctp_chunk_abort
  - total_received_sctp_chunk_asconf
  - total_received_sctp_chunk_asconf_ack
  - total_received_sctp_chunk_auth
  - total_received_sctp_chunk_cookie_ack
  - total_received_sctp_chunk_cookie_echo
  - total_received_sctp_chunk_cwr
  - total_received_sctp_chunk_data
  - total_received_sctp_chunk_ecne
  - total_received_sctp_chunk_error
  - total_received_sctp_chunk_forward_tsn
  - total_received_sctp_chunk_heartbeat
  - total_received_sctp_chunk_heartbeat_ack
  - total_received_sctp_chunk_i_data
  - total_received_sctp_chunk_i_forward_tsn
  - total_received_sctp_chunk_init
  - total_received_sctp_chunk_init_ack
  - total_received_sctp_chunk_pad
  - total_received_sctp_chunk_reconfig
  - total_received_sctp_chunk_sack
  - total_received_sctp_chunk_shutdown
  - total_received_sctp_chunk_shutdown_ack
  - total_received_sctp_chunk_shutdown_complete
  - total_received_sctp_chunk_unknown
  - total_received_unknown_sctp
  - total_sent_sctp
  - total_sent_sctp_byte_size
  - total_sent_sctp_chunk_abort
  - total_sent_sctp_chunk_asconf
  - total_sent_sctp_chunk_asconf_ack
  - total_sent_sctp_chunk_auth
  - total_sent_sctp_chunk_cookie_ack
  - total_sent_sctp_chunk_cookie_echo
  - total_sent_sctp_chunk_cwr
  - total_sent_sctp_chunk_data
  - total_sent_sctp_chunk_ecne
  - total_sent_sctp_chunk_error
  - total_sent_sctp_chunk_forward_tsn
  - total_sent_sctp_chunk_heartbeat
  - total_sent_sctp_chunk_heartbeat_ack
  - total_sent_sctp_chunk_i_data
  - total_sent_sctp_chunk_i_forward_tsn
  - total_sent_sctp_chunk_init
  - total_sent_sctp_chunk_init_ack
  - total_sent_sctp_chunk_pad
  - total_sent_sctp_chunk_reconfig
  - total_sent_sctp_chunk_sack
  - total_sent_sctp_chunk_shutdown
  - total_sent_sctp_chunk_shutdown_ack
  - total_sent_sctp_chunk_shutdown_complete
  - total_sent_sctp_chunk_unknown


### GetStatsConnection

**x-sora-target**: Sora_20170529.GetStatsConnection

指定した接続の統計情報を取得します。

* - キー
  - 型
* - channel_id
  - string
* - connection_id
  - string

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20170529.GetStatsConnection \
    channel_id=sora \
    connection_id=KDBN2YD1A919V5BA2JX6TG2RP8 -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 69
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.4.0
x-sora-target: Sora_20170529.GetStatsConnection

{
    "channel_id": "sora",
    "connection_id": "KP8VZZ321D0A90RSVJC4RMGJ08"
}


HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 10954
content-type: application/json
date: Tue, 30 Nov 2021 01:59:51 GMT
server: Cowboy

{
    "channel_id": "sora",
    "client_id": "KP8VZZ321D0A90RSVJC4RMGJ08",
    "bundle_id": "KP8VZZ321D0A90RSVJC4RMGJ08",
    "connection_id": "KP8VZZ321D0A90RSVJC4RMGJ08",
    "data_channel": {
        "#test": {
            "compress": false,
            "direction": "sendrecv",
            "ordered": true,
            "protocol": "",
            "total_received_data_channel_message": 1,
            "total_received_data_channel_message_byte_size": 1,
            "total_sent_data_channel_message": 1,
            "total_sent_data_channel_message_byte_size": 17
        },
        "e2ee": {
            "compress": false,
            "direction": "sendrecv",
            "ordered": true,
            "protocol": "",
            "total_received_data_channel_message": 1,
            "total_received_data_channel_message_byte_size": 1,
            "total_sent_data_channel_message": 1,
            "total_sent_data_channel_message_byte_size": 16
        },
        "notify": {
            "compress": true,
            "direction": "recvonly",
            "ordered": true,
            "protocol": "",
            "total_received_data_channel_message": 1,
            "total_received_data_channel_message_byte_size": 1,
            "total_sent_data_channel_message": 8,
            "total_sent_data_channel_message_byte_size": 627
        },
        "push": {
            "compress": true,
            "direction": "recvonly",
            "ordered": true,
            "protocol": "",
            "total_received_data_channel_message": 1,
            "total_received_data_channel_message_byte_size": 1,
            "total_sent_data_channel_message": 1,
            "total_sent_data_channel_message_byte_size": 16
        },
        "signaling": {
            "compress": true,
            "direction": "sendrecv",
            "ordered": true,
            "protocol": "",
            "total_received_data_channel_message": 1,
            "total_received_data_channel_message_byte_size": 1,
            "total_sent_data_channel_message": 1,
            "total_sent_data_channel_message_byte_size": 21
        },
        "stats": {
            "compress": true,
            "direction": "sendrecv",
            "ordered": true,
            "protocol": "",
            "total_received_data_channel_message": 3,
            "total_received_data_channel_message_byte_size": 30078,
            "total_sent_data_channel_message": 3,
            "total_sent_data_channel_message_byte_size": 73
        }
    },
    "dtls": {
        "total_received_dtls": 36,
        "total_sent_dtls": 37
    },
    "network_status": {
        "unstable_level": 0
    },
    "packet_loss_simulator": {
        "total_dropped_received_data_channel": 2,
        "total_dropped_received_rtp": 0,
        "total_dropped_sent_data_channel": 2,
        "total_dropped_sent_rtp": 0
    },
    "rtcp": {
        "total_generic_nack_cache_hit": 4,
        "total_generic_nack_cache_miss": 0,
        "total_pli_trigger": 0,
        "total_received_rtcp": 375,
        "total_received_rtcp_bye": 0,
        "total_received_rtcp_byte_size": 33260,
        "total_received_rtcp_psfb_afb": 278,
        "total_received_rtcp_psfb_fir": 0,
        "total_received_rtcp_psfb_pli": 0,
        "total_received_rtcp_rr": 73,
        "total_received_rtcp_rtpfb_generic_nack": 4,
        "total_received_rtcp_rtpfb_tmmbn": 0,
        "total_received_rtcp_rtpfb_tmmbr": 0,
        "total_received_rtcp_rtpfb_transport_wide": 0,
        "total_received_rtcp_sdes": 298,
        "total_received_rtcp_sr": 298,
        "total_received_rtcp_unknown": 0,
        "total_received_rtcp_xr": 0,
        "total_sent_rtcp": 184,
        "total_sent_rtcp_bye": 0,
        "total_sent_rtcp_byte_size": 14812,
        "total_sent_rtcp_psfb_afb": 79,
        "total_sent_rtcp_psfb_fir": 0,
        "total_sent_rtcp_psfb_pli": 0,
        "total_sent_rtcp_rr": 91,
        "total_sent_rtcp_rtpfb_generic_nack": 0,
        "total_sent_rtcp_rtpfb_tmmbn": 0,
        "total_sent_rtcp_rtpfb_tmmbr": 0,
        "total_sent_rtcp_rtpfb_transport_wide": 0,
        "total_sent_rtcp_sdes": 93,
        "total_sent_rtcp_sr": 93,
        "total_sent_rtcp_unknown": 0,
        "total_sent_rtcp_xr": 0
    },
    "rtp": {
        "total_received": 5706,
        "total_received_byte_size": 1879672,
        "total_received_rtp": 5331,
        "total_received_rtp_byte_size": 1846412,
        "total_received_rtp_padding": 0,
        "total_received_rtp_padding_size": 0,
        "total_received_rtp_red": 0,
        "total_received_rtp_red_rtx": 0,
        "total_received_rtp_red_ulpfec": 0,
        "total_received_rtp_rtx": 79,
        "total_sent": 5548,
        "total_sent_byte_size": 2015913,
        "total_sent_rtp": 5364,
        "total_sent_rtp_byte_size": 2001101
    },
    "rtp_hdr_ext": {
        "total_received_rtp_hdr_ext_abs_send_time": 5331,
        "total_received_rtp_hdr_ext_audio_level": 3187,
        "total_received_rtp_hdr_ext_av1_rtp_sepc": 2144,
        "total_received_rtp_hdr_ext_color_space": 0,
        "total_received_rtp_hdr_ext_inband_cn": 0,
        "total_received_rtp_hdr_ext_playout_delay": 0,
        "total_received_rtp_hdr_ext_sdes_mid": 0,
        "total_received_rtp_hdr_ext_sdes_repaired_rtp_stream_id": 0,
        "total_received_rtp_hdr_ext_sdes_rtp_stream_id": 0,
        "total_received_rtp_hdr_ext_toffset": 0,
        "total_received_rtp_hdr_ext_transport_wide_cc": 0,
        "total_received_rtp_hdr_ext_unknown": 0,
        "total_received_rtp_hdr_ext_video_content_type": 0,
        "total_received_rtp_hdr_ext_video_orientation": 0,
        "total_received_rtp_hdr_ext_video_timeing": 0,
        "total_sent_rtp_hdr_ext_abs_send_time": 0,
        "total_sent_rtp_hdr_ext_audio_level": 3188,
        "total_sent_rtp_hdr_ext_av1_rtp_sepc": 2176,
        "total_sent_rtp_hdr_ext_color_space": 0,
        "total_sent_rtp_hdr_ext_inband_cn": 0,
        "total_sent_rtp_hdr_ext_playout_delay": 0,
        "total_sent_rtp_hdr_ext_sdes_mid": 0,
        "total_sent_rtp_hdr_ext_sdes_repaired_rtp_stream_id": 0,
        "total_sent_rtp_hdr_ext_sdes_rtp_stream_id": 0,
        "total_sent_rtp_hdr_ext_toffset": 0,
        "total_sent_rtp_hdr_ext_transport_wide_cc": 0,
        "total_sent_rtp_hdr_ext_unknown": 0,
        "total_sent_rtp_hdr_ext_video_content_type": 0,
        "total_sent_rtp_hdr_ext_video_orientation": 0,
        "total_sent_rtp_hdr_ext_video_timeing": 0
    },
    "sctp": {
        "total_pruned_sctp_data_chunk": 0,
        "total_received_invalid_sctp": 0,
        "total_received_sctp": 32,
        "total_received_sctp_byte_size": 8244,
        "total_received_sctp_chunk_abort": 0,
        "total_received_sctp_chunk_asconf": 0,
        "total_received_sctp_chunk_asconf_ack": 0,
        "total_received_sctp_chunk_auth": 0,
        "total_received_sctp_chunk_cookie_ack": 0,
        "total_received_sctp_chunk_cookie_echo": 1,
        "total_received_sctp_chunk_cwr": 0,
        "total_received_sctp_chunk_data": 14,
        "total_received_sctp_chunk_ecne": 0,
        "total_received_sctp_chunk_error": 0,
        "total_received_sctp_chunk_forward_tsn": 0,
        "total_received_sctp_chunk_heartbeat": 0,
        "total_received_sctp_chunk_heartbeat_ack": 2,
        "total_received_sctp_chunk_i_data": 0,
        "total_received_sctp_chunk_i_forward_tsn": 0,
        "total_received_sctp_chunk_init": 1,
        "total_received_sctp_chunk_init_ack": 0,
        "total_received_sctp_chunk_pad": 19,
        "total_received_sctp_chunk_reconfig": 0,
        "total_received_sctp_chunk_sack": 15,
        "total_received_sctp_chunk_shutdown": 0,
        "total_received_sctp_chunk_shutdown_ack": 0,
        "total_received_sctp_chunk_shutdown_complete": 0,
        "total_received_sctp_chunk_unknown": 0,
        "total_received_unknown_sctp": 0,
        "total_sent_sctp": 37,
        "total_sent_sctp_byte_size": 2060,
        "total_sent_sctp_chunk_abort": 0,
        "total_sent_sctp_chunk_asconf": 0,
        "total_sent_sctp_chunk_asconf_ack": 0,
        "total_sent_sctp_chunk_auth": 0,
        "total_sent_sctp_chunk_cookie_ack": 1,
        "total_sent_sctp_chunk_cookie_echo": 0,
        "total_sent_sctp_chunk_cwr": 0,
        "total_sent_sctp_chunk_data": 19,
        "total_sent_sctp_chunk_ecne": 0,
        "total_sent_sctp_chunk_error": 0,
        "total_sent_sctp_chunk_forward_tsn": 0,
        "total_sent_sctp_chunk_heartbeat": 2,
        "total_sent_sctp_chunk_heartbeat_ack": 0,
        "total_sent_sctp_chunk_i_data": 0,
        "total_sent_sctp_chunk_i_forward_tsn": 0,
        "total_sent_sctp_chunk_init": 0,
        "total_sent_sctp_chunk_init_ack": 1,
        "total_sent_sctp_chunk_pad": 0,
        "total_sent_sctp_chunk_reconfig": 0,
        "total_sent_sctp_chunk_sack": 14,
        "total_sent_sctp_chunk_shutdown": 0,
        "total_sent_sctp_chunk_shutdown_ack": 0,
        "total_sent_sctp_chunk_shutdown_complete": 0,
        "total_sent_sctp_chunk_unknown": 0
    },
    "signaling": {
        "total_received_signaling_pong": 0,
        "total_sent_signaling_ping": 0
    },
    "simulcast": {
        "r0": {
            "rtp": {
                "total_received_rtp": 0,
                "total_received_rtp_byte_size": 0,
                "total_received_rtp_padding": 0,
                "total_received_rtp_padding_size": 0,
                "total_received_rtp_red": 0,
                "total_received_rtp_red_rtx": 0,
                "total_received_rtp_red_ulpfec": 0,
                "total_received_rtp_rtx": 0
            },
            "rtp_hdr_ext": {
                "total_received_rtp_hdr_ext_abs_send_time": 0,
                "total_received_rtp_hdr_ext_audio_level": 0,
                "total_received_rtp_hdr_ext_av1_rtp_sepc": 0,
                "total_received_rtp_hdr_ext_color_space": 0,
                "total_received_rtp_hdr_ext_inband_cn": 0,
                "total_received_rtp_hdr_ext_playout_delay": 0,
                "total_received_rtp_hdr_ext_sdes_mid": 0,
                "total_received_rtp_hdr_ext_sdes_repaired_rtp_stream_id": 0,
                "total_received_rtp_hdr_ext_sdes_rtp_stream_id": 0,
                "total_received_rtp_hdr_ext_toffset": 0,
                "total_received_rtp_hdr_ext_transport_wide_cc": 0,
                "total_received_rtp_hdr_ext_unknown": 0,
                "total_received_rtp_hdr_ext_video_content_type": 0,
                "total_received_rtp_hdr_ext_video_orientation": 0,
                "total_received_rtp_hdr_ext_video_timeing": 0
            }
        },
        "r1": {
            "rtp": {
                "total_received_rtp": 0,
                "total_received_rtp_byte_size": 0,
                "total_received_rtp_padding": 0,
                "total_received_rtp_padding_size": 0,
                "total_received_rtp_red": 0,
                "total_received_rtp_red_rtx": 0,
                "total_received_rtp_red_ulpfec": 0,
                "total_received_rtp_rtx": 0
            },
            "rtp_hdr_ext": {
                "total_received_rtp_hdr_ext_abs_send_time": 0,
                "total_received_rtp_hdr_ext_audio_level": 0,
                "total_received_rtp_hdr_ext_av1_rtp_sepc": 0,
                "total_received_rtp_hdr_ext_color_space": 0,
                "total_received_rtp_hdr_ext_inband_cn": 0,
                "total_received_rtp_hdr_ext_playout_delay": 0,
                "total_received_rtp_hdr_ext_sdes_mid": 0,
                "total_received_rtp_hdr_ext_sdes_repaired_rtp_stream_id": 0,
                "total_received_rtp_hdr_ext_sdes_rtp_stream_id": 0,
                "total_received_rtp_hdr_ext_toffset": 0,
                "total_received_rtp_hdr_ext_transport_wide_cc": 0,
                "total_received_rtp_hdr_ext_unknown": 0,
                "total_received_rtp_hdr_ext_video_content_type": 0,
                "total_received_rtp_hdr_ext_video_orientation": 0,
                "total_received_rtp_hdr_ext_video_timeing": 0
            }
        },
        "r2": {
            "rtp": {
                "total_received_rtp": 0,
                "total_received_rtp_byte_size": 0,
                "total_received_rtp_padding": 0,
                "total_received_rtp_padding_size": 0,
                "total_received_rtp_red": 0,
                "total_received_rtp_red_rtx": 0,
                "total_received_rtp_red_ulpfec": 0,
                "total_received_rtp_rtx": 0
            },
            "rtp_hdr_ext": {
                "total_received_rtp_hdr_ext_abs_send_time": 0,
                "total_received_rtp_hdr_ext_audio_level": 0,
                "total_received_rtp_hdr_ext_av1_rtp_sepc": 0,
                "total_received_rtp_hdr_ext_color_space": 0,
                "total_received_rtp_hdr_ext_inband_cn": 0,
                "total_received_rtp_hdr_ext_playout_delay": 0,
                "total_received_rtp_hdr_ext_sdes_mid": 0,
                "total_received_rtp_hdr_ext_sdes_repaired_rtp_stream_id": 0,
                "total_received_rtp_hdr_ext_sdes_rtp_stream_id": 0,
                "total_received_rtp_hdr_ext_toffset": 0,
                "total_received_rtp_hdr_ext_transport_wide_cc": 0,
                "total_received_rtp_hdr_ext_unknown": 0,
                "total_received_rtp_hdr_ext_video_content_type": 0,
                "total_received_rtp_hdr_ext_video_orientation": 0,
                "total_received_rtp_hdr_ext_video_timeing": 0
            }
        }
    },
    "spotlight": {
        "total_spotlight_focus_failed": 0,
        "total_spotlight_unfocus_audio_no_room": 0,
        "total_spotlight_unfocus_audio_out_packet": 0,
        "total_spotlight_unfocus_audio_publish": 0
    },
    "timestamp": "2021-11-30T01:59:51.372062Z",
    "turn": {
        "total_received_allocate_request": 7,
        "total_received_binding_request": 0,
        "total_received_channel_bind_request": 1,
        "total_received_channel_data": 5802,
        "total_received_create_permission_request": 1,
        "total_received_expired_channel_number": 0,
        "total_received_refresh_request": 4,
        "total_received_send_indication": 3,
        "total_received_turn_binding_error": 0,
        "total_received_turn_binding_request": 29,
        "total_received_turn_binding_success": 28,
        "total_received_turn_invalid_stun": 0,
        "total_received_turn_unknown": 0,
        "total_received_turn_unknown_stun": 0,
        "total_received_unknown_channel_number": 0,
        "total_sent_allocate_error": 2,
        "total_sent_allocate_success": 2,
        "total_sent_binding_error": 0,
        "total_sent_binding_success": 0,
        "total_sent_channel_bind_error": 0,
        "total_sent_channel_bind_success": 1,
        "total_sent_channel_data": 5644,
        "total_sent_create_permission_error": 0,
        "total_sent_create_permission_success": 1,
        "total_sent_data_indication": 2,
        "total_sent_refresh_error": 0,
        "total_sent_refresh_success": 3,
        "total_sent_turn_binding_error": 0,
        "total_sent_turn_binding_request": 28,
        "total_sent_turn_binding_success": 1,
        "total_sent_turn_unknown": 0
    }
}
```


### GetStatsClient

**x-sora-target**: Sora_20170529.GetStatsClient

指定したクライアントの統計情報を取得します。

* - キー
  - 型
* - channel_id
  - string
* - client_id
  - string

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20170529.GetStatsClient \
    channel_id=sora \
    client_id=82TKXKK1M15C76KTF192WVDSVC \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 65
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.4.0
x-sora-target: Sora_20170529.GetStatsClient

{
    "channel_id": "sora",
    "client_id": "spam"
}


HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 10656
content-type: application/json
date: Tue, 30 Nov 2021 02:02:33 GMT
server: Cowboy

[
    {
        "channel_id": "sora",
        "client_id": "spam",
        "bundle_id": "DDG3V4NZPH04V02NKDMY97993W",
        "connection_id": "DDG3V4NZPH04V02NKDMY97993W",
        ...
    },
    {
        "channel_id": "sora",
        "client_id": "spam",
        "bundle_id": "1RKMMEA10923N96N88S1GEKGYR",
        "connection_id": "1RKMMEA10923N96N88S1GEKGYR",
        ...
    }
]
```


### GetStatsAllConnections

**x-sora-target**: Sora_20171101.GetStatsAllConnections

すべての接続の統計情報を取得します。

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20171101.GetStatsAllConnections -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.4.0
x-sora-target: Sora_20171101.GetStatsAllConnections



HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 32059
content-type: application/json
date: Tue, 30 Nov 2021 02:06:00 GMT
server: Cowboy

[
    {
        "channel_id": "sora",
        "client_id": "spam",
        "bundle_id": "DDG3V4NZPH04V02NKDMY97993W",
        "connection_id": "DDG3V4NZPH04V02NKDMY97993W",
        ...
    },
    {
        "channel_id": "sora",
        "client_id": "spam",
        "bundle_id: "1RKMMEA10923N96N88S1GEKGYR",
        "connection_id": "1RKMMEA10923N96N88S1GEKGYR",
        ...
    },
    {
        "channel_id": "zakuro",
        "client_id": "EYYX5FGZN17VB647HGYZ27K8MM",
        "bundle_id": "EYYX5FGZN17VB647HGYZ27K8MM",
        "connection_id": "EYYX5FGZN17VB647HGYZ27K8MM",
        ...
    }
]
```


## ライセンス API


### GetLicense

**x-sora-target**: Sora_20171218.GetLicense

現在利用しているライセンス情報を取得します。

> **重要**
>
> `signature` は表示されません

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20171218.GetLicense -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20171218.GetLicense



HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 174
content-type: application/json
date: Fri, 05 Jan 2018 06:41:35 GMT
server: Cowboy

{
    "expired_at": "2023-03",
    "max_connections": 100,
    "product_name": "Sora",
    "serial_code": "123ABC-SRA-E001-202303-100",
    "type": "Experimental"
}
```


### UpdateLicense

**x-sora-target**: Sora_20171218.UpdateLicense

ライセンスを更新します。

`sora.conf` の `license_file` に設定したファイルを新規のライセンスとして読み込みます。
ライセンスが壊れていたり、見つからない場合はエラーになります。
いずれの場合も接続中のクライアントへの影響はありません。

> **重要**
>
> `signature` は表示されません

```console
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20171218.UpdateLicense -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20171218.UpdateLicense



HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 379
content-type: application/json
date: Fri, 05 Jan 2018 06:44:47 GMT
server: Cowboy

{
    "new_license": {
        "expired_at": "2023-03",
        "max_connections": 100,
        "product_name": "Sora",
        "serial_code": "123ABC-SRA-E001-202303-100",
        "type": "Experimental"
    },
    "old_license": {
        "expired_at": "2024-03",
        "max_connections": 100,
        "product_name": "Sora",
        "serial_code": "123ABC-SRA-E002-202403-100",
        "type": "Experimental"
    }
}
```
