Play Times

Getting detailed play times for a client id

What is a client id? A Client ID is a unique identifier defined by you or your code. The idea is to generate a client ID that can be recalled for a certain user. For example, it could be a salted and hashed version of the mac ID or an external user ID. This ID can be used to save and recall play time data.

URL path: /play_times/:client_id

Scope Name play_times

Description: IGDB Play Times

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
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.

Example

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

Getting total play times for a client id

URL path: /play_times/totals/:client_id

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/play_times/totals/fsf34fw4w4wferevxaaaf34wr")
.header("user-key", "YOUR_KEY")
.header("Accept", "application/json")
.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: /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

  • Content-Type: application/json

Example

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