# GAMEMONITORING > GAMEMONITORING REST API sunucular, oyuncular, gönderiler, çevrimiçi geçmişi ve oylar hakkında JSON verileri döndürür. Bu sayfa entegrasyonun temellerini ve ilk isteği açıklar. Parametreler ve istek testleri yöntem sayfalarında bulunur. - [GAMEMONITORING API](https://gamemonitoring.tr/developers/docs/api.md) - [GAMEMONITORING MCP](https://gamemonitoring.tr/developers/docs/mcp.md) - [Sunucu ekle](https://gamemonitoring.tr/developers/docs/api/servers/__post.md) - [Sunucu](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/__get.md) - [Sunucu oyuncuları](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/players/__get.md) - [Sunucudan bahseden gönderiler](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/posts/__get.md) - [Sunucunun çevrimiçi oyuncu grafiği](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/stats/players_online/__get.md) - [Sunucu oyları](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/votes/__get.md) - [Sunucu oy grafiği](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/votes/chart/__get.md) - [Sunucuya en çok oy verenler](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/votes/top/__get.md) - [Projenin çevrimiçi oyuncu grafiği](https://gamemonitoring.tr/developers/docs/api/projects/:project_id/stats/players_online/__get.md) - [Proje oyları](https://gamemonitoring.tr/developers/docs/api/projects/:project_id/votes/__get.md) - [Proje oy grafiği](https://gamemonitoring.tr/developers/docs/api/projects/:project_id/votes/chart/__get.md) - [Projeye en çok oy verenler](https://gamemonitoring.tr/developers/docs/api/projects/:project_id/votes/top/__get.md) - [Oy](https://gamemonitoring.tr/developers/docs/api/votes/:vote_id/__get.md) - [Oy işlemesini onayla](https://gamemonitoring.tr/developers/docs/api/votes/:vote_id/claim/__post.md) - [Kullanıcı profili](https://gamemonitoring.tr/developers/docs/api/users/:id/__get.md) - [Hesap sahipliğini doğrula](https://gamemonitoring.tr/developers/docs/api/users/verify-code/__post.md) - [Webhook](https://gamemonitoring.tr/developers/docs/webhook.md) - [Oy ödülleri](https://gamemonitoring.tr/developers/docs/webhook/vote.md) - [Sistem IP adresleri](https://gamemonitoring.tr/developers/docs/ips.md) - [OpenAPI](https://gamemonitoring.tr/developers/docs/openapi.json) - [Tüm belgeler](https://gamemonitoring.tr/developers/docs/llms-full.txt) - [GAMEMONITORING MCP](https://api.gamemonitoring.net/mcp) --- # GAMEMONITORING API GAMEMONITORING REST API sunucular, oyuncular, gönderiler, çevrimiçi geçmişi ve oylar hakkında JSON verileri döndürür. Bu sayfa entegrasyonun temellerini ve ilk isteği açıklar. Parametreler ve istek testleri yöntem sayfalarında bulunur. ## Temel adres https://api.gamemonitoring.tr ## İlk istek Herkese açık sunucu verileriyle başlayın. Sunucu kimliği, sunucunun GAMEMONITORING sayfa adresinin sonunda yer alır. ```bash curl --header 'Accept: application/json' 'https://api.gamemonitoring.tr/servers/1' ``` ## Yöntem seçin - [POST /servers — Sunucu ekle](https://gamemonitoring.tr/developers/docs/api/servers/__post.md) - [GET /servers/{server_id} — Sunucu](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/__get.md) - [GET /servers/{server_id}/players — Sunucu oyuncuları](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/players/__get.md) - [GET /servers/{server_id}/posts — Sunucudan bahseden gönderiler](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/posts/__get.md) - [GET /servers/{server_id}/stats/players_online — Sunucunun çevrimiçi oyuncu grafiği](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/stats/players_online/__get.md) - [GET /servers/{server_id}/votes — Sunucu oyları](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/votes/__get.md) - [GET /servers/{server_id}/votes/chart — Sunucu oy grafiği](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/votes/chart/__get.md) - [GET /servers/{server_id}/votes/top — Sunucuya en çok oy verenler](https://gamemonitoring.tr/developers/docs/api/servers/:server_id/votes/top/__get.md) - [GET /projects/{project_id}/stats/players_online — Projenin çevrimiçi oyuncu grafiği](https://gamemonitoring.tr/developers/docs/api/projects/:project_id/stats/players_online/__get.md) - [GET /projects/{project_id}/votes — Proje oyları](https://gamemonitoring.tr/developers/docs/api/projects/:project_id/votes/__get.md) - [GET /projects/{project_id}/votes/chart — Proje oy grafiği](https://gamemonitoring.tr/developers/docs/api/projects/:project_id/votes/chart/__get.md) - [GET /projects/{project_id}/votes/top — Projeye en çok oy verenler](https://gamemonitoring.tr/developers/docs/api/projects/:project_id/votes/top/__get.md) - [GET /votes/{vote_id} — Oy](https://gamemonitoring.tr/developers/docs/api/votes/:vote_id/__get.md) - [POST /votes/{vote_id}/claim — Oy işlemesini onayla](https://gamemonitoring.tr/developers/docs/api/votes/:vote_id/claim/__post.md) - [GET /users/{id} — Kullanıcı profili](https://gamemonitoring.tr/developers/docs/api/users/:id/__get.md) - [POST /users/verify-code — Hesap sahipliğini doğrula](https://gamemonitoring.tr/developers/docs/api/users/verify-code/__post.md) ## API sürümleri API sürümünü isteğe bağlı v sorgu parametresiyle seçebilirsiniz. Geçerli sürüm 1.0.0. Sürüm kullanılabilir yolları, istek alanlarını ve yanıt biçimini belirler. v belirtilmezse desteklenen en düşük sürüm kullanılır. Bu sürüm kaldırıldığında bir sonraki en düşük sürüm varsayılan olur. Sözleşmeyi sabitlemek için v belirtin. Geçersiz, tekrarlanan veya desteklenmeyen sürümler HTTP 400 döndürür; desteklenmeyen sürümler için kullanılabilir değerler error.data.supported_versions alanındadır. ## Parametreleri gönderme Kimlikler istek yolundadır: server_id ve project_id sayısal GAMEMONITORING kimlikleri, vote_id ise oy kimliğidir. Süslü parantez içindeki parametreyi gerçek değeriyle değiştirin. Filtreler, dönemler ve sayfalama URL içinde ? sonrasında gönderilir. Özellikle takma ad ve arama metnini URLSearchParams veya kullandığınız kütüphanenin eşdeğeriyle kodlayın. Sunucu eklemek için Content-Type: application/json ile JSON gönderin. connect herkese açık host:port, steam_app_id oyunun Steam App ID değeridir. Sorgu ve bağlantı portları farklıysa query kullanın. ## Veri biçimi HTTP 200 sonucu response içinde döndürür: yönteme göre nesne, dizi veya items içeren nesne. Yöntemin şemasına bakın; boş liste tek başına hata değildir. Bazı alanlar null olabilir veya bulunmayabilir. Bunlar 0, false ve boş metinden farklıdır; eksik veriyi ayrı ele alın. created_at, expires_at ve last_update saniye cinsinden Unix zamanı kullanır. JavaScript Date için 1000 ile çarpın; filtrelerde Date.now() değerini 1000 ile bölüp aşağı yuvarlayın. 64 bit Steam kimliklerini metin olarak saklayın. JavaScript Number dönüşümü hassasiyet kaybına yol açabilir. GAMEMONITORING sunucu kimliği ile oyunun Steam App ID değeri farklı kimliklerdir. ## Hatalar ve yeniden denemeler HTTP durumunu ve error nesnesini kontrol edin: code durum kodunu, message açıklamayı, data varsa ek bilgileri içerir. Mesaj metni bölgeye göre değişebilir; kodda koşul olarak kullanmayın. Parametre veya erişim hatasının nedenini düzeltmeden tekrar denemeyin. JSON içermeyebilen ağ hatalarını ve proxy yanıtlarını da ele alın. Veriler son sunucu sorgusunu yansıtır ve önbellekte olabilir. last_update değerini kontrol edin, makul bir yenileme aralığı kullanın ve sonucu entegrasyonunuzda önbelleğe alın. API sorgularını sıklaştırmak oyun sunucusunu daha hızlı güncellemez. ## Oylama ve Webhook Yeni oylara tepki vermek için proje Webhook ayarını yapın. signature değerini doğrulayın, is_test=true testlerini atlayın ve oyu API üzerinden almak için event_id değerini vote_id olarak kullanın. entity_type ve entity_id değerlerini kontrol edin ve event_type + event_id çiftini yalnızca bir kez işleyin. Test olaylarını ödül vermeden 2xx yanıtıyla onaylayın. ## Entegrasyon desteği Hata bildirirken HTTP yöntemi, yol, parametreler, istek zamanı, HTTP durumu ve alınan error bilgisini hazırlayın. Bunlar sorunu yeniden oluşturmayı kolaylaştırır. ## OpenAPI ```json { "openapi": "3.1.1", "info": { "title": "GAMEMONITORING", "version": "1.0.0" }, "paths": { "/servers": { "post": { "operationId": "createServer", "summary": "Sunucu ekle", "description": "Bağlantı adresiyle sunucu ekler veya mevcut sunucuyu döndürür.", "parameters": [ { "$ref": "#/components/parameters/ApiVersion" } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "connect": { "type": "string", "minLength": 1, "example": "198.51.100.24:27015" }, "steam_app_id": { "type": "integer", "minimum": 0, "example": 730 }, "query": { "type": "integer", "minimum": 10, "maximum": 65535, "example": 27016 } }, "required": [ "connect", "steam_app_id" ] }, "example": { "connect": "198.51.100.24:27015", "steam_app_id": 730 } } } }, "responses": { "200": { "description": "Created or existing server", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServerCreateResult" }, "example": { "response": { "connect": "198.51.100.24:27015", "game": 730, "id": 100001, "name": "Example Arena", "request": "198.51.100.24:27016", "status": true } } } } }, "400": { "description": "Missing game or address, invalid address or offline server" }, "403": { "description": "Blocked address" }, "409": { "description": "Query address is already in use" }, "503": { "description": "Server creation service is unavailable" }, "504": { "$ref": "#/components/responses/QueryTimeout" }, "default": { "$ref": "#/components/responses/UnexpectedError" } } } }, "/servers/{server_id}": { "get": { "operationId": "getServer", "summary": "Sunucu", "description": "Sunucunun herkese açık verilerini döndürür.", "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "server_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 1 } } ], "responses": { "200": { "description": "Server details response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServerEnvelope" }, "example": { "response": { "steam_id": "90123456789012345", "domain": null, "id": 1, "ip": "198.51.100.24", "port": 27015, "query": 27015, "project_id": 42, "color": 0, "city": "Prague", "description": "[]", "game": 730, "boosts": 3, "last_offline": 1782751200, "last_online": 1783201200, "icon": null, "name": "Example CS2 Server", "connect": "198.51.100.24:27015", "request": "198.51.100.24:27015", "map": "de_mirage", "gamemode": "Counter-Strike 2", "version": "1.41.6.5", "numplayers": 12, "maxplayers": 64, "bots": 0, "secured": true, "private": false, "country": "CZ", "status": true, "votes": 128, "points": 2450, "add_date": 1701541119, "last_update": 1783201200, "ban_reason": null, "banned": false, "wipe": null, "official": null, "wipe_period": null, "next_wipe": null, "pve": null, "pvp": null, "list_hidden": false, "hide_address": false, "hide_query": false, "position_game": 12, "language": "en", "parked": false, "app": { "id": 2, "steam_id": 730, "name": "Counter-Strike 2", "url": "counter-strike-2" }, "mods": [ { "id": 5, "name": "Admin System" }, { "id": 14, "name": "Advertisement" }, { "id": 9, "name": "Admins" }, { "id": 3, "name": "Admin Commands" } ], "disabled_modules": [] } } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "404": { "$ref": "#/components/responses/NotFound" }, "503": { "$ref": "#/components/responses/ServiceUnavailable" }, "504": { "$ref": "#/components/responses/QueryTimeout" }, "default": { "$ref": "#/components/responses/UnexpectedError" } } } }, "/servers/{server_id}/players": { "get": { "operationId": "getServerPlayers", "summary": "Sunucu oyuncuları", "description": "Sunucunun oyuncu listesini döndürür.", "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "limit", "in": "query", "description": "Öğe sayısı 1 ile 100 arasında, varsayılan 50", "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 50, "example": 5 } }, { "$ref": "#/components/parameters/offset" }, { "name": "server_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 1 } } ], "responses": { "200": { "description": "Server players", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServerPlayersResult" }, "example": { "response": { "items": [ { "avatar": "no.jpg", "created": 1783200000, "last_online": 1783203600, "last_session_time": 0, "name": "NovaPlayer", "user": null, "username": null } ] } } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "503": { "$ref": "#/components/responses/ServiceUnavailable" }, "504": { "$ref": "#/components/responses/QueryTimeout" } } } }, "/servers/{server_id}/posts": { "get": { "operationId": "getServerPosts", "summary": "Sunucudan bahseden gönderiler", "description": "Belirtilen sunucudan görünür biçimde bahseden herkese açık gönderileri döndürür.", "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "before_created_at", "in": "query", "description": "Sonraki sayfa için son gönderinin `created_at` değerini Unix saniyesi olarak, `id` değerini ise `before_id` olarak gönderin. Diğer filtreleri aynı tutun. İmleç, `sort` ve `period` belirtilmediğinde çalışır. Bu parametrelerden biri belirtilirse `offset` kullanın.", "schema": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 } }, { "name": "before_id", "in": "query", "description": "İmleç için gönderi kimliği", "schema": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 } }, { "name": "conversation_post_id", "in": "query", "description": "Tartışma gönderisinin kimliği", "schema": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 } }, { "name": "period", "in": "query", "description": "En iyi gönderilerin dönemi için top kullanın.", "schema": { "type": "string", "const": "top" } }, { "name": "reply_to_post_id", "in": "query", "description": "Üst gönderinin kimliği", "schema": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 } }, { "name": "root_only", "in": "query", "description": "Yalnızca ana gönderileri almak için 1 kullanın", "schema": { "type": "number", "const": 1 } }, { "name": "sort", "in": "query", "description": "Gönderi sırası. En iyi gönderiler için helpful-desc kullanın.", "schema": { "type": "string" } }, { "name": "visibility", "in": "query", "description": "Bu işlem yalnızca herkese açık gönderileri döndürür.", "schema": { "type": "string", "const": "public" } }, { "name": "server_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 1 } }, { "name": "limit", "in": "query", "description": "Öğe sayısı 1 ile 100 arasında, varsayılan 20", "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 20, "example": 5 } }, { "$ref": "#/components/parameters/offset" }, { "name": "search", "in": "query", "schema": { "type": "string", "maxLength": 120, "example": "admin" } } ], "responses": { "200": { "description": "Public posts mentioning the server", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServerPostsResult" }, "example": { "response": [ { "id": 1001, "comment": "Great server! Thanks to the admin team.", "conversation_post_id": null, "language": "en", "moderation_needed": false, "replays": 0, "reply_to_post_id": null, "views": 25, "updated_at": null, "created_at": 1783200000, "translated_content": null, "user": { "avatar": "no.jpg", "id": 204801, "username": "demo_user" }, "images": [], "mentions": [ { "type": "server", "meta": { "game": { "id": 2, "name": "Counter-Strike 2", "steam_id": 730, "url": "counter-strike-2" }, "icon": null, "id": 1, "name": "Example CS2 Server" } } ], "reactions": [], "replays_items": [], "replays_items_count": 0 } ] } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "404": { "description": "Server not found" }, "503": { "$ref": "#/components/responses/ServiceUnavailable" }, "504": { "$ref": "#/components/responses/QueryTimeout" }, "default": { "$ref": "#/components/responses/UnexpectedError" } } } }, "/servers/{server_id}/stats/players_online": { "get": { "operationId": "getServerPlayerStats", "summary": "Sunucunun çevrimiçi oyuncu grafiği", "description": "Her aralığın en düşük, ortalama ve en yüksek oyuncu sayısını içeren grafiği döndürür.", "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "type", "in": "query", "description": "İstatistik dönemi: day, week veya month; varsayılan month", "schema": { "type": "string", "default": "month", "example": "week", "enum": [ "day", "week", "month" ] } }, { "name": "server_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 1 } } ], "responses": { "200": { "description": "Player statistics grouped by time interval", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServerPlayerStatsResult" }, "example": { "response": { "items": [ { "avg_players": 12, "date": 1783200000, "maps": [ "de_mirage" ], "max_players": 16, "min_players": 8, "x": 1783200000, "y": 16 } ] } } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "503": { "$ref": "#/components/responses/ServiceUnavailable" }, "504": { "$ref": "#/components/responses/QueryTimeout" }, "default": { "$ref": "#/components/responses/UnexpectedError" } } } }, "/servers/{server_id}/votes": { "get": { "operationId": "getServerVotes", "summary": "Sunucu oyları", "description": "Belirtilen sunucuya verilen oyları döndürür.", "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "user_id", "in": "query", "description": "Kullanıcı kimliği", "schema": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 } }, { "name": "server_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 42 } }, { "$ref": "#/components/parameters/limit" }, { "$ref": "#/components/parameters/offset" }, { "$ref": "#/components/parameters/sort" }, { "$ref": "#/components/parameters/order" }, { "$ref": "#/components/parameters/claimed" }, { "$ref": "#/components/parameters/nickname" }, { "$ref": "#/components/parameters/created" }, { "$ref": "#/components/parameters/created__gt" }, { "$ref": "#/components/parameters/created__gte" }, { "$ref": "#/components/parameters/created__lt" }, { "$ref": "#/components/parameters/created__lte" }, { "$ref": "#/components/parameters/expire" }, { "$ref": "#/components/parameters/expire__gt" }, { "$ref": "#/components/parameters/expire__gte" }, { "$ref": "#/components/parameters/expire__lt" }, { "$ref": "#/components/parameters/expire__lte" } ], "security": [], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "response": { "type": "array", "items": { "$ref": "#/components/schemas/VoteDetails" } } }, "required": [ "response" ] }, "example": { "response": [ { "claimed_at": null, "created_at": 1783200000, "entity_id": 42, "entity_type": "server", "expires_at": 1783243200, "id": "9824cabb-2203-437e-9b6c-aba43dde3e4b", "nickname": "NovaPlayer", "server": { "app": { "id": 2, "name": "Counter-Strike 2", "steam_id": 730, "url": "counter-strike-2" }, "game": 730, "icon": null, "id": 42, "name": "Example CS2 Server" }, "user": { "avatar": "no.jpg", "id": 204801, "username": "demo_user", "uuid": "d4f9c57e-7c8b-49c7-8d7e-b2f1a39f4a25", "connections": [] } } ] } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "503": { "$ref": "#/components/responses/ServiceUnavailable" }, "504": { "$ref": "#/components/responses/QueryTimeout" }, "default": { "$ref": "#/components/responses/UnexpectedError" } } } }, "/servers/{server_id}/votes/chart": { "get": { "operationId": "getServerVoteChart", "summary": "Sunucu oy grafiği", "description": "Günlük oy sayılarını döndürür.", "security": [], "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "server_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 42 } }, { "$ref": "#/components/parameters/period" } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "response": { "type": "array", "items": { "type": "object", "properties": { "x": { "type": [ "integer", "string" ] }, "y": { "type": [ "integer", "string" ] } } } } }, "required": [ "response" ] }, "example": { "response": [ { "x": 1800000000, "y": 10 } ] } } } }, "400": { "$ref": "#/components/responses/BadRequest" } } } }, "/servers/{server_id}/votes/top": { "get": { "operationId": "getServerTopVoters", "summary": "Sunucuya en çok oy verenler", "description": "En fazla oy veren kullanıcıları döndürür.", "security": [], "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "server_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 42 } }, { "$ref": "#/components/parameters/period" }, { "$ref": "#/components/parameters/limit" }, { "$ref": "#/components/parameters/offset" } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "response": { "type": "array", "items": { "type": "object", "properties": { "counts": { "type": "object", "properties": { "active": { "type": [ "integer", "string" ] }, "total": { "type": [ "integer", "string" ] } } }, "last": { "type": "object", "properties": { "created_at": { "type": "integer" }, "expire_at": { "type": "integer" }, "nickname": { "type": "string" } } }, "user": { "type": "object", "properties": { "avatar": { "type": [ "string", "null" ] }, "username": { "type": "string" } } } } } } }, "required": [ "response" ] }, "example": { "response": [ { "counts": { "active": 2, "total": 10 }, "last": { "created_at": 1783200000, "expire_at": 1783243200, "nickname": "NovaPlayer" }, "user": { "avatar": "no.jpg", "username": "demo_user" } } ] } } } }, "400": { "$ref": "#/components/responses/BadRequest" } } } }, "/projects/{project_id}/stats/players_online": { "get": { "operationId": "getProjectPlayerStats", "summary": "Projenin çevrimiçi oyuncu grafiği", "description": "Her aralık için proje sunucularındaki toplam oyuncu sayısının en düşük, ortalama ve en yüksek değerlerini döndürür.", "security": [], "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "type", "in": "query", "description": "İstatistik dönemi: day, week veya month; varsayılan month", "schema": { "type": "string", "default": "month", "example": "week", "enum": [ "day", "week", "month" ] } }, { "name": "project_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 1 } } ], "responses": { "200": { "description": "Combined project player statistics grouped by time interval", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProjectPlayerStatsResult" }, "example": { "response": { "items": [ { "avg_players": 12, "date": 1783200000, "max_players": 16, "min_players": 8, "x": 1783200000 } ] } } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "403": { "description": "Private project is not accessible to the requester" }, "404": { "description": "Project not found" } } } }, "/projects/{project_id}/votes": { "get": { "operationId": "getProjectVotes", "summary": "Proje oyları", "description": "Projeye verilen oyları döndürür. Kimlik doğrulaması olmadan yalnızca herkese açık projelere erişilebilir.", "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "user_id", "in": "query", "description": "Kullanıcı kimliği", "schema": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 } }, { "name": "project_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 42 } }, { "$ref": "#/components/parameters/limit" }, { "$ref": "#/components/parameters/offset" }, { "$ref": "#/components/parameters/sort" }, { "$ref": "#/components/parameters/order" }, { "$ref": "#/components/parameters/claimed" }, { "$ref": "#/components/parameters/nickname" }, { "$ref": "#/components/parameters/created" }, { "$ref": "#/components/parameters/created__gt" }, { "$ref": "#/components/parameters/created__gte" }, { "$ref": "#/components/parameters/created__lt" }, { "$ref": "#/components/parameters/created__lte" }, { "$ref": "#/components/parameters/expire" }, { "$ref": "#/components/parameters/expire__gt" }, { "$ref": "#/components/parameters/expire__gte" }, { "$ref": "#/components/parameters/expire__lt" }, { "$ref": "#/components/parameters/expire__lte" } ], "security": [], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "response": { "type": "array", "items": { "$ref": "#/components/schemas/VoteDetails" } } }, "required": [ "response" ] }, "example": { "response": [ { "claimed_at": null, "created_at": 1783200000, "entity_id": 42, "entity_type": "project", "expires_at": 1785792000, "id": "7206f073-2f18-4660-91b8-bd947fbc4be2", "nickname": "NovaPlayer", "project": { "id": 42 }, "user": { "avatar": "no.jpg", "id": 204801, "username": "demo_user", "uuid": "d4f9c57e-7c8b-49c7-8d7e-b2f1a39f4a25", "connections": [] } } ] } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "403": { "description": "Private project is not accessible to the requester" }, "404": { "description": "Project not found" }, "503": { "$ref": "#/components/responses/ServiceUnavailable" }, "504": { "$ref": "#/components/responses/QueryTimeout" }, "default": { "$ref": "#/components/responses/UnexpectedError" } } } }, "/projects/{project_id}/votes/chart": { "get": { "operationId": "getProjectVoteChart", "summary": "Proje oy grafiği", "description": "Projenin günlük oy sayılarını döndürür. Kimlik doğrulaması olmadan yalnızca herkese açık projelere erişilebilir.", "security": [], "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "project_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 42 } }, { "$ref": "#/components/parameters/period" } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "response": { "type": "array", "items": { "type": "object", "properties": { "x": { "type": [ "integer", "string" ] }, "y": { "type": [ "integer", "string" ] } } } } }, "required": [ "response" ] }, "example": { "response": [ { "x": 1800000000, "y": 10 } ] } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "403": { "description": "Private project is not accessible to the requester" }, "404": { "description": "Project not found" } } } }, "/projects/{project_id}/votes/top": { "get": { "operationId": "getProjectTopVoters", "summary": "Projeye en çok oy verenler", "description": "Projeye en çok oy veren kullanıcıları döndürür. Kimlik doğrulaması olmadan yalnızca herkese açık projelere erişilebilir.", "security": [], "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "project_id", "in": "path", "required": true, "schema": { "type": "integer", "minimum": 1, "example": 42 } }, { "$ref": "#/components/parameters/period" }, { "$ref": "#/components/parameters/limit" }, { "$ref": "#/components/parameters/offset" } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "response": { "type": "array", "items": { "type": "object", "properties": { "counts": { "type": "object", "properties": { "active": { "type": [ "integer", "string" ] }, "total": { "type": [ "integer", "string" ] } } }, "last": { "type": "object", "properties": { "created_at": { "type": "integer" }, "expire_at": { "type": "integer" }, "nickname": { "type": "string" } } }, "user": { "type": "object", "properties": { "avatar": { "type": [ "string", "null" ] }, "username": { "type": "string" } } } } } } }, "required": [ "response" ] }, "example": { "response": [ { "counts": { "active": 2, "total": 10 }, "last": { "created_at": 1783200000, "expire_at": 1785792000, "nickname": "NovaPlayer" }, "user": { "avatar": "no.jpg", "username": "demo_user" } } ] } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "403": { "description": "Private project is not accessible to the requester" }, "404": { "description": "Project not found" } } } }, "/votes/{vote_id}": { "get": { "operationId": "getVote", "summary": "Oy", "description": "Kimliğine göre oy bilgilerini döndürür.", "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "vote_id", "in": "path", "required": true, "schema": { "type": "string", "minLength": 1, "example": "9824cabb-2203-437e-9b6c-aba43dde3e4b" } } ], "responses": { "200": { "description": "Vote details response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/VoteDetailsEnvelope" }, "example": { "response": { "created_at": 1783200000, "expires_at": 1783243200, "id": "6f59a4a8-2f0f-4d96-a50a-9d7a21f4b812", "entity_id": 100001, "entity_type": "server", "nickname": "NovaPlayer", "server": { "app": { "id": 2400, "name": "Example Shooter", "steam_id": 111111, "url": "example-shooter" }, "game": 111111, "icon": null, "id": 100001, "name": "Example Arena" }, "user": { "avatar": "8f14e45f-e9a1-4f4d-a9f3-6d7b0d4a2c18.webp", "id": 204801, "username": "demo_user", "uuid": "d4f9c57e-7c8b-49c7-8d7e-b2f1a39f4a25", "connections": [ { "id": "100000000000000001", "name": "demo_user", "type": "discord", "url": "https://discord.com/users/100000000000000001" }, { "id": "76561198000000001", "name": "NovaPlayer", "type": "steam", "url": "https://steamcommunity.com/profiles/76561198000000001" } ] }, "claimed_at": null } } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "403": { "$ref": "#/components/responses/Forbidden" }, "404": { "$ref": "#/components/responses/NotFound" }, "503": { "$ref": "#/components/responses/ServiceUnavailable" }, "504": { "$ref": "#/components/responses/QueryTimeout" }, "default": { "$ref": "#/components/responses/UnexpectedError" } }, "security": [] } }, "/votes/{vote_id}/claim": { "post": { "operationId": "claimVote", "summary": "Oy işlemesini onayla", "description": "Oyu işlenmiş olarak işaretler. Sunucu veya proje sahibi tarafından kullanılabilir.", "security": [ { "AccountAPIKey": [] } ], "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "vote_id", "in": "path", "required": true, "schema": { "type": "string", "minLength": 1, "example": "9824cabb-2203-437e-9b6c-aba43dde3e4b" } } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/VoteClaimResult" }, "example": { "response": { "success": true } } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "401": { "description": "Missing, invalid, expired or revoked credential." }, "403": { "description": "Missing API key scope, restricted account or entity ownership." }, "404": { "description": "Unknown vote or invalid entity association." }, "429": { "description": "Account claim quota exceeded: 12 000 per minute. Honor Retry-After." } } } }, "/users/{id}": { "get": { "operationId": "getPublicUser", "summary": "Kullanıcı profili", "description": "Kullanıcı profili verilerini döndürür.", "security": [], "parameters": [ { "$ref": "#/components/parameters/ApiVersion" }, { "name": "id", "in": "path", "required": true, "description": "Hesap kimliği.", "schema": { "type": "string", "format": "uuid", "example": "ef57cc6f-f068-11ef-a5bf-d00d12c6f2dd" } } ], "responses": { "200": { "description": "User profile.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserProfileResult" }, "example": { "response": { "avatar": "447f9470-325b-4e0a-ada0-f4f1659ef805.png", "id": 1, "username": "GAMEMONITORING", "banner": "469ebf64-206c-4374-a742-7730ea227f95.webp", "connections": [ { "account_id": "76561197960287930", "account_level": 1, "id": 220354, "name": "Rabscuttle", "platform": { "icon": null, "id": 3, "name": "Steam", "url": "steam" } } ], "created": 1435235037, "last_online": 1793734264, "uuid": "ef57cc6f-f068-11ef-a5bf-d00d12c6f2dd" } } } } }, "400": { "$ref": "#/components/responses/BadRequest" }, "404": { "description": "User not found." } } } }, "/users/verify-code": { "post": { "operationId": "verifyUserCode", "summary": "Hesap sahipliğini doğrula", "description": "Kullanıcı, GAMEMONITORING hesabının kendisine ait olduğunu doğrulamak için [Entegrasyon](/settings/integration) bölümünden bir kod alır. Kod oluşturulduktan sonra 5 dakika geçerlidir. Doğrulama başarılı olursa API, kodun verildiği hesabın kimliğini döndürür ve kodu kullanılmış olarak işaretler.", "security": [], "parameters": [ { "$ref": "#/components/parameters/ApiVersion" } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "additionalProperties": false, "required": [ "code" ], "properties": { "code": { "type": "string", "description": "Tek kullanımlık hesap doğrulama kodu. Büyük ve küçük harfler eşdeğerdir.", "pattern": "^\\s*[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{4}(?:-[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{4}){2}\\s*$", "example": "7KMD-P9RX-3WHT" } } } } } }, "responses": { "200": { "description": "The stable GAMEMONITORING account ID.", "headers": { "Cache-Control": { "schema": { "type": "string" }, "example": "no-store" } }, "content": { "application/json": { "schema": { "type": "object", "additionalProperties": false, "required": [ "response" ], "properties": { "response": { "type": "object", "additionalProperties": false, "required": [ "id" ], "properties": { "id": { "type": "string", "format": "uuid" } } } } }, "example": { "response": { "id": "550e8400-e29b-41d4-a716-446655440000" } } } } }, "400": { "description": "Invalid request or code format." }, "404": { "description": "Unknown, expired or already redeemed code." }, "429": { "description": "Too many requests." }, "503": { "description": "A required service is temporarily unavailable." } } } } }, "components": { "schemas": { "ErrorEnvelope": { "type": "object", "required": [ "error" ], "properties": { "error": { "type": "object", "required": [ "code", "message" ], "properties": { "code": { "type": "integer", "description": "HTTP durum kodu." }, "message": { "type": "string", "description": "API dilindeki hata mesajı. Metin değişebilir; hataları durum koduyla işleyin." }, "data": { "description": "Varsa ek hata ayrıntıları." } } } } }, "Server": { "type": "object", "properties": { "add_date": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ], "description": "Saniye cinsinden Unix zamanı (UTC)." }, "app": { "anyOf": [ { "type": "object", "properties": { "id": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "name": { "type": "string" }, "steam_id": { "description": "Steam App ID of the game. Use this as game_steam_id when searching servers.", "anyOf": [ { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "string" } ] }, { "type": "null" } ] }, "url": { "type": "string" } }, "additionalProperties": {} }, { "type": "null" } ] }, "color": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "connect": { "type": [ "string", "null" ] }, "country": { "type": [ "string", "null" ] }, "domain": { "type": [ "string", "null" ] }, "game": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "hide_address": { "anyOf": [ { "type": "boolean" }, { "type": "integer", "minimum": 0, "maximum": 1 } ] }, "hide_query": { "anyOf": [ { "type": "boolean" }, { "type": "integer", "minimum": 0, "maximum": 1 } ] }, "icon": { "type": [ "string", "null" ] }, "id": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }, "ip": { "type": [ "string", "null" ] }, "language": { "type": [ "string", "null" ] }, "last_update": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ], "description": "Saniye cinsinden Unix zamanı (UTC)." }, "map": { "type": [ "string", "null" ] }, "maxplayers": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "name": { "type": [ "string", "null" ] }, "numplayers": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "official": { "anyOf": [ { "anyOf": [ { "type": "boolean" }, { "type": "integer", "minimum": 0, "maximum": 1 } ] }, { "type": "null" } ] }, "points": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "port": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "private": { "anyOf": [ { "anyOf": [ { "type": "boolean" }, { "type": "integer", "minimum": 0, "maximum": 1 } ] }, { "type": "null" } ] }, "project_id": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "pve": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "pvp": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "query": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "request": { "type": [ "string", "null" ] }, "secured": { "anyOf": [ { "anyOf": [ { "type": "boolean" }, { "type": "integer", "minimum": 0, "maximum": 1 } ] }, { "type": "null" } ] }, "status": { "anyOf": [ { "type": "boolean" }, { "type": "integer", "minimum": 0, "maximum": 1 } ] }, "steam_id": { "anyOf": [ { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "string" } ] }, { "type": "null" } ], "description": "Hassasiyet kaybını önlemek için metin kimliklerini metin olarak saklayın." }, "version": { "type": [ "string", "null" ] }, "votes": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "wipe": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ], "description": "Saniye cinsinden Unix zamanı (UTC)." }, "ban_reason": { "type": [ "string", "null" ] }, "banned": { "anyOf": [ { "type": "boolean" }, { "type": "integer", "minimum": 0, "maximum": 1 } ] }, "boosts": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "bots": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "city": { "type": [ "string", "null" ] }, "description": { "type": [ "string", "null" ], "description": "JSON dizesi olarak kodlanmış blok listesi biçimindeki sunucu açıklaması." }, "disabled_modules": { "type": "array", "items": { "type": "string" } }, "gamemode": { "type": [ "string", "null" ] }, "hidden": { "anyOf": [ { "type": "boolean" }, { "type": "integer", "minimum": 0, "maximum": 1 } ] }, "last_offline": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ], "description": "Saniye cinsinden Unix zamanı (UTC)." }, "last_online": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ], "description": "Saniye cinsinden Unix zamanı (UTC)." }, "list_hidden": { "anyOf": [ { "type": "boolean" }, { "type": "integer", "minimum": 0, "maximum": 1 } ] }, "map_url": { "type": [ "string", "null" ] }, "mods": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "name": { "type": "string" } }, "required": [ "id", "name" ], "additionalProperties": {} } }, "next_wipe": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ], "description": "Saniye cinsinden Unix zamanı (UTC)." }, "parked": { "type": "boolean" }, "position_game": { "anyOf": [ { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" } ] }, "wipe_period": { "type": [ "string", "null" ] } }, "required": [ "id", "parked" ], "additionalProperties": {} }, "ServerEnvelope": { "type": "object", "required": [ "response" ], "properties": { "response": { "$ref": "#/components/schemas/Server", "description": "Başarılı yanıtlarda sonuç response içindedir. Listeler dizi veya items içeren nesne olabilir; işlemin şemasına bakın." } } }, "UserProfileResult": { "type": "object", "required": [ "response" ], "properties": { "response": { "type": "object", "required": [ "id", "uuid", "username", "avatar", "banner", "created", "last_online" ], "properties": { "id": { "type": "integer", "minimum": 1, "description": "Numeric profile ID." }, "uuid": { "type": "string", "format": "uuid", "description": "Account ID." }, "username": { "type": "string" }, "avatar": { "type": [ "string", "null" ] }, "banner": { "type": [ "string", "null" ] }, "created": { "type": [ "integer", "null" ] }, "last_online": { "type": [ "integer", "null" ] }, "connections": { "type": "array", "items": { "type": "object", "required": [ "id", "account_id", "account_level", "name" ], "properties": { "id": { "type": "integer", "minimum": 1 }, "account_id": { "type": "string" }, "account_level": { "type": [ "number", "null" ] }, "name": { "type": [ "string", "null" ] }, "platform": { "type": [ "object", "null" ], "required": [ "id", "name", "icon", "url" ], "properties": { "id": { "type": "integer", "minimum": 1 }, "name": { "type": "string" }, "icon": { "type": [ "string", "null" ] }, "url": { "type": [ "string", "null" ] } } } } } } } } } }, "ServerCreateResult": { "type": "object", "properties": { "response": { "type": "object", "properties": { "connect": { "type": [ "string", "null" ] }, "game": { "type": [ "integer", "null" ] }, "id": { "type": "integer", "minimum": 1 }, "name": { "type": [ "string", "null" ] }, "request": { "type": [ "string", "null" ] }, "status": { "type": [ "boolean", "null" ] } }, "required": [ "connect", "game", "id", "name", "request", "status" ] } }, "required": [ "response" ] }, "ServerPlayersResult": { "type": "object", "properties": { "response": { "type": "object", "properties": { "items": { "description": "Oturum geçmişi sorgusu oyuncu döndürmezse `items`, varsa son sunucu sorgusundaki oyuncuların tam listesini içerir.", "type": "array", "items": { "type": "object", "properties": { "avatar": { "type": "string" }, "created": { "type": [ "number", "string", "null" ] }, "last_online": { "type": [ "number", "string", "null" ] }, "last_session_time": { "type": "number" }, "name": { "type": [ "number", "string", "null" ] }, "user": { "type": [ "object", "null" ], "properties": { "avatar": { "type": [ "string", "null" ] }, "username": { "type": [ "string", "null" ] } } }, "username": { "type": [ "string", "null" ] } }, "required": [ "avatar", "last_session_time", "username" ] } } }, "required": [ "items" ] } }, "required": [ "response" ] }, "ServerPostsResult": { "type": "object", "properties": { "response": { "type": "array", "items": { "type": "object", "additionalProperties": true } } }, "required": [ "response" ] }, "ServerPlayerStatsResult": { "type": "object", "properties": { "response": { "type": "object", "properties": { "items": { "type": "array", "items": { "type": "object", "properties": { "avg_players": { "type": "number" }, "date": { "type": "number" }, "maps": { "type": "array", "items": { "type": "string" } }, "max_players": { "type": "number" }, "min_players": { "type": "number" }, "x": { "type": "number" }, "y": { "type": "number" } }, "required": [ "avg_players", "date", "maps", "max_players", "min_players", "x", "y" ] } } }, "required": [ "items" ] } }, "required": [ "response" ] }, "ProjectPlayerStatsResult": { "type": "object", "properties": { "response": { "type": "object", "properties": { "items": { "type": "array", "items": { "type": "object", "properties": { "avg_players": { "type": "number" }, "date": { "type": "number" }, "max_players": { "type": "number" }, "min_players": { "type": "number" }, "x": { "type": "number" } }, "required": [ "avg_players", "date", "max_players", "min_players", "x" ] } } }, "required": [ "items" ] } }, "required": [ "response" ] }, "VoteDetailsEnvelope": { "type": "object", "properties": { "response": { "$ref": "#/components/schemas/VoteDetails" } } }, "VoteDetails": { "type": "object", "properties": { "id": { "type": "string", "example": "9824cabb-2203-437e-9b6c-aba43dde3e4b" }, "entity_id": { "type": "number", "description": "ID of the entity that received the vote.", "example": 1 }, "entity_type": { "type": "string", "description": "Type of the entity that received the vote.", "enum": [ "server", "project" ], "example": "server" }, "nickname": { "type": [ "string", "null" ], "example": "PlayerName" }, "created_at": { "type": "number", "example": 1710000000 }, "expires_at": { "type": "number", "example": 1710086400 }, "server": { "type": [ "object", "null" ], "description": "Present for `server` votes.", "properties": { "id": { "type": [ "number", "string", "null" ], "example": 1 }, "name": { "type": [ "string", "null" ], "example": "Public Server" }, "icon": { "type": [ "string", "null" ] }, "game": { "type": [ "number", "null" ], "example": 730 } } }, "project": { "type": [ "object", "null" ], "description": "Present for `project` votes.", "properties": { "id": { "type": "number", "example": 1 } } }, "user": { "type": [ "object", "null" ], "properties": { "id": { "type": [ "number", "string", "null" ] }, "uuid": { "type": [ "string", "null" ] }, "username": { "type": [ "string", "null" ] }, "avatar": { "type": [ "string", "null" ] } } }, "webhook": { "type": [ "object", "null" ], "description": "Present only when the requester can view webhook delivery details.", "properties": { "attempted_at": { "type": [ "number", "null" ] }, "event_id": { "type": [ "string", "null" ] }, "event_type": { "type": [ "string", "null" ], "enum": [ "server.vote", "project.vote", null ], "example": "project.vote" }, "is_test": { "type": [ "boolean", "null" ] }, "request_body": { "type": [ "object", "null" ] }, "response_body": {}, "response_code": { "type": [ "number", "string", "null" ] }, "status": { "type": [ "string", "null" ], "enum": [ "delivered", "failed", "no_result", "pending", null ] }, "url": { "type": [ "string", "null" ] } } }, "claimed_at": { "type": [ "integer", "null" ], "description": "Processing acknowledgement time in Unix seconds; null means unclaimed.", "example": null } } }, "VoteClaimResult": { "type": "object", "properties": { "response": { "type": "object", "properties": { "success": { "type": "boolean", "const": true } }, "required": [ "success" ] } }, "required": [ "response" ] } }, "parameters": { "ApiVersion": { "name": "v", "in": "query", "required": false, "description": "API sürümü. v belirtilmezse desteklenen en düşük sürüm kullanılır. Belgelenen sözleşmeyi sabitlemek için v=1.0.0 belirtin. Geçersiz, tekrarlanan veya desteklenmeyen değerler HTTP 400 döndürür.", "schema": { "type": "string", "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$", "const": "1.0.0" } }, "created": { "name": "created", "in": "query", "description": "Oyları tam oluşturulma zamanına göre filtreler. Zamanı Unix saniyesi olarak verin. Tarih filtresi yoksa sorgu saklanan tüm oyları kapsar.", "schema": { "type": "integer", "example": 1800000000 } }, "created__gt": { "name": "created__gt", "in": "query", "description": "Oluşturulma zamanı, Unix saniyesi >", "schema": { "type": "integer", "example": 1800000000 } }, "created__gte": { "name": "created__gte", "in": "query", "description": "Oluşturulma zamanı, Unix saniyesi ≥", "schema": { "type": "integer", "example": 1800000000 } }, "created__lt": { "name": "created__lt", "in": "query", "description": "Oluşturulma zamanı, Unix saniyesi <", "schema": { "type": "integer", "example": 1800000000 } }, "created__lte": { "name": "created__lte", "in": "query", "description": "Oluşturulma zamanı, Unix saniyesi ≤", "schema": { "type": "integer", "example": 1800000000 } }, "expire": { "name": "expire", "in": "query", "description": "Sona erme zamanı, Unix saniyesi", "schema": { "type": "integer", "example": 1800000000 } }, "expire__gt": { "name": "expire__gt", "in": "query", "description": "Sona erme zamanı, Unix saniyesi >", "schema": { "type": "integer", "example": 1800000000 } }, "expire__gte": { "name": "expire__gte", "in": "query", "description": "Sona erme zamanı, Unix saniyesi ≥", "schema": { "type": "integer", "example": 1800000000 } }, "expire__lt": { "name": "expire__lt", "in": "query", "description": "Sona erme zamanı, Unix saniyesi <", "schema": { "type": "integer", "example": 1800000000 } }, "expire__lte": { "name": "expire__lte", "in": "query", "description": "Sona erme zamanı, Unix saniyesi ≤", "schema": { "type": "integer", "example": 1800000000 } }, "claimed": { "name": "claimed", "in": "query", "description": "İşlenme durumu: 0 işlenmemiş, 1 işlenmiş; varsayılan olarak tümü", "schema": { "type": "integer", "enum": [ 0, 1 ], "example": 0 } }, "limit": { "name": "limit", "in": "query", "description": "Öğe sayısı 1 ile 1000 arasında, varsayılan 100", "schema": { "type": "integer", "minimum": 1, "maximum": 1000, "default": 100, "example": 100 } }, "offset": { "name": "offset", "in": "query", "description": "Atlanacak öğe sayısı, en az 0, varsayılan 0", "schema": { "type": "integer", "minimum": 0, "default": 0, "example": 0 } }, "order": { "name": "order", "in": "query", "schema": { "type": "string", "enum": [ "asc", "desc" ], "default": "desc", "example": "asc" } }, "sort": { "name": "sort", "in": "query", "schema": { "type": "string", "enum": [ "created", "expire" ], "default": "created", "example": "created" } }, "nickname": { "name": "nickname", "in": "query", "description": "Oy verenin takma adının bölümlerine göre arama, 3 ile 255 karakter", "schema": { "type": "string", "minLength": 3, "maxLength": 255, "example": "Player" } }, "server_id": { "name": "server_id", "in": "query", "schema": { "type": "integer", "example": 42 } }, "entity_type": { "name": "entity_type", "in": "query", "schema": { "type": "string", "enum": [ "server", "project" ], "example": "server" } }, "webhook_status": { "name": "webhook_status", "in": "query", "schema": { "type": "string", "enum": [ "delivered", "failed", "no_result", "pending" ], "example": "failed" } }, "period": { "name": "period", "in": "query", "description": "Oy tarihine göre dönem, varsayılan olarak saklanan tüm geçmiş", "schema": { "type": "string", "enum": [ "24h", "7d", "30d", "90d" ], "example": "30d" } } }, "securitySchemes": { "AccountAPIKey": { "type": "http", "scheme": "bearer", "description": "Account API key: 43 base64url characters without a prefix. Claim requires votes:claim scope plus current ownership. Send only in Authorization: Bearer ." } }, "responses": { "BadRequest": { "description": "Geçersiz parametreler veya JSON. Türleri, zorunlu alanları ve izin verilen değerleri kontrol edin.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }, "example": { "error": { "code": 400, "message": "Invalid request parameters." } } } } }, "Forbidden": { "description": "Erişim reddedildi: adres engellenmiş veya proje herkese açık değil.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }, "example": { "error": { "code": 403, "message": "Access denied." } } } } }, "ServiceUnavailable": { "description": "Hizmet geçici olarak kullanılamıyor. Daha sonra deneyin.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }, "example": { "error": { "code": 503, "message": "Service temporarily unavailable." } } } } }, "QueryTimeout": { "description": "Sorgu zaman sınırını aştı. Daha sonra deneyin veya isteği daraltın.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }, "example": { "error": { "code": 504, "message": "Query timed out." } } } } }, "NotFound": { "description": "İstenen kaynak mevcut değil.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }, "example": { "error": { "code": 404, "message": "Resource not found." } } } } }, "UnexpectedError": { "description": "Beklenmeyen sunucu hatası. error nesnesi gerçek durum kodunu içerir.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }, "example": { "error": { "code": 500, "message": "Internal server error." } } } } } } }, "servers": [ { "url": "https://api.gamemonitoring.tr" } ] } ``` https://gamemonitoring.tr/developers/docs/api.md --- # GAMEMONITORING MCP MCP (Model Context Protocol) ile ajanlar GAMEMONITORING oyunlarına, sunucularına, çevrimiçi durumuna ve oyuncu sayılarına erişebilir. Tüm araçlar salt okunurdur. Herkese açık erişim hesap veya API anahtarı gerektirmez. ## Ajan bağla Elle kurulumda Streamable HTTP seçeneğini belirleyip URL’yi yapıştırın. Cursor ve VS Code için doğrudan kurulum, komut satırı istemcileri için kopyalanabilir komutlar bulunur. ```text https://api.gamemonitoring.net/mcp ``` ### Codex ```bash codex mcp add gamemonitoring --url 'https://api.gamemonitoring.net/mcp' ``` ### Claude Code ```bash claude mcp add --scope user --transport http gamemonitoring 'https://api.gamemonitoring.net/mcp' ``` ### Gemini CLI ```bash gemini mcp add --scope user --transport http gamemonitoring 'https://api.gamemonitoring.net/mcp' ``` ### MCP JSON ```json { "mcpServers": { "gamemonitoring": { "url": "https://api.gamemonitoring.net/mcp" } } } ``` ### Ajan için örnek istek ```text GAMEMONITORING ile en çok çevrimiçi oyuncuya sahip üç Rust sunucusunu bul. Her sunucunun adresini ve oyuncu sayısını göster. ``` ## MCP araçları search_games ile başlayın. Sunucuları aramak, filtrelemek ve saymak için dönen steam_id değerini game_steam_id olarak iletin. Sunucu ayrıntıları için search_servers aracının döndürdüğü GAMEMONITORING sunucu kimliğini kullanın. ### search_games Oyunları ad, slug veya Steam App ID ile arar. steam_id, ad, slug, sunucu sayısı ve oyuncu sayısını döndürür. ```json { "name": "Rust", "limit": 1 } ``` ### get_server_filters Haritaları, sürümleri, ülkeleri, dilleri, oyun modlarını ve diğer filtreleri listeler. Belirli bir oyun için game_steam_id, genel filtreler için boş bir nesne gönderin. ```json { "game_steam_id": 252490 } ``` ### search_servers Sunucuları oyun ve filtrelere göre arar. Sıralama, 1 ile 100 arasında limit ve offset desteklenir. Aramayı daraltmak için oyunu belirtin. ```json { "game_steam_id": 252490, "status": "online", "sort": "numplayers", "limit": 3 } ``` ### get_server Sayısal server_id için herkese açık sunucu ayrıntılarını ve güncel durumu döndürür. ```json { "server_id": 1 } ``` ### get_server_list_metadata Sunucu aramasıyla aynı filtreleri kullanarak eşleşen sunucuları, çevrimiçi sunucuları ve çevrimiçi oyuncuları sayar. ```json { "game_steam_id": 252490, "status": "online" } ``` ## Veri biçimi Başarılı bir tools/call yanıtında result.structuredContent verileri içerir. result.content, verilerin metin gösterimini ve kaynak REST isteğinin bağlantısını içerir. Protokol hataları en üst düzeydeki error alanında yer alır. Araç hatası olduğunda HTTP 200 yanıtında bile result.isError değeri true olur. Varsa ayrıntılar result.structuredContent.error alanındadır. Arama zaman aşımına uğrarsa oyuna veya diğer filtrelere göre daraltın. https://gamemonitoring.tr/developers/docs/mcp.md --- # Webhook {#webhook} Webhook, platformdaki bir işlemden sonra GAMEMONITORING olayını sisteminize gönderir. JSON gövdeli standart bir `POST` isteğidir; web sitesi, panel veya oyun servisi bu sayede otomatik tepki verebilir. Oy ödülleri ayarlıyorsanız önce bu rehbere göre Webhook’u bağlayın, ardından ayrı akışı kullanın: [Oy ödülleri](https://gamemonitoring.tr/developers/docs/webhook/vote#flow). ## Bağlantı {#connect} Bu ayar bir GAMEMONITORING projesini handler’ınıza bağlar ve gelen istekleri doğrulamak için imzalama tokenı sağlar. 1. [Projelerim](https://gamemonitoring.tr/projects/my) sayfasını açın, bir proje oluşturun veya mevcut projeyi seçin, ardından Webhook ayarlarına gidin. 2. `Content-Type: application/json` ile `POST` kabul eden ve istekleri yönlendirmeyen herkese açık bir HTTPS endpoint oluşturun. 3. Webhook ayarlarında tam handler URL’sini girin, örneğin `https://panel.example.com/gamemonitoring-webhook`, ve kaydedin. 4. Aynı bloktaki imzalama tokenını kopyalayın ve handler scriptinize ekleyin. 5. Handler’da `signature` doğrulayın, gerekli `event_type` değerini işleyin ve başarılı `2xx` yanıtını yalnızca olay işlendikten sonra döndürün. Yerel test için handler’ı bilgisayarınızda çalıştırıp herkese açık bir HTTPS URL üzerinden erişilebilir hale getirebilirsiniz. Bunun için [ngrok](https://ngrok.com) veya başka bir tünelleme servisi kullanın ve oluşturulan herkese açık URL’yi Webhook ayarlarına girin. Kurulumdan sonra arayüzden test Webhook’u gönderin ve teslimat durumunu kontrol edin. Örnek URL için sunucunuz `/gamemonitoring-webhook` yolunda `POST` kabul etmelidir. Test başarısızsa önce handler yanıtına bakın: `401` imza hatasıdır, `403` veya HTML doğrulama sayfası genellikle WAF ya da bot protection sorununu gösterir, timeout ise URL’nin internetten erişilemediği veya çok yavaş yanıt verdiği anlamına gelir. ## Handler gereksinimleri {#handler-requirements} - URL internetten erişilebilir olmalıdır. Yerel adresler, özel ağlar ve kullanıcı adı veya parola içeren URL’ler uygun değildir. - Production için HTTPS önerilir. HTTP desteklenir, ancak aktarım sırasında veriyi daha zayıf korur. - Handler `POST` metodunu ve JSON gövdeyi yönlendirme olmadan kabul etmelidir. - `2xx` yanıtını yalnızca sisteminiz olayı işledikten sonra döndürün. Genellikle `204 No Content` yeterlidir. - Olay güvenli şekilde işlenemiyorsa hata kodu döndürün. `3xx`, `4xx`, `5xx`, timeout ve bağlantı hatası başarısız teslimat sayılır. - Firewall, bot protection veya allowlist kullanıyorsanız [GAMEMONITORING IP adreslerini](https://gamemonitoring.tr/developers/docs/ips) istisnalara ekleyin. - Yanıt gövdesinde token, stack trace, SQL hatası veya başka dahili detaylar döndürmeyin. Handler yanıtı arayüzde gösterilir; bu nedenle hata metni güvenli ve anlaşılır olmalıdır. ## Olay verileri {#event-data} Her Webhook JSON gövde ve temel alanlarla gelir: - `event_type` — işlenmesi gereken olay. - `event_id` — benzersiz olay ID’si. Idempotency ve tekrar teslimat koruması için `event_type` ile birlikte kullanın. - `is_test` — arayüzden gelen test teslimatını belirtir. - `signature` — olay gövdesinin imzası. **Webhook olayı örneği** ```json { "event_id": "9824cabb-2203-437e-9b6c-aba43dde3e4b", "event_type": "example.event", "is_test": false, "signature": "0ac4c97a5d934599dbd78985c4bcbb6926e77b4809d2be56333b1b25f638f064" } ``` Örneği okuma şekli: `event_type` hangi olayın işleneceğini gösterir; `event_id` durum değişikliği öncesinde idempotency için gerekir; `is_test: true` teknik teslimat kontrolü anlamına gelir; `signature` iş verisi değildir ve yalnızca isteği doğrulamak için kullanılır. İşleme mantığı `event_type` değerine bağlıdır. `server.vote` ve `project.vote` için ayrı akışı kullanın: [Oy ödülleri](https://gamemonitoring.tr/developers/docs/webhook/vote#flow). `is_test` `true` ise imzayı doğrulayın ve `2xx` döndürün, ancak bakiye değiştirmeyin, eşya vermeyin ve production işlemleri başlatmayın. ## Handler yanıtı örneği {#response-example} Her gelen olayı tek ve net bir sonuçla bitirin: - `204 No Content` — imza doğru, olay işlendi veya güvenli şekilde atlandı. Test teslimatı ve daha önce işlenmiş olay için aynı yanıtı döndürün. - `400 Bad Request` — zorunlu alanlar eksik. Bu handler hatası veya beklenmeyen istek gövdesi anlamına gelir; iş mantığını çalıştırmayın. - `401 Unauthorized` — imza geçersiz. API isteği yapmayın, veritabanını değiştirmeyin ve ödül vermeyin. - `500 Internal Server Error` — veritabanı, kuyruk veya dahili sistem geçici olarak kullanılamıyor. Teslimat başarısız kalır ve sebep düzeltildikten sonra tekrar denenebilir. Örnek: handler olayı aldı, imzayı doğruladı, `event_type` + `event_id` kaydetti ve olayı işlediyse `204` dönebilir. Veritabanı kullanılamıyorsa ve olay kaydedilemiyorsa, teslimatın erken başarılı sayılmaması için `500` döndürmek daha doğrudur. ## İmza doğrulama {#signature} İmza `signature` alanında bulunur. Her türlü iş mantığından, API isteğinden ve veritabanı değişikliğinden önce doğrulayın. Doğrulama için `signature` hariç olay gövdesindeki tüm alanları alın, anahtarları alfabetik sıralayın ve `&` ile birleştirilmiş `key=value` string’i oluşturun. Boolean değerler `true` veya `false` olarak yazılır. **İmzalama string’i** ```text event_id=9824cabb-2203-437e-9b6c-aba43dde3e4b&event_type=example.event&is_test=false ``` Yukarıdaki örnek için imzalama string’i yalnızca `event_id`, `event_type` ve `is_test` alanlarından oluşur. Ardından Webhook ayarlarındaki imzalama tokenı ile `HMAC-SHA256` hesaplayın ve sonucu istekteki `signature` ile karşılaştırın. Örneklerdeki hazır imzalar demo tokenı `paste-webhook-token-here` ile hesaplanmıştır. Kendi handler’ınızda Webhook ayarlarındaki tokenı kullanın. Handler’da: - sıralanmış anahtarlardan imzalama string’ini oluşturun; - imzalama tokenı ile `HMAC-SHA256` hesaplayın; - sonucu constant-time karşılaştırma fonksiyonuyla `signature` ile karşılaştırın: PHP için `hash_equals`, Node.js için `timingSafeEqual`, Python için `compare_digest`; - imza geçersizse `401` döndürün. ## Adım 1. Temel handler {#minimal-handler} Herhangi bir Webhook’u kabul edebilen handler ile başlayın: JSON okur, `signature` doğrular, test teslimatını işler, temel alanları kontrol eder ve `204` döner. Bu adımda handler yalnızca teslimatın doğru kabul edildiğini doğrular. Olay bazlı mantığı bu temel yol çalıştıktan sonra ekleyin. ### PHP ```php $isTest ? 'true' : 'false']); // Build the exact signing string: all body fields except signature, // sorted by key and joined as key=value pairs with &. $fields = array_values(array_filter(array_keys($event), fn($field) => $field !== 'signature')); sort($fields, SORT_STRING); // Calculate HMAC-SHA256 with the webhook token from your settings. $signing = implode('&', array_map(fn($field) => $field . '=' . (string) ($signingData[$field] ?? ''), $fields)); $expected = hash_hmac('sha256', $signing, $secret); $actual = (string) ($event['signature'] ?? ''); // Reject the request before doing any work when the signature is invalid. if (!hash_equals($expected, $actual)) { http_response_code(401); exit; } // Test deliveries must not change balance, inventory, roles, or production data. if ($isTest) { http_response_code(204); exit; } // Real deliveries must include an event type and a stable event id. $eventType = (string) ($event['event_type'] ?? ''); $eventId = (string) ($event['event_id'] ?? ''); if ($eventType === '' || $eventId === '') { http_response_code(400); exit; } // At this point the webhook is trusted. Add event-specific logic here. syslog(LOG_INFO, 'Accepted webhook event ' . $eventType . ' #' . $eventId); // 204 tells GAMEMONITORING that the delivery was accepted successfully. http_response_code(204); ``` ### JavaScript ```javascript const crypto = require('node:crypto') const express = require('express') const app = express() // Replace this token with the signing token from your GAMEMONITORING webhook settings. const secret = 'paste-webhook-token-here' // GAMEMONITORING sends JSON with Content-Type: application/json. app.use(express.json()) function isValidSignature(event) { // Build the exact signing string: all body fields except signature, // sorted by key and joined as key=value pairs with &. const fields = Object.keys(event).filter((field) => field !== 'signature').sort() const signing = fields.map((field) => field + '=' + String(event[field] ?? '')).join('&') // Calculate HMAC-SHA256 with the webhook token from your settings. const expected = crypto.createHmac('sha256', secret).update(signing).digest('hex') const actual = String(event.signature || '') // timingSafeEqual requires buffers with the same length. const expectedBuffer = Buffer.from(expected) const actualBuffer = Buffer.from(actual) return expectedBuffer.length === actualBuffer.length && crypto.timingSafeEqual(expectedBuffer, actualBuffer) } app.post('/gamemonitoring-webhook', (req, res) => { // Read the webhook payload parsed by express.json(). const event = req.body || {} // Reject the request before doing any work when the signature is invalid. if (!isValidSignature(event)) { return res.sendStatus(401) } // Test deliveries must not change balance, inventory, roles, or production data. if (event.is_test === true) { return res.sendStatus(204) } // Real deliveries must include an event type and a stable event id. const eventType = String(event.event_type || '') const eventId = String(event.event_id || '') if (!eventType || !eventId) { return res.sendStatus(400) } // At this point the webhook is trusted. Add event-specific logic here. console.log('Accepted webhook event ' + eventType + ' #' + eventId) // 204 tells GAMEMONITORING that the delivery was accepted successfully. return res.sendStatus(204) }) app.listen(3000) ``` ### Python ```python import hashlib import hmac from flask import Flask, abort, request app = Flask(__name__) # Replace this token with the signing token from your GAMEMONITORING webhook settings. secret = b'paste-webhook-token-here' def stringify(value): # GAMEMONITORING signs booleans as lowercase true/false strings. if isinstance(value, bool): return 'true' if value else 'false' return '' if value is None else str(value) def is_valid_signature(event): # Build the exact signing string: all body fields except signature, # sorted by key and joined as key=value pairs with &. fields = sorted(field for field in event.keys() if field != 'signature') signing = '&'.join(f'{field}={stringify(event.get(field))}' for field in fields) # Calculate HMAC-SHA256 with the webhook token from your settings. expected = hmac.new(secret, signing.encode(), hashlib.sha256).hexdigest() actual = str(event.get('signature') or '') return hmac.compare_digest(expected, actual) @app.post('/gamemonitoring-webhook') def gamemonitoring_webhook(): # Read and decode the JSON body sent by GAMEMONITORING. event = request.get_json(silent=True) or {} # Reject the request before doing any work when the signature is invalid. if not is_valid_signature(event): abort(401) # Test deliveries must not change balance, inventory, roles, or production data. if event.get('is_test') is True: return '', 204 # Real deliveries must include an event type and a stable event id. event_type = str(event.get('event_type') or '') event_id = str(event.get('event_id') or '') if not event_type or not event_id: abort(400) # At this point the webhook is trusted. Add event-specific logic here. app.logger.info('Accepted webhook event %s #%s', event_type, event_id) # 204 tells GAMEMONITORING that the delivery was accepted successfully. return '', 204 ``` ## Adım 2. Tekilleştirme ekleyin {#deduplication} Webhook at-least-once modelini kullanır: aynı olay birden fazla kez gelebilir. Handler sistem durumunu değiştirmeden önce bu işlemi `event_type` + `event_id` ile idempotent yapın. Önce `event_type` ve `event_id` çiftini benzersiz anahtarla saklayan bir tablo oluşturun. Kayıt zaten varsa olay daha önce işlenmiştir. **İşlenmiş Webhook olayları tablosu** ```sql CREATE TABLE gamemonitoring_webhooks ( event_type varchar(64) NOT NULL, event_id varchar(100) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (event_type, event_id) ); ``` Sonra temel handler’ı genişletin: imza ve temel alanlar doğrulandıktan sonra `event_type` + `event_id` kaydedin ve durum değişikliklerini aynı transaction içinde yapın. ### PHP ```php $isTest ? 'true' : 'false']); // Build the exact signing string: all body fields except signature, // sorted by key and joined as key=value pairs with &. $fields = array_values(array_filter(array_keys($event), fn($field) => $field !== 'signature')); sort($fields, SORT_STRING); // Calculate HMAC-SHA256 with the webhook token from your settings. $signing = implode('&', array_map(fn($field) => $field . '=' . (string) ($signingData[$field] ?? ''), $fields)); $expected = hash_hmac('sha256', $signing, $secret); $actual = (string) ($event['signature'] ?? ''); // Reject the request before doing any work when the signature is invalid. if (!hash_equals($expected, $actual)) { http_response_code(401); exit; } // Test deliveries must not change balance, inventory, roles, or production data. if ($isTest) { http_response_code(204); exit; } // Real deliveries must include an event type and a stable event id. $eventType = (string) ($event['event_type'] ?? ''); $eventId = (string) ($event['event_id'] ?? ''); if ($eventType === '' || $eventId === '') { http_response_code(400); exit; } // At this point the webhook is trusted. Deduplicate it before event-specific logic. $pdo = null; try { // Add your local database connection for deduplication and event-specific work. $pdo = new PDO('mysql:host=127.0.0.1;dbname=game;charset=utf8mb4', 'game', 'password', [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]); // Keep deduplication and the real state change in one transaction. // If any step fails, return 500 so the delivery can be retried. $pdo->beginTransaction(); // Store the event once. This requires the table to have a unique key on // (event_type, event_id). Duplicate deliveries affect zero rows. $deduplicate = $pdo->prepare('INSERT IGNORE INTO gamemonitoring_webhooks (event_type, event_id) VALUES (?, ?)'); $deduplicate->execute([$eventType, $eventId]); // The event was already processed earlier. Return success without changing // state again, because duplicate delivery is expected. if ($deduplicate->rowCount() === 0) { $pdo->commit(); http_response_code(204); exit; } // Add event-specific database changes here. Keep them after the // deduplication insert and inside this same transaction. // Commit only after deduplication and event-specific work both succeed. $pdo->commit(); // Log only newly processed real events after the transaction succeeds. syslog(LOG_INFO, 'Accepted webhook event ' . $eventType . ' #' . $eventId); http_response_code(204); } catch (Throwable $error) { // Roll back partial database work so the event can be retried safely. if ($pdo instanceof PDO && $pdo->inTransaction()) { $pdo->rollBack(); } // 500 keeps the delivery failed instead of marking unfinished work as done. http_response_code(500); } ``` ### JavaScript ```javascript const crypto = require('node:crypto') const express = require('express') const mysql = require('mysql2/promise') const app = express() // Replace this token with the signing token from your GAMEMONITORING webhook settings. const secret = 'paste-webhook-token-here' // Add your local database connection for deduplication and event-specific work. const db = mysql.createPool({ database: 'game', host: '127.0.0.1', password: 'password', user: 'game', }) // GAMEMONITORING sends JSON with Content-Type: application/json. app.use(express.json()) function isValidSignature(event) { // Build the exact signing string: all body fields except signature, // sorted by key and joined as key=value pairs with &. const fields = Object.keys(event).filter((field) => field !== 'signature').sort() const signing = fields.map((field) => field + '=' + String(event[field] ?? '')).join('&') // Calculate HMAC-SHA256 with the webhook token from your settings. const expected = crypto.createHmac('sha256', secret).update(signing).digest('hex') const actual = String(event.signature || '') // timingSafeEqual requires buffers with the same length. const expectedBuffer = Buffer.from(expected) const actualBuffer = Buffer.from(actual) return expectedBuffer.length === actualBuffer.length && crypto.timingSafeEqual(expectedBuffer, actualBuffer) } app.post('/gamemonitoring-webhook', async (req, res) => { // Read the webhook payload parsed by express.json(). const event = req.body || {} // Reject the request before doing any work when the signature is invalid. if (!isValidSignature(event)) { return res.sendStatus(401) } // Test deliveries must not change balance, inventory, roles, or production data. if (event.is_test === true) { return res.sendStatus(204) } // Real deliveries must include an event type and a stable event id. const eventType = String(event.event_type || '') const eventId = String(event.event_id || '') if (!eventType || !eventId) { return res.sendStatus(400) } // At this point the webhook is trusted. Deduplicate it before event-specific logic. let connection try { connection = await db.getConnection() // Keep deduplication and the real state change in one transaction. // If any step fails, return 500 so the delivery can be retried. await connection.beginTransaction() // Store the event once. This requires the table to have a unique key on // (event_type, event_id). Duplicate deliveries affect zero rows. const [deduplicate] = await connection.execute( 'INSERT IGNORE INTO gamemonitoring_webhooks (event_type, event_id) VALUES (?, ?)', [eventType, eventId], ) // The event was already processed earlier. Return success without changing // state again, because duplicate delivery is expected. if (deduplicate.affectedRows === 0) { await connection.commit() return res.sendStatus(204) } // Add event-specific database changes here. Keep them after the // deduplication insert and inside this same transaction. // Commit only after deduplication and event-specific work both succeed. await connection.commit() // Log only newly processed real events after the transaction succeeds. console.log('Accepted webhook event ' + eventType + ' #' + eventId) return res.sendStatus(204) } catch (error) { // Roll back partial database work so the event can be retried safely. if (connection) { await connection.rollback() } // 500 keeps the delivery failed instead of marking unfinished work as done. return res.sendStatus(500) } finally { // Return the connection to the pool. if (connection) { connection.release() } } }) app.listen(3000) ``` ### Python ```python import hashlib import hmac import pymysql from flask import Flask, abort, request app = Flask(__name__) # Replace this token with the signing token from your GAMEMONITORING webhook settings. secret = b'paste-webhook-token-here' # Add your local database connection for deduplication and event-specific work. db_config = { 'database': 'game', 'host': '127.0.0.1', 'password': 'password', 'user': 'game', } def stringify(value): # GAMEMONITORING signs booleans as lowercase true/false strings. if isinstance(value, bool): return 'true' if value else 'false' return '' if value is None else str(value) def is_valid_signature(event): # Build the exact signing string: all body fields except signature, # sorted by key and joined as key=value pairs with &. fields = sorted(field for field in event.keys() if field != 'signature') signing = '&'.join(f'{field}={stringify(event.get(field))}' for field in fields) # Calculate HMAC-SHA256 with the webhook token from your settings. expected = hmac.new(secret, signing.encode(), hashlib.sha256).hexdigest() actual = str(event.get('signature') or '') return hmac.compare_digest(expected, actual) @app.post('/gamemonitoring-webhook') def gamemonitoring_webhook(): # Read and decode the JSON body sent by GAMEMONITORING. event = request.get_json(silent=True) or {} # Reject the request before doing any work when the signature is invalid. if not is_valid_signature(event): abort(401) # Test deliveries must not change balance, inventory, roles, or production data. if event.get('is_test') is True: return '', 204 # Real deliveries must include an event type and a stable event id. event_type = str(event.get('event_type') or '') event_id = str(event.get('event_id') or '') if not event_type or not event_id: abort(400) # At this point the webhook is trusted. Deduplicate it before event-specific logic. connection = None try: connection = pymysql.connect(**db_config) connection.begin() # Keep deduplication and the real state change in one transaction. # If any step fails, return 500 so the delivery can be retried. with connection.cursor() as cursor: # Store the event once. This requires the table to have a unique key # on (event_type, event_id). Duplicate deliveries affect zero rows. cursor.execute( 'INSERT IGNORE INTO gamemonitoring_webhooks (event_type, event_id) VALUES (%s, %s)', (event_type, event_id), ) # The event was already processed earlier. Return success without # changing state again, because duplicate delivery is expected. if cursor.rowcount == 0: connection.commit() return '', 204 # Add event-specific database changes here. Keep them after the # deduplication insert and inside this same transaction. # Commit only after deduplication and event-specific work both succeed. connection.commit() # Log only newly processed real events after the transaction succeeds. app.logger.info('Accepted webhook event %s #%s', event_type, event_id) return '', 204 except Exception: # Roll back partial database work so the event can be retried safely. if connection: connection.rollback() # 500 keeps the delivery failed instead of marking unfinished work as done. abort(500) finally: # Close the database connection. if connection: connection.close() ``` Nickname, kullanıcı ID’si veya server ID’sini tekilleştirme anahtarı olarak kullanmayın: aynı kullanıcı farklı olaylar oluşturabilir veya izin verilen bir aksiyonu daha sonra tekrar yapabilir. Anahtar `event_type` + `event_id` olmalıdır. Örnek: handler sistem durumunu değiştirdi ama GAMEMONITORING `204` almadan bağlantı koptu. Daha sonra teslimat tekrarlandığında aynı olay yeniden gelir. Handler kayıtlı `event_type` + `event_id` bulmalı, tekrar durum değişikliği yapmamalı ve `204` dönmelidir. Handler geçici olarak olayı işleyemiyorsa hata yanıtı döndürün. Sebep düzeltildikten sonra, bu olay için tekrar gönderme varsa teslimat arayüzden tekrar gönderilebilir. ## Testler ve tekrar gönderme {#tests-resend} Test teslimatı (`is_test: true`) handler URL’sini, imzayı ve HTTP yanıtını kontrol eder. Handler aynı işleme yolunu izlemelidir: JSON okur, `signature` doğrular, `is_test` değerini tanır ve başarılı `2xx` yanıtı döner. Test olayı bakiye, envanter, roller, abonelikler veya diğer production verilerini değiştirmemelidir. Test için teknik log ve `204` yanıtı yeterlidir. Teslimat hata ile biterse arayüzde durum, HTTP kodu ve handler yanıtı gösterilir. Sebep düzeltildikten sonra, bu olay için tekrar gönderme varsa başarısız teslimat yeniden gönderilebilir. https://gamemonitoring.tr/developers/docs/webhook.md --- # Oy ödülleri {#vote-rewards} Oy ödülleri `server.vote` ve `project.vote` Webhook olaylarını kullanır: handler olayı alır, API ile oy verisini çeker ve ödülü yalnızca bir kez verir. Önce [proje Webhook’unu](https://gamemonitoring.tr/developers/docs/webhook#connect) ve [signature](https://gamemonitoring.tr/developers/docs/webhook#signature) doğrulamasını ayarlayın. Oy verisi [GET /votes/:vote_id](https://gamemonitoring.tr/developers/docs/api/votes/:vote_id/__GET) ile istenir. ## Akış nasıl çalışır {#flow} 1. Webhook olayını alın ve [signature](https://gamemonitoring.tr/developers/docs/webhook#signature) doğrulayın. [is_test](https://gamemonitoring.tr/developers/docs/webhook#tests-resend) `true` ise oyu çekmeden ve ödül vermeden `204` döndürün. 2. `event_type` değerinin `server.vote` veya `project.vote` olduğundan emin olun. 3. `event_id` değerini oy ID’si olarak kullanın. 4. [GET /votes/:vote_id](https://gamemonitoring.tr/developers/docs/api/votes/:vote_id/__GET) ile oy verisini alın ve oyuncuyu kendi sisteminizde bulun. 5. Tek transaction içinde `event_type` + `event_id` ile [tekrar işleme korumasını](https://gamemonitoring.tr/developers/docs/webhook#deduplication) uygulayın ve ödülü yalnızca yeni olay için verin. 6. Ödül güvenli şekilde verilemiyorsa hata yanıtı döndürün. Sebep düzeltildikten sonra teslimatı arayüzden [tekrar gönderin](https://gamemonitoring.tr/developers/docs/webhook#tests-resend). ## Ödül örneği {#reward-example} `PlayerName` oyuncusunun ID’si `1` olan server için oy verdiğini ve sisteminizin ona `100` coin eklemesi gerektiğini varsayalım. 1. GAMEMONITORING `event_type: server.vote` ve `event_id: 9824cabb-2203-437e-9b6c-aba43dde3e4b` ile Webhook gönderir. 2. Handler [signature](https://gamemonitoring.tr/developers/docs/webhook#signature) doğrular. İmza geçersizse `401` döndürür ve durur. 3. Handler `GET /votes/9824cabb-2203-437e-9b6c-aba43dde3e4b` ister, nickname, server ve user verisini alır, ardından yerel hesabı bulur. 4. Transaction içinde handler `event_type` + `event_id` değerini [tekrar işleme koruması](https://gamemonitoring.tr/developers/docs/webhook#deduplication) için kaydeder. 5. Yeni olay için handler aynı transaction içinde `100` coin ekler. 6. Tekrar teslimatta handler zaten kaydedilmiş olayı bulur, ödülü tekrar vermez ve `204` döndürür. Aynı akış eşya, rol, VIP süresi, promosyon kodu veya dahili kuyruğa eklenecek işler için de uygundur. ## Oy olayı {#vote-event} Server oyu için GAMEMONITORING `server.vote`, proje oyu için `project.vote` olayını gönderir. Olay gövdesinde yalnızca teslimat verileri vardır: `event_type`, `event_id`, `is_test` ve `signature`. Tam oy verisi ayrıca istenmelidir. **Olay örneği** ```json { "event_id": "9824cabb-2203-437e-9b6c-aba43dde3e4b", "event_type": "server.vote", "is_test": false, "signature": "ae83b8aba88a3a9ab3b97b1f6d65664da5628a9cb64d56d5132807bca5472e4f" } ``` Bu olayda `event_id` oy ID’sidir. Nickname, server veya user verisi için Webhook gövdesini kaynak olarak kullanmayın: bu veriler API’den gelir. ## Oy verisini alma {#fetch-vote} `event_id` değerini `vote_id` olarak kullanın ve oy verisini [GET /votes/:vote_id](https://gamemonitoring.tr/developers/docs/api/votes/:vote_id/__GET) ile isteyin: **Oy verisi isteği** ```bash curl -sS "https://api.gamemonitoring.tr/votes/9824cabb-2203-437e-9b6c-aba43dde3e4b" ``` Ödül vermek için genellikle `response.nickname`, `response.server` ve public `response.user` verileri gerekir. Ödül belirli bir server’a bağlıysa her zaman `response.server.id` kontrol edin. Alanları kullanma şekli: `response.nickname` veritabanınızdaki oyuncu hesabını bulmaya yardım eder, `response.server.id` server için ödül kuralını seçer, `response.user.id` ise oy veren GAMEMONITORING kullanıcı ID’si olarak ödül loguna yazılabilir. API geçici olarak kullanılamıyorsa veya beklenmeyen yanıt veriyorsa doğrulama yapmadan ödül vermeyin. Hata kodu döndürün, sebebi düzeltin ve teslimatı arayüzden [tekrar gönderin](https://gamemonitoring.tr/developers/docs/webhook#tests-resend). ## Adım 3. Oy ödülü handler’ı {#complete-example} Örnek temel handler’ın devamıdır: imzayı doğrular, oy verisini alır, olayı tekrar işlemeye karşı korur ve ödülü tek transaction içinde ekler. Kullanıcı tablosu adını, bakiye alanını ve oyuncu arama kuralını kendi sistem yapınızla değiştirin. Örneği çalıştırmadan önce [proje Webhook’unu](https://gamemonitoring.tr/developers/docs/webhook#connect) ayarlayın, [GET /votes/:vote_id](https://gamemonitoring.tr/developers/docs/api/votes/:vote_id/__GET) endpoint’ini kontrol edin ve SQL user update sorgularını kendi hesap modelinizle değiştirin. ### PHP ```php $isTest ? 'true' : 'false']); // Build the exact signing string: all body fields except signature, // sorted by key and joined as key=value pairs with &. $fields = array_values(array_filter(array_keys($event), fn($field) => $field !== 'signature')); sort($fields, SORT_STRING); // Calculate HMAC-SHA256 with the webhook token from your settings. $signing = implode('&', array_map(fn($field) => $field . '=' . (string) ($signingData[$field] ?? ''), $fields)); $expected = hash_hmac('sha256', $signing, $secret); $actual = (string) ($event['signature'] ?? ''); // Reject the request before doing any work when the signature is invalid. if (!hash_equals($expected, $actual)) { http_response_code(401); exit; } // Test deliveries must not change balance, inventory, roles, or production data. if ($isTest) { http_response_code(204); exit; } // Real deliveries must include an event type and a stable event id. $eventType = (string) ($event['event_type'] ?? ''); $eventId = (string) ($event['event_id'] ?? ''); if ($eventType === '' || $eventId === '') { http_response_code(400); exit; } // This reward handler processes server and project vote events. if (!in_array($eventType, ['server.vote', 'project.vote'], true)) { http_response_code(204); exit; } // At this point the webhook is trusted. Load vote data before opening a database transaction. $pdo = null; try { // Load full vote data by event_id. Nickname, entity, and user data are not // in the webhook body. Return 500 if the API cannot confirm the vote. $voteUrl = $apiUrl . '/votes/' . rawurlencode($eventId); $voteContext = stream_context_create(['http' => ['timeout' => 5]]); $voteBody = @file_get_contents($voteUrl, false, $voteContext); if ($voteBody === false) { throw new RuntimeException('Vote API request failed'); } $voteResponse = json_decode($voteBody, true) ?: []; $vote = $voteResponse['response'] ?? null; // Do not issue a reward when the vote response is missing a concrete nickname. if (!is_array($vote) || !isset($vote['nickname']) || !is_string($vote['nickname'])) { throw new RuntimeException('Vote API response does not include nickname'); } // Verify that the API entity matches the event before changing the account. $expectedEntityType = $eventType === 'project.vote' ? 'project' : 'server'; if (($vote['entity_type'] ?? '') !== $expectedEntityType) { throw new RuntimeException('Vote entity type does not match event type'); } // Use vote nickname to update the local account. The entity id is available in // vote.entity_id and in either vote.server.id or vote.project.id. $nickname = trim($vote['nickname']); if ($nickname === '') { throw new RuntimeException('Vote nickname is empty'); } // Add your local database connection for deduplication and event-specific work. $pdo = new PDO('mysql:host=127.0.0.1;dbname=game;charset=utf8mb4', 'game', 'password', [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]); // Keep deduplication and the real state change in one transaction. // If any step fails, return 500 so the delivery can be retried. $pdo->beginTransaction(); // Store the event once. This requires the table to have a unique key on // (event_type, event_id). Duplicate deliveries affect zero rows. $deduplicate = $pdo->prepare('INSERT IGNORE INTO gamemonitoring_webhooks (event_type, event_id) VALUES (?, ?)'); $deduplicate->execute([$eventType, $eventId]); // The event was already processed earlier. Return success without changing // state again, because duplicate delivery is expected. if ($deduplicate->rowCount() === 0) { $pdo->commit(); http_response_code(204); exit; } // Add event-specific database changes here. Keep them after the // deduplication insert and inside this same transaction. $balance = $pdo->prepare('UPDATE users SET balance = balance + ? WHERE nickname = ?'); $balance->execute([$rewardAmount, $nickname]); // Commit only after deduplication and event-specific work both succeed. $pdo->commit(); // Log only newly processed real events after the transaction succeeds. syslog(LOG_INFO, 'Accepted webhook event ' . $eventType . ' #' . $eventId); http_response_code(204); } catch (Throwable $error) { // Roll back partial database work so the event can be retried safely. if ($pdo instanceof PDO && $pdo->inTransaction()) { $pdo->rollBack(); } // 500 keeps the delivery failed instead of marking unfinished work as done. http_response_code(500); } ``` ### JavaScript ```javascript const crypto = require('node:crypto') const express = require('express') const mysql = require('mysql2/promise') const app = express() // Replace this token with the signing token from your GAMEMONITORING webhook settings. const secret = 'paste-webhook-token-here' // Add the GAMEMONITORING API URL and reward settings for vote events. const apiUrl = 'https://api.gamemonitoring.tr' const rewardAmount = '1.00' // Add your local database connection for deduplication and event-specific work. const db = mysql.createPool({ database: 'game', host: '127.0.0.1', password: 'password', user: 'game', }) // GAMEMONITORING sends JSON with Content-Type: application/json. app.use(express.json()) function isValidSignature(event) { // Build the exact signing string: all body fields except signature, // sorted by key and joined as key=value pairs with &. const fields = Object.keys(event).filter((field) => field !== 'signature').sort() const signing = fields.map((field) => field + '=' + String(event[field] ?? '')).join('&') // Calculate HMAC-SHA256 with the webhook token from your settings. const expected = crypto.createHmac('sha256', secret).update(signing).digest('hex') const actual = String(event.signature || '') // timingSafeEqual requires buffers with the same length. const expectedBuffer = Buffer.from(expected) const actualBuffer = Buffer.from(actual) return expectedBuffer.length === actualBuffer.length && crypto.timingSafeEqual(expectedBuffer, actualBuffer) } app.post('/gamemonitoring-webhook', async (req, res) => { // Read the webhook payload parsed by express.json(). const event = req.body || {} // Reject the request before doing any work when the signature is invalid. if (!isValidSignature(event)) { return res.sendStatus(401) } // Test deliveries must not change balance, inventory, roles, or production data. if (event.is_test === true) { return res.sendStatus(204) } // Real deliveries must include an event type and a stable event id. const eventType = String(event.event_type || '') const eventId = String(event.event_id || '') if (!eventType || !eventId) { return res.sendStatus(400) } // This reward handler processes server and project vote events. if (!['server.vote', 'project.vote'].includes(eventType)) { return res.sendStatus(204) } // At this point the webhook is trusted. Load vote data before opening a database transaction. let connection try { // Load full vote data by event_id. Nickname, entity, and user data are not // in the webhook body. Return 500 if the API cannot confirm the vote. const voteUrl = apiUrl + '/votes/' + encodeURIComponent(eventId) const voteResponse = await fetch(voteUrl, { signal: AbortSignal.timeout(5000) }) if (!voteResponse.ok) { throw new Error('Vote API request failed') } const voteBody = await voteResponse.json() const vote = voteBody.response // Do not issue a reward when the vote response is missing a concrete nickname. if (!vote || typeof vote.nickname !== 'string') { throw new Error('Vote API response does not include nickname') } // Verify that the API entity matches the event before changing the account. const expectedEntityType = eventType === 'project.vote' ? 'project' : 'server' if (vote.entity_type !== expectedEntityType) { throw new Error('Vote entity type does not match event type') } // Use vote nickname to update the local account. The entity id is available in // vote.entity_id and in either vote.server.id or vote.project.id. const nickname = vote.nickname.trim() if (!nickname) { throw new Error('Vote nickname is empty') } connection = await db.getConnection() // Keep deduplication and the real state change in one transaction. // If any step fails, return 500 so the delivery can be retried. await connection.beginTransaction() // Store the event once. This requires the table to have a unique key on // (event_type, event_id). Duplicate deliveries affect zero rows. const [deduplicate] = await connection.execute( 'INSERT IGNORE INTO gamemonitoring_webhooks (event_type, event_id) VALUES (?, ?)', [eventType, eventId], ) // The event was already processed earlier. Return success without changing // state again, because duplicate delivery is expected. if (deduplicate.affectedRows === 0) { await connection.commit() return res.sendStatus(204) } // Add event-specific database changes here. Keep them after the // deduplication insert and inside this same transaction. await connection.execute('UPDATE users SET balance = balance + ? WHERE nickname = ?', [rewardAmount, nickname]) // Commit only after deduplication and event-specific work both succeed. await connection.commit() // Log only newly processed real events after the transaction succeeds. console.log('Accepted webhook event ' + eventType + ' #' + eventId) return res.sendStatus(204) } catch (error) { // Roll back partial database work so the event can be retried safely. if (connection) { await connection.rollback() } // 500 keeps the delivery failed instead of marking unfinished work as done. return res.sendStatus(500) } finally { // Return the connection to the pool. if (connection) { connection.release() } } }) app.listen(3000) ``` ### Python ```python import hashlib import hmac import pymysql import requests from flask import Flask, abort, request app = Flask(__name__) # Replace this token with the signing token from your GAMEMONITORING webhook settings. secret = b'paste-webhook-token-here' # Add the GAMEMONITORING API URL and reward settings for vote events. api_url = 'https://api.gamemonitoring.tr' reward_amount = '1.00' # Add your local database connection for deduplication and event-specific work. db_config = { 'database': 'game', 'host': '127.0.0.1', 'password': 'password', 'user': 'game', } def stringify(value): # GAMEMONITORING signs booleans as lowercase true/false strings. if isinstance(value, bool): return 'true' if value else 'false' return '' if value is None else str(value) def is_valid_signature(event): # Build the exact signing string: all body fields except signature, # sorted by key and joined as key=value pairs with &. fields = sorted(field for field in event.keys() if field != 'signature') signing = '&'.join(f'{field}={stringify(event.get(field))}' for field in fields) # Calculate HMAC-SHA256 with the webhook token from your settings. expected = hmac.new(secret, signing.encode(), hashlib.sha256).hexdigest() actual = str(event.get('signature') or '') return hmac.compare_digest(expected, actual) @app.post('/gamemonitoring-webhook') def gamemonitoring_webhook(): # Read and decode the JSON body sent by GAMEMONITORING. event = request.get_json(silent=True) or {} # Reject the request before doing any work when the signature is invalid. if not is_valid_signature(event): abort(401) # Test deliveries must not change balance, inventory, roles, or production data. if event.get('is_test') is True: return '', 204 # Real deliveries must include an event type and a stable event id. event_type = str(event.get('event_type') or '') event_id = str(event.get('event_id') or '') if not event_type or not event_id: abort(400) # This reward handler processes server and project vote events. if event_type not in ('server.vote', 'project.vote'): return '', 204 # At this point the webhook is trusted. Load vote data before opening a database transaction. connection = None try: # Load full vote data by event_id. Nickname, entity, and user data # are not in the webhook body. Return 500 if the API cannot confirm the vote. vote_url = f"{api_url}/votes/{event_id}" response = requests.get(vote_url, timeout=5) if not response.ok: raise RuntimeError('Vote API request failed') vote = response.json().get('response') # Do not issue a reward when the vote response is missing a concrete nickname. if not isinstance(vote, dict) or not isinstance(vote.get('nickname'), str): raise RuntimeError('Vote API response does not include nickname') # Verify that the API entity matches the event before changing the account. expected_entity_type = 'project' if event_type == 'project.vote' else 'server' if vote.get('entity_type') != expected_entity_type: raise RuntimeError('Vote entity type does not match event type') # Use vote nickname to update the local account. The entity id is available in # vote.entity_id and in either vote.server.id or vote.project.id. nickname = vote['nickname'].strip() if not nickname: raise RuntimeError('Vote nickname is empty') connection = pymysql.connect(**db_config) connection.begin() # Keep deduplication and the real state change in one transaction. # If any step fails, return 500 so the delivery can be retried. with connection.cursor() as cursor: # Store the event once. This requires the table to have a unique key # on (event_type, event_id). Duplicate deliveries affect zero rows. cursor.execute( 'INSERT IGNORE INTO gamemonitoring_webhooks (event_type, event_id) VALUES (%s, %s)', (event_type, event_id), ) # The event was already processed earlier. Return success without # changing state again, because duplicate delivery is expected. if cursor.rowcount == 0: connection.commit() return '', 204 # Add event-specific database changes here. Keep them after the # deduplication insert and inside this same transaction. cursor.execute('UPDATE users SET balance = balance + %s WHERE nickname = %s', (reward_amount, nickname)) # Commit only after deduplication and event-specific work both succeed. connection.commit() # Log only newly processed real events after the transaction succeeds. app.logger.info('Accepted webhook event %s #%s', event_type, event_id) return '', 204 except Exception: # Roll back partial database work so the event can be retried safely. if connection: connection.rollback() # 500 keeps the delivery failed instead of marking unfinished work as done. abort(500) finally: # Close the database connection. if connection: connection.close() ``` https://gamemonitoring.tr/developers/docs/webhook/vote.md --- # Sistem IP adresleri GAMEMONITORING bu IP adreslerini oyun sunucularını kontrol etmek ve [Webhook isteklerini](https://gamemonitoring.tr/developers/docs/webhook#connect) sisteminize teslim etmek için kullanır. Sunucu, web sitesi, WAF, CDN veya bot protection gelen istekleri sınırlıyorsa bunları allowlist’e ekleyin. ## Ne zaman eklenmeli {#when-needed} - oyun sunucusu yalnızca izinli adreslerden istek kabul ediyorsa; - [Webhook handler](https://gamemonitoring.tr/developers/docs/webhook#handler-requirements) firewall, WAF veya Cloudflare ile korunuyorsa; - bot protection otomatik istekleri engelliyorsa; - hosting sağlayıcısı network kuralları için IP listesi istiyorsa. ## Kullanım örneği {#usage-example} Webhook örneği: handler `https://panel.example.com/gamemonitoring-webhook` adresinde ve domain Cloudflare ile korunuyor. Cloudflare’ın challenge göstermemesi ve [Webhook `POST` isteklerini](https://gamemonitoring.tr/developers/docs/webhook#handler-requirements) engellememesi için GAMEMONITORING IP adreslerini bu domain veya tam path için allowlist’e ekleyin. Oyun sunucusu örneği: firewall query portuna yalnızca güvenilir adreslerden izin veriyor. GAMEMONITORING IP adreslerini query port kuralına ekleyin, yoksa monitoring online durumu ve sunucu durumunu stabil kontrol edemez. ## Allowlist yapılandırma {#allowlist} Yukarıdaki IP adreslerini sistem yöneticinize veya hosting sağlayıcınıza iletin. Kural bu adreslerden oyun sunucunuza veya Webhook handler’a gelen isteklere izin vermelidir. Kural path bazlıysa yalnızca gerekli endpoint ile sınırlayın, örneğin `/gamemonitoring-webhook`. Kural port bazlıysa sadece oyun query portunu veya Webhook alan web-server portunu belirtin. ## Yapılandırmadan sonra doğrulama {#verification} Kuralları değiştirdikten sonra test request veya [test Webhook](https://gamemonitoring.tr/developers/docs/webhook#tests-resend) gönderin ve isteğin artık engellenmediğini kontrol edin. Kontrol başarısızsa firewall, WAF veya Cloudflare loglarını inceleyin. Loglarda source IP, request path ve block reason görünmelidir. Böylece domain, path, port veya kural sırası eksik mi anlaşılır. ## Cloudflare yapılandırması {#cloudflare} Webhook handler Cloudflare arkasındaysa, bu istekler için WAF kontrollerini atlayan bir kurala GAMEMONITORING IP adreslerini ekleyin: 1. Cloudflare dashboard’a giriş yapın. 2. Gerekli domain’i seçin. 3. **Security** bölümünü açın. 4. **WAF** seçin. 5. **Custom rules** açın. 6. **Create rule** tıklayın. 7. Anlaşılır bir ad verin, örneğin **Allow GAMEMONITORING**. 8. **Field** alanında **IP Source Address** seçin. 9. **Operator** alanında **is in** seçin. 10. **Value** alanına listedeki IP adreslerini ekleyin. 11. **Choose action** alanında **Skip** seçin. 12. **WAF components to skip** içinde handler isteklerini engelleyen kontrolleri seçin. 13. **Select order** alanında **First** seçin. 14. **Deploy** tıklayın. Kurulumdan sonra istekler hâlâ engelleniyorsa firewall veya Cloudflare loglarını kontrol edin ve kuralın doğru domain ile handler path’e uygulandığından emin olun. ```http GET https://api.gamemonitoring.tr/pages/system/ips ``` https://gamemonitoring.tr/developers/docs/ips.md