Start a play session
curl --request POST \
--url https://patch.gg/api/v1/me/play-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"project": "mira/lantern-run",
"version": "1.2.0",
"device_id": "<string>",
"app_version": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
project: 'mira/lantern-run',
version: '1.2.0',
device_id: '<string>',
app_version: '<string>'
})
};
fetch('https://patch.gg/api/v1/me/play-sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://patch.gg/api/v1/me/play-sessions"
payload = {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"project": "mira/lantern-run",
"version": "1.2.0",
"device_id": "<string>",
"app_version": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"project": "mira/lantern-run",
"version": "<string>",
"client": "desktop",
"started_at": "<string>",
"last_seen_at": "<string>",
"ended_at": "<string>",
"end": "ended",
"heartbeat_s": 123
}{
"error": {
"code": "version_exists",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "version_exists",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "version_exists",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "version_exists",
"message": "<string>",
"details": "<unknown>"
}
}Play
Start a play session
Patch Desktop calls this when a mod’s game starts running, and the play page when a browser game opens. The client makes the id, so a retried start is the same session. Then send a heartbeat every heartbeat_s seconds and end it. Play by the project’s own team is recorded but never counted in its insights.
POST
/
me
/
play-sessions
Start a play session
curl --request POST \
--url https://patch.gg/api/v1/me/play-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"project": "mira/lantern-run",
"version": "1.2.0",
"device_id": "<string>",
"app_version": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
project: 'mira/lantern-run',
version: '1.2.0',
device_id: '<string>',
app_version: '<string>'
})
};
fetch('https://patch.gg/api/v1/me/play-sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://patch.gg/api/v1/me/play-sessions"
payload = {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"project": "mira/lantern-run",
"version": "1.2.0",
"device_id": "<string>",
"app_version": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"project": "mira/lantern-run",
"version": "<string>",
"client": "desktop",
"started_at": "<string>",
"last_seen_at": "<string>",
"ended_at": "<string>",
"end": "ended",
"heartbeat_s": 123
}{
"error": {
"code": "version_exists",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "version_exists",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "version_exists",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "version_exists",
"message": "<string>",
"details": "<unknown>"
}
}Authorizations
An API key (pch_...) or the token from pch login.
Body
application/json
Made by the client (a UUID)
Pattern:
^[a-z0-9][a-z0-9_-]*\/[a-z0-9][a-z0-9-]*$Example:
"mira/lantern-run"
Required string length:
1 - 64Example:
"1.2.0"
Available options:
desktop, web The Patch Desktop install or browser playing, made by the client
Maximum string length:
64Maximum string length:
40Response
Started
Example:
"mira/lantern-run"
Example:
"desktop"
Available options:
ended, exited, crashed, timed_out, null Send a heartbeat this often