Play Times

Getting detailed play times for a user

URL path: /private/play_times/

Scope Name play_times

Description: IGDB Play Times

This information is only accessible after a user has authenticated and you have an access token. Any reads or writes performed will be specifically to that user.

Example response

[
    {
        "id": 5253,
        "created_at": 1519380959,
        "game": 5343,
        "user": 24223,
        "client_id": "fsf34fw4w4wferevxaaaf34wr",
        "start_time": 15192843993,
        "end_time": 1519380959,
        "duration": 1
    }
]

Fields

Name Type Mandatory Comment
id 64-bit integer + ID of the play time
created_at 64-bit integer + Unix date the play time was created
game 64-bit integer + Game ID
user 64-bit integer + User ID
start_time 64-bit integer + Unix date the play time started
end_time 64-bit integer + Unix date the play time ended
duration 64-bit integer + Duration of play session in seconds
client_id string A Client ID (usually generated from hardware IDs like MAC ID)

Usage

With the play times endpoint you can get user play times for specific games. This data is generated by desktop clients such as PlayNite.

Important headers

  • Authorization: Bearer "YOUR_ACCESSTOKEN"

Example

HttpResponse<JsonNode> response: Unirest.get("https://api-endpoint.igdb.com/private/play_times/")
.header("user-key", "YOUR_KEY")
.header("Accept", "application/json")
.header("Authorization", "Bearer 'YOUR_ACCESSTOKEN'")
.asJson();

Getting total play times for a user

URL path: /private/play_times/totals/

Important headers

  • Authorization: Bearer "YOUR_ACCESSTOKEN"

Example response

[
    {
        "game": 1337,
        "total_duration": 991
    }
]

Fields

Name Type Mandatory Comment
game 64-bit integer + Game ID
total_duration 64-bit integer + Total duration of play session in seconds

Example

HttpResponse<JsonNode> response: Unirest.get("https://api-endpoint.igdb.com/private/play_times/totals/")
.header("user-key", "YOUR_KEY")
.header("Accept", "application/json")
.header("Authorization", "Bearer 'YOUR_ACCESSTOKEN'")
.asJson();

Creating a play time

To create a new play time entry you have to send a POST request with the new entry in the body with the JSON structure below.

Request URL: /private/play_times/ The API will respond with the newly created list entry, see Example Response.

Example JSON Body

{
	"play_time": {
		"game_id": 52432,
		"client_id": "gfds809fs789dfs789fds789fds78", // optional
		"start_time": 15192843993,
		"end_time": 1519380959,
		"ip_location": "53.213.12.5"
	}
}

Important headers

  • Authorization: Bearer "YOUR_ACCESSTOKEN"
  • Content-Type: application/json

Example

HttpResponse<JsonNode> response: Unirest.post("https://api-endpoint.igdb.com/private/play_times/")
.header("user-key", "YOUR_KEY")
.header("Accept", "application/json")
.header("Authorization", "Bearer 'YOUR_ACCESSTOKEN'")
.header("Content-Type", "application/json")
.body(jsonBody)
.asJson();