ajout app

This commit is contained in:
2024-04-17 20:22:30 +02:00
parent cc017cfc5e
commit f9d05a2fd3
8025 changed files with 729805 additions and 0 deletions

View File

@ -0,0 +1,62 @@
![restAPI](restAPI.png)
## Create a meeting
Create a meeting with a `HTTP request` containing the `API_KEY` sent to MiroTalks server. The response contains a `meeting` URL that can be `embedded` in your client within an `iframe`.
The `API_KEY` is defined in the `app/src/config.js`, change it with your own.
```js
api: {
// app/api
keySecret: 'mirotalksfu_default_secret',
}
```
Some examples demonstrating how to call the API:
```bash
# js
node meetings.js
node meeting.js
node join.js
# php
php meetings.php
php meeting.php
php join.php
# python
python3 meetings.py
python3 meeting.py
python3 join.py
# bash
./meetings.sh
./meeting.sh
./join.sh
```
## Embed a meeting
Embedding a meeting into a `service` or `app` requires using an `iframe` with the `src` attribute specified as the `meeting` from `HTTP response`.
```html
<iframe
allow="camera; microphone; display-capture; fullscreen; clipboard-read; clipboard-write; autoplay"
src="https://sfu.mirotalk.com/join/your_room_name"
style="height: 100vh; width: 100vw; border: 0px;"
></iframe>
```
## Fast Integration
Develop your `website` or `application`, and bring `video meetings` in with a simple `iframe`.
```html
<iframe
allow="camera; microphone; display-capture; fullscreen; clipboard-read; clipboard-write; autoplay"
src="https://sfu.mirotalk.com/newroom"
style="height: 100vh; width: 100vw; border: 0px;"
></iframe>
```

View File

@ -0,0 +1,46 @@
'use strict';
async function getJoin() {
try {
// Use dynamic import with await
const { default: fetch } = await import('node-fetch');
const API_KEY_SECRET = 'mirotalksfu_default_secret';
const MIROTALK_URL = 'https://sfu.mirotalk.com/api/v1/join';
//const MIROTALK_URL = 'http://localhost:3010/api/v1/join';
const response = await fetch(MIROTALK_URL, {
method: 'POST',
headers: {
authorization: API_KEY_SECRET,
'Content-Type': 'application/json',
},
body: JSON.stringify({
room: 'test',
roomPassword: false,
name: 'mirotalksfu',
audio: true,
video: true,
screen: true,
hide: false,
notify: true,
token: {
username: 'username',
password: 'password',
presenter: true,
expire: '1h',
},
}),
});
const data = await response.json();
if (data.error) {
console.log('Error:', data.error);
} else {
console.log('join:', data.join);
}
} catch (error) {
console.error('Error fetching data:', error);
}
}
getJoin();

View File

@ -0,0 +1,45 @@
<?php
$API_KEY_SECRET = "mirotalksfu_default_secret";
$MIROTALK_URL = "https://sfu.mirotalk.com/api/v1/join";
// $MIROTALK_URL = "http://localhost:3010/api/v1/join";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $MIROTALK_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = [
'authorization:' . $API_KEY_SECRET,
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = array(
"room" => "test",
"roomPassword" => false,
"name" => "mirotalksfu",
"audio" => true,
"video" => true,
"screen" => true,
"hide" => false,
"notify" => true,
"token" => array(
"username" => "username",
"password" => "password",
"presenter" => true,
"expire" => "1h",
),
);
$data_string = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Status code: $httpcode \n";
$data = json_decode($response);
echo "join: ", $data->{'join'}, "\n";

View File

@ -0,0 +1,39 @@
# pip3 install requests
import requests
import json
API_KEY_SECRET = "mirotalksfu_default_secret"
MIROTALK_URL = "https://sfu.mirotalk.com/api/v1/join"
# MIROTALK_URL = "http://localhost:3010/api/v1/join"
headers = {
"authorization": API_KEY_SECRET,
"Content-Type": "application/json",
}
data = {
"room": "test",
"roomPassword": "false",
"name": "mirotalksfu",
"audio": "true",
"video": "true",
"screen": "true",
"hide": "false",
"notify": "true",
"token": {
"username": "username",
"password": "password",
"presenter": "true",
"expire": "1h",
}
}
response = requests.post(
MIROTALK_URL,
headers=headers,
json=data,
)
print("Status code:", response.status_code)
data = json.loads(response.text)
print("join:", data["join"])

View File

@ -0,0 +1,11 @@
#!/bin/bash
API_KEY_SECRET="mirotalksfu_default_secret"
MIROTALK_URL="https://sfu.mirotalk.com/api/v1/join"
# MIROTALK_URL="http://localhost:3010/api/v1/join"
curl $MIROTALK_URL \
--header "authorization: $API_KEY_SECRET" \
--header "Content-Type: application/json" \
--data '{"room":"test","roomPassword":"false","name":"mirotalksfu","audio":"true","video":"true","screen":"false","hide":"false","notify":"true","token":{"username":"username","password":"password","presenter":"true", "expire":"1h"}}' \
--request POST

View File

@ -0,0 +1,30 @@
'use strict';
async function getMeeting() {
try {
// Use dynamic import with await
const { default: fetch } = await import('node-fetch');
const API_KEY_SECRET = 'mirotalksfu_default_secret';
const MIROTALK_URL = 'https://sfu.mirotalk.com/api/v1/meeting';
// const MIROTALK_URL = 'http://localhost:3010/api/v1/meeting';
const response = await fetch(MIROTALK_URL, {
method: 'POST',
headers: {
authorization: API_KEY_SECRET,
'Content-Type': 'application/json',
},
});
const data = await response.json();
if (data.error) {
console.log('Error:', data.error);
} else {
console.log('meeting:', data.meeting);
}
} catch (error) {
console.error('Error fetching data:', error);
}
}
getMeeting();

View File

@ -0,0 +1,25 @@
<?php
$API_KEY_SECRET = "mirotalksfu_default_secret";
$MIROTALK_URL = "https://sfu.mirotalk.com/api/v1/meeting";
// $MIROTALK_URL = "http://localhost:3010/api/v1/meeting";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $MIROTALK_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = [
'authorization:' . $API_KEY_SECRET,
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Status code: $httpcode \n";
$data = json_decode($response);
echo "meeting: ", $data->{'meeting'}, "\n";

View File

@ -0,0 +1,21 @@
# pip3 install requests
import requests
import json
API_KEY_SECRET = "mirotalksfu_default_secret"
MIROTALK_URL = "https://sfu.mirotalk.com/api/v1/meeting"
# MIROTALK_URL = "http://localhost:3010/api/v1/meeting"
headers = {
"authorization": API_KEY_SECRET,
"Content-Type": "application/json",
}
response = requests.post(
MIROTALK_URL,
headers=headers
)
print("Status code:", response.status_code)
data = json.loads(response.text)
print("meeting:", data["meeting"])

View File

@ -0,0 +1,10 @@
#!/bin/bash
API_KEY_SECRET="mirotalksfu_default_secret"
MIROTALK_URL="https://sfu.mirotalk.com/api/v1/meeting"
# MIROTALK_URL="http://localhost:3010/api/v1/meeting"
curl $MIROTALK_URL \
--header "authorization: $API_KEY_SECRET" \
--header "Content-Type: application/json" \
--request POST

View File

@ -0,0 +1,34 @@
'use strict';
async function getMeetings() {
try {
// Use dynamic import with await
const { default: fetch } = await import('node-fetch');
const API_KEY_SECRET = 'mirotalksfu_default_secret';
const MIROTALK_URL = 'https://sfu.mirotalk.com/api/v1/meetings';
//const MIROTALK_URL = 'http://localhost:3010/api/v1/meetings';
const response = await fetch(MIROTALK_URL, {
method: 'GET',
headers: {
authorization: API_KEY_SECRET,
'Content-Type': 'application/json',
},
});
const data = await response.json();
if (data.error) {
console.log('Error:', data.error);
} else {
if (data && data.meetings) {
const meetings = data.meetings;
const formattedData = JSON.stringify({ meetings }, null, 2);
console.log(formattedData);
}
}
} catch (error) {
console.error('Error fetching data:', error);
}
}
getMeetings();

View File

@ -0,0 +1,29 @@
<?php
$API_KEY_SECRET = "mirotalksfu_default_secret";
$MIROTALK_URL = "https://sfu.mirotalk.com/api/v1/meetings";
//$MIROTALK_URL = "http://localhost:3010/api/v1/meetings";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $MIROTALK_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPGET, true);
$headers = [
'authorization:' . $API_KEY_SECRET,
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Status code: $httpcode \n";
if ($response) {
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
} else {
echo "Failed to retrieve data.\n";
}

View File

@ -0,0 +1,26 @@
# pip3 install requests
import requests
import json
API_KEY_SECRET = "mirotalksfu_default_secret"
MIROTALK_URL = "https://sfu.mirotalk.com/api/v1/meetings"
#MIROTALK_URL = "http://localhost:3010/api/v1/meetings"
headers = {
"authorization": API_KEY_SECRET,
"Content-Type": "application/json",
}
response = requests.get(
MIROTALK_URL,
headers=headers
)
print("Status code:", response.status_code)
if response.status_code == 200:
data = response.json()
pretty_printed_data = json.dumps(data, indent=4)
print(data)
else:
print("Failed to retrieve data. Error:", response.text)

View File

@ -0,0 +1,10 @@
#!/bin/bash
API_KEY_SECRET="mirotalksfu_default_secret"
MIROTALK_URL="https://sfu.mirotalk.com/api/v1/meetings"
#MIROTALK_URL="http://localhost:3010/api/v1/meetings"
curl $MIROTALK_URL \
--header "authorization: $API_KEY_SECRET" \
--header "Content-Type: application/json" \
--request GET

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,204 @@
swagger: '2.0'
info:
title: MiroTalk SFU API
description: API description for external applications that integrate with MiroTalk SFU.
version: 1.0.1
basePath: /api/v1
schemes:
- https
- http
paths:
/meetings:
get:
tags:
- 'meetings'
summary: 'Get meetings'
description: 'Get meetings'
produces:
- 'application/json'
security:
- secretApiKey: []
responses:
'200':
description: 'Get Meetings done'
schema:
$ref: '#/definitions/MeetingsResponse'
'403':
description: 'Unauthorized!'
/meeting:
post:
tags:
- 'meeting'
summary: 'Create meeting'
description: 'Create meeting'
consumes:
- 'application/json'
produces:
- 'application/json'
security:
- secretApiKey: []
responses:
'200':
description: 'Meeting created'
schema:
$ref: '#/definitions/MeetingResponse'
'403':
description: 'Unauthorized!'
/join:
post:
tags:
- 'join'
summary: 'Create direct join'
description: 'Create join'
parameters:
- in: body
name: Join
description: Custom Join URL.
schema:
$ref: '#/definitions/JoinRequest'
consumes:
- 'application/json'
produces:
- 'application/json'
security:
- secretApiKey: []
responses:
'200':
description: 'Direct join created'
schema:
$ref: '#/definitions/JoinResponse'
'403':
description: 'Unauthorized!'
/token:
post:
tags:
- 'token'
summary: 'Get token'
description: 'Get token'
parameters:
- in: body
name: token
description: Custom Token.
schema:
$ref: '#/definitions/TokenRequest'
consumes:
- 'application/json'
produces:
- 'application/json'
security:
- secretApiKey: []
responses:
'200':
description: 'Get token done'
schema:
$ref: '#/definitions/TokenResponse'
'403':
description: 'Unauthorized!'
securityDefinitions:
secretApiKey:
type: 'apiKey'
name: 'authorization'
in: 'header'
description: 'Format like this: authorization: {API_KEY_SECRET}'
definitions:
MeetingsResponse:
type: object
properties:
meetings:
type: array
items:
$ref: '#/definitions/Meeting'
MeetingResponse:
type: 'object'
properties:
meeting:
type: string
JoinRequest:
type: object
properties:
room:
type: string
default: 'test'
roomPassword:
type: ['boolean', 'string'] # Allow boolean or string type
default: false
name:
type: string
default: 'mirotalksfu'
audio:
type: boolean
default: false
video:
type: boolean
default: false
screen:
type: boolean
default: false
hide:
type: boolean
default: false
notify:
type: boolean
default: false
token:
$ref: '#/definitions/TokenRequest'
TokenRequest:
type: object
properties:
username:
type: string
default: 'username'
password:
type: string
default: 'password'
presenter:
type: boolean
default: true
expire:
type: string
default: '1h'
JoinResponse:
type: 'object'
properties:
join:
type: string
TokenResponse:
type: 'object'
properties:
token:
type: string
Peer:
type: object
properties:
name:
type: string
presenter:
type: boolean
video:
type: boolean
audio:
type: boolean
screen:
type: boolean
hand:
type: boolean
os:
type: string
browser:
type: string
Meeting:
type: object
properties:
roomId:
type: string
peers:
type: array
items:
$ref: '#/definitions/Peer'

View File

@ -0,0 +1,36 @@
'use strict';
async function getToken() {
try {
// Use dynamic import with await
const { default: fetch } = await import('node-fetch');
const API_KEY_SECRET = 'mirotalksfu_default_secret';
const MIROTALK_URL = 'https://sfu.mirotalk.com/api/v1/token';
//const MIROTALK_URL = 'http://localhost:3010/api/v1/token';
const response = await fetch(MIROTALK_URL, {
method: 'POST',
headers: {
authorization: API_KEY_SECRET,
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: 'username',
password: 'password',
presenter: true,
expire: '1h',
}),
});
const data = await response.json();
if (data.error) {
console.log('Error:', data.error);
} else {
console.log('token:', data.token);
}
} catch (error) {
console.error('Error fetching data:', error);
}
}
getToken();

View File

@ -0,0 +1,37 @@
<?php
$API_KEY_SECRET = "mirotalksfu_default_secret";
$MIROTALK_URL = "https://sfu.mirotalk.com/api/v1/token";
#$MIROTALK_URL = "http://localhost:3010/api/v1/token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $MIROTALK_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = [
'authorization:' . $API_KEY_SECRET,
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = array(
"username" => "username",
"password" => "password",
"presenter" => true,
"expire" => "1h",
);
$data_string = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Status code: $httpcode \n";
$data = json_decode($response);
echo "token: ", $data->{'token'}, "\n";

View File

@ -0,0 +1,29 @@
# pip3 install requests
import requests
import json
API_KEY_SECRET = "mirotalksfu_default_secret"
MIROTALK_URL = "https://sfu.mirotalk.com/api/v1/token"
#MIROTALK_URL = "http://localhost:3010/api/v1/token"
headers = {
"authorization": API_KEY_SECRET,
"Content-Type": "application/json",
}
data = {
"username": "username",
"password": "password",
"presenter": "true",
"expire": "1h"
}
response = requests.post(
MIROTALK_URL,
headers=headers,
json=data
)
print("Status code:", response.status_code)
data = json.loads(response.text)
print("token:", data["token"])

View File

@ -0,0 +1,11 @@
#!/bin/bash
API_KEY_SECRET="mirotalksfu_default_secret"
MIROTALK_URL="https://sfu.mirotalk.com/api/v1/token"
#MIROTALK_URL="http://localhost:3010/api/v1/token"
curl $MIROTALK_URL \
--header "authorization: $API_KEY_SECRET" \
--header "Content-Type: application/json" \
--data '{"username":"username","password":"password","presenter":"true", "expire":"1h"}' \
--request POST