crawlora-bo3 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8fa0f01a4dd4b3dea83c1a4536d5676210242c032fa889c80d248803a8702c29
4
+ data.tar.gz: b4ebf8acf83d23a3231d3b92a8159c9326905516896df66bb2de4caf07684c82
5
+ SHA512:
6
+ metadata.gz: 5805deb3c2ba62aad78d443ddc954525d39a1a9cd46a5c8419e9be60158f36af3af0e7165b0396bbe7ca9857148f9b2bcfbead05f2f9c60c0b8aeeb3042ec115
7
+ data.tar.gz: 6a3e49e756df744b3c558623d0def2313cffc36d13ccb94e45e6558c7f39f8cae809f68dabf2d9a429709e4f115d72cf678e0d6bae63281891014b15a855ad4b
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - Initial focused BO3.gg Ruby client for Crawlora's hosted API.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Crawlora
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # Crawlora BO3.gg API client for Ruby (`crawlora-bo3`)
2
+
3
+ This Ruby gem calls Crawlora's hosted BO3.gg API at `https://api.crawlora.net/api/v1`. It exposes 28 endpoints covering Counter-Strike and Valorant matches, teams, players, tournaments, rankings, news, and statistics; it does not call or scrape BO3.gg directly. Requests require your Crawlora API key and use your account's service plan.
4
+
5
+ ## Install
6
+
7
+ ```ruby
8
+ gem "crawlora-bo3"
9
+ ```
10
+
11
+ Create an account at [crawlora.net](https://crawlora.net/signup?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=bo3-ruby-signup), open the [Crawlora console](https://crawlora.net/app?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=bo3-ruby-console) to get an API key, and set `CRAWLORA_API_KEY` before running the client:
12
+
13
+ ```ruby
14
+ require "json"
15
+ require "crawlora/bo3"
16
+
17
+ client = Crawlora::Bo3::Client.new
18
+ result = client.request("bo3-economy-baseline", JSON.parse("{}"))
19
+ puts result
20
+ client.close
21
+ ```
22
+
23
+ Use an operation-specific method for normal calls. `request(operation_id, params = {}, response_type: :auto)` is available for every operation. `response_type: :text` returns raw response text. This gem includes 28 API operations.
24
+
25
+ ```ruby
26
+ client = Crawlora::Bo3::Client.new(api_key: ENV.fetch("CRAWLORA_API_KEY"), timeout: 30)
27
+ # client.<operation_method>(<endpoint parameters>)
28
+ client.close
29
+ ```
30
+
31
+ Client options include `api_key`, `base_url`, and `timeout`. Ruby stdlib provides the HTTP and JSON support.
32
+
33
+ ## Supported BO3.gg API endpoints
34
+
35
+ Browse every route included in this gem. The [endpoint reference](https://github.com/Crawlora-org/crawlora-bo3/blob/main/docs/usage.md) includes parameter and response details.
36
+
37
+ | Method | Endpoint | API operation | Description |
38
+ | --- | --- | --- | --- |
39
+ | `GET` | `/bo3/economy-baseline` | `bo3-economy-baseline` | BO3.gg CS2 economy baseline |
40
+ | `GET` | `/bo3/forum` | `bo3-forum` | BO3.gg forum threads with category and sort filters |
41
+ | `GET` | `/bo3/forum-categories` | `bo3-forum-categories` | BO3.gg forum categories |
42
+ | `GET` | `/bo3/match` | `bo3-match` | BO3.gg match detail |
43
+ | `GET` | `/bo3/match-games` | `bo3-match-games` | BO3.gg esports match maps with round-by-round results |
44
+ | `GET` | `/bo3/match-history` | `bo3-match-history` | BO3.gg esports match history |
45
+ | `GET` | `/bo3/match-players` | `bo3-match-players` | BO3.gg per-player match statistics |
46
+ | `GET` | `/bo3/news-categories` | `bo3-news-categories` | BO3.gg news categories |
47
+ | `GET` | `/bo3/news-feed` | `bo3-news-feed` | BO3.gg news, articles, wiki and predictions feed |
48
+ | `GET` | `/bo3/player` | `bo3-player` | BO3.gg player profile |
49
+ | `GET` | `/bo3/player-leaderboard` | `bo3-player-leaderboard` | BO3.gg CS2 player leaderboard |
50
+ | `GET` | `/bo3/player-recent-matches` | `bo3-player-recent-matches` | BO3.gg player recent matches |
51
+ | `GET` | `/bo3/player-stats` | `bo3-player-stats` | BO3.gg player statistics |
52
+ | `GET` | `/bo3/records` | `bo3-records` | BO3.gg CS2 records with scope and type filters |
53
+ | `GET` | `/bo3/team` | `bo3-team` | BO3.gg team profile |
54
+ | `GET` | `/bo3/team-prize-money` | `bo3-team-prize-money` | BO3.gg team prize money by period |
55
+ | `GET` | `/bo3/team-ranking-dates` | `bo3-team-ranking-dates` | BO3.gg official ranking dates and regions |
56
+ | `GET` | `/bo3/team-rankings` | `bo3-team-rankings` | BO3.gg team rankings, current and historical |
57
+ | `GET` | `/bo3/team-recent-matches` | `bo3-team-recent-matches` | BO3.gg team recent matches |
58
+ | `GET` | `/bo3/team-stats` | `bo3-team-stats` | BO3.gg team statistics |
59
+ | `GET` | `/bo3/tournament` | `bo3-tournament` | BO3.gg tournament detail |
60
+ | `GET` | `/bo3/tournament-map-pool` | `bo3-tournament-map-pool` | BO3.gg CS2 tournament map pool |
61
+ | `GET` | `/bo3/tournament-mvps` | `bo3-tournament-mvps` | BO3.gg esports tournament MVPs |
62
+ | `GET` | `/bo3/tournament-squads` | `bo3-tournament-squads` | BO3.gg CS2 tournament squads |
63
+ | `GET` | `/bo3/tournament-stages` | `bo3-tournament-stages` | BO3.gg esports tournament stages |
64
+ | `GET` | `/bo3/tournaments` | `bo3-tournaments` | BO3.gg tournament list with filters |
65
+ | `GET` | `/bo3/transfers` | `bo3-transfers` | BO3.gg esports transfer feed |
66
+ | `GET` | `/bo3/valorant-leaderboard` | `bo3-valorant-leaderboard` | BO3.gg Valorant player leaderboard |
67
+
68
+ See [Crawlora](https://crawlora.net/?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=bo3-ruby-homepage), the [API documentation](https://crawlora.net/docs?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=bo3-ruby-api-docs), and [the package repository](https://github.com/Crawlora-org/crawlora-bo3) for account setup, the API operation reference, and release history.
@@ -0,0 +1,308 @@
1
+ require "json"
2
+ require "net/http"
3
+ require "uri"
4
+
5
+ module Crawlora
6
+ module Bo3
7
+ module Errors
8
+ class Error < StandardError
9
+ attr_reader :status, :operation_id, :body
10
+
11
+ def initialize(message, status: nil, operation_id: nil, body: nil)
12
+ super(message)
13
+ @status, @operation_id, @body = status, operation_id, body
14
+ end
15
+ end
16
+ class ClientError < Error; end
17
+ class ServerError < Error; end
18
+ class NetworkError < Error; end
19
+ end
20
+
21
+ OPERATIONS = JSON.parse(<<~'JSON').freeze
22
+ {"bo3-economy-baseline": {"bodyParam": null, "bodyRequired": false, "id": "bo3-economy-baseline", "method": "GET", "params": [], "path": "/bo3/economy-baseline", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "bo3-forum": {"bodyParam": null, "bodyRequired": false, "id": "bo3-forum", "method": "GET", "params": [{"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb; defaults to cs2", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"description": "Forum category id from bo3-forum-categories, for example 4", "in": "query", "minimum": 1, "name": "category", "type": "integer"}, {"description": "Order; one of activity, newest, comments, rating; defaults to activity", "enum": ["activity", "newest", "comments", "rating"], "in": "query", "name": "sort", "type": "string"}, {"description": "Zero-based offset; defaults to 0", "in": "query", "minimum": 0, "name": "offset", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 20", "in": "query", "maximum": 100, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/forum", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"in": "query", "name": "category", "type": "integer"}, {"enum": ["activity", "newest", "comments", "rating"], "in": "query", "name": "sort", "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-forum-categories": {"bodyParam": null, "bodyRequired": false, "id": "bo3-forum-categories", "method": "GET", "params": [{"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb; defaults to cs2", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}], "path": "/bo3/forum-categories", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-match": {"bodyParam": null, "bodyRequired": false, "id": "bo3-match", "method": "GET", "params": [{"description": "Match slug from bo3-match-history, for example vitality-vs-natus-vincere-27-10-2026", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "vitality-vs-natus-vincere-27-10-2026"}], "path": "/bo3/match", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-match-games": {"bodyParam": null, "bodyRequired": false, "id": "bo3-match-games", "method": "GET", "params": [{"description": "Numeric BO3 match id (the id of a bo3-match-history row)", "in": "query", "minimum": 1, "name": "match_id", "required": true, "type": "integer", "x-example": 132243}], "path": "/bo3/match-games", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "match_id", "required": true, "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-match-history": {"bodyParam": null, "bodyRequired": false, "id": "bo3-match-history", "method": "GET", "params": [{"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb; defaults to cs2", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"description": "Match status; one of finished, defwin, upcoming, current, canceled, postponed; defaults to finished and defwin together", "enum": ["finished", "defwin", "upcoming", "current", "canceled", "postponed"], "in": "query", "name": "status", "type": "string"}, {"description": "Tournament tier; one of s, a, b, c, d", "enum": ["s", "a", "b", "c", "d"], "in": "query", "name": "tier", "type": "string"}, {"description": "First start day, YYYY-MM-DD (UTC, inclusive)", "in": "query", "name": "from", "type": "string", "x-example": "2026-10-01"}, {"description": "Last start day, YYYY-MM-DD (UTC, inclusive)", "in": "query", "name": "to", "type": "string", "x-example": "2026-10-27"}, {"description": "Order by start time; one of newest, oldest; defaults to newest", "enum": ["newest", "oldest"], "in": "query", "name": "sort", "type": "string"}, {"description": "Zero-based offset; defaults to 0", "in": "query", "minimum": 0, "name": "offset", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 20", "in": "query", "maximum": 100, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/match-history", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"enum": ["finished", "defwin", "upcoming", "current", "canceled", "postponed"], "in": "query", "name": "status", "type": "string"}, {"enum": ["s", "a", "b", "c", "d"], "in": "query", "name": "tier", "type": "string"}, {"in": "query", "name": "from", "type": "string"}, {"in": "query", "name": "to", "type": "string"}, {"enum": ["newest", "oldest"], "in": "query", "name": "sort", "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-match-players": {"bodyParam": null, "bodyRequired": false, "id": "bo3-match-players", "method": "GET", "params": [{"description": "Match slug from bo3-match-history, for example vitality-vs-natus-vincere-27-10-2026", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "vitality-vs-natus-vincere-27-10-2026"}], "path": "/bo3/match-players", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-news-categories": {"bodyParam": null, "bodyRequired": false, "id": "bo3-news-categories", "method": "GET", "params": [], "path": "/bo3/news-categories", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "bo3-news-feed": {"bodyParam": null, "bodyRequired": false, "id": "bo3-news-feed", "method": "GET", "params": [{"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb, games (general gaming news); defaults to cs2", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb", "games"], "in": "query", "name": "game", "type": "string"}, {"description": "Editorial section; one of news, article, wiki, predictions, reviews (game reviews, game=games only); defaults to news", "enum": ["news", "article", "wiki", "predictions", "reviews"], "in": "query", "name": "section", "type": "string"}, {"description": "Tag slug such as team-liquid or pgl-masters-bucharest-2026 (team, player, tournament or topic tag); an unknown tag returns an empty list", "in": "query", "name": "tag", "type": "string", "x-example": "team-liquid"}, {"description": "Language of the items; one of en, ru, pt, es, de, fr, tr, pl, id, vi, ja, ko, ua, ms, tl, da; defaults to en", "enum": ["en", "ru", "pt", "es", "de", "fr", "tr", "pl", "id", "vi", "ja", "ko", "ua", "ms", "tl", "da"], "in": "query", "name": "locale", "type": "string"}, {"description": "Category id from bo3-news-categories, for example 38 (Predictions)", "in": "query", "minimum": 1, "name": "category", "type": "integer"}, {"description": "Order by publish time; one of newest, oldest; defaults to newest", "enum": ["newest", "oldest"], "in": "query", "name": "sort", "type": "string"}, {"description": "Zero-based offset; defaults to 0", "in": "query", "minimum": 0, "name": "offset", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 20", "in": "query", "maximum": 100, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/news-feed", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb", "games"], "in": "query", "name": "game", "type": "string"}, {"enum": ["news", "article", "wiki", "predictions", "reviews"], "in": "query", "name": "section", "type": "string"}, {"in": "query", "name": "tag", "type": "string"}, {"enum": ["en", "ru", "pt", "es", "de", "fr", "tr", "pl", "id", "vi", "ja", "ko", "ua", "ms", "tl", "da"], "in": "query", "name": "locale", "type": "string"}, {"in": "query", "name": "category", "type": "integer"}, {"enum": ["newest", "oldest"], "in": "query", "name": "sort", "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-player": {"bodyParam": null, "bodyRequired": false, "id": "bo3-player", "method": "GET", "params": [{"description": "Player slug, for example donk", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "donk"}, {"description": "Game the player must belong to; one of cs2, valorant, lol, dota2, r6siege, mlbb", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}], "path": "/bo3/player", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}, {"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-player-leaderboard": {"bodyParam": null, "bodyRequired": false, "id": "bo3-player-leaderboard", "method": "GET", "params": [{"description": "First day, YYYY-MM-DD (UTC); defaults to six months before to", "in": "query", "name": "from", "type": "string", "x-example": "2026-04-28"}, {"description": "Last day, YYYY-MM-DD (UTC); defaults to today", "in": "query", "name": "to", "type": "string", "x-example": "2026-10-28"}, {"description": "Tournament tier of the games counted; one of s, a, b, c, d", "enum": ["s", "a", "b", "c", "d"], "in": "query", "name": "tier", "type": "string"}, {"description": "Stat to rank by; one of rating, kd, kills, damage, assists, headshots, games, rounds; defaults to rating", "enum": ["rating", "kd", "kills", "damage", "assists", "headshots", "games", "rounds"], "in": "query", "name": "sort", "type": "string"}, {"description": "Direction; one of desc, asc; defaults to desc", "enum": ["desc", "asc"], "in": "query", "name": "order", "type": "string"}, {"description": "Zero-based offset; defaults to 0", "in": "query", "minimum": 0, "name": "offset", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 20", "in": "query", "maximum": 100, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/player-leaderboard", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "from", "type": "string"}, {"in": "query", "name": "to", "type": "string"}, {"enum": ["s", "a", "b", "c", "d"], "in": "query", "name": "tier", "type": "string"}, {"enum": ["rating", "kd", "kills", "damage", "assists", "headshots", "games", "rounds"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["desc", "asc"], "in": "query", "name": "order", "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-player-recent-matches": {"bodyParam": null, "bodyRequired": false, "id": "bo3-player-recent-matches", "method": "GET", "params": [{"description": "Player slug, for example donk", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "donk"}, {"description": "Opposing team slug, for example mouz-cs2", "in": "query", "name": "opponent", "type": "string"}, {"description": "Tournament slug from bo3-tournaments", "in": "query", "name": "tournament", "type": "string"}, {"default": 10, "description": "Newest matches to return, 1 to 30, default 10", "in": "query", "maximum": 30, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/player-recent-matches", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}, {"in": "query", "name": "opponent", "type": "string"}, {"in": "query", "name": "tournament", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-player-stats": {"bodyParam": null, "bodyRequired": false, "id": "bo3-player-stats", "method": "GET", "params": [{"description": "Player slug, for example donk", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "donk"}, {"description": "Statistics view; one of general, maps, accuracy; defaults to general", "enum": ["general", "maps", "accuracy"], "in": "query", "name": "kind", "type": "string"}, {"description": "First day, YYYY-MM-DD; defaults to six months before to", "in": "query", "name": "from", "type": "string", "x-example": "2026-04-28"}, {"description": "Last day, YYYY-MM-DD; defaults to today (UTC)", "in": "query", "name": "to", "type": "string", "x-example": "2026-10-28"}], "path": "/bo3/player-stats", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}, {"enum": ["general", "maps", "accuracy"], "in": "query", "name": "kind", "type": "string"}, {"in": "query", "name": "from", "type": "string"}, {"in": "query", "name": "to", "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-records": {"bodyParam": null, "bodyRequired": false, "id": "bo3-records", "method": "GET", "params": [{"description": "First day, YYYY-MM-DD (UTC); unscoped default is six months before to", "in": "query", "name": "from", "type": "string", "x-example": "2026-04-28"}, {"description": "Last day, YYYY-MM-DD (UTC); unscoped default is today", "in": "query", "name": "to", "type": "string", "x-example": "2026-10-28"}, {"description": "Record type such as game_player_headshots or game_round_player_clutch; the types present are listed in the response", "in": "query", "name": "record_type", "type": "string"}, {"description": "Match slug to scope the records to one match", "in": "query", "name": "match", "type": "string", "x-example": "vitality-vs-natus-vincere-27-10-2026"}, {"description": "Tournament slug to scope the records to one tournament", "in": "query", "name": "tournament", "type": "string", "x-example": "pgl-masters-bucharest-2026"}, {"description": "Team slug to scope the records to one team", "in": "query", "name": "team", "type": "string", "x-example": "vitality"}, {"description": "Player slug to scope the records to one player", "in": "query", "name": "player", "type": "string", "x-example": "donk"}, {"description": "Order by game time; one of newest, oldest; defaults to newest", "enum": ["newest", "oldest"], "in": "query", "name": "sort", "type": "string"}, {"description": "Zero-based offset; defaults to 0", "in": "query", "minimum": 0, "name": "offset", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 20", "in": "query", "maximum": 100, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/records", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "from", "type": "string"}, {"in": "query", "name": "to", "type": "string"}, {"in": "query", "name": "record_type", "type": "string"}, {"in": "query", "name": "match", "type": "string"}, {"in": "query", "name": "tournament", "type": "string"}, {"in": "query", "name": "team", "type": "string"}, {"in": "query", "name": "player", "type": "string"}, {"enum": ["newest", "oldest"], "in": "query", "name": "sort", "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-team": {"bodyParam": null, "bodyRequired": false, "id": "bo3-team", "method": "GET", "params": [{"description": "Team slug, for example vitality", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "vitality"}, {"description": "Game the team must belong to; one of cs2, valorant, lol, dota2, r6siege, mlbb", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}], "path": "/bo3/team", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}, {"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-team-prize-money": {"bodyParam": null, "bodyRequired": false, "id": "bo3-team-prize-money", "method": "GET", "params": [{"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb; defaults to cs2", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"description": "First day, YYYY-MM-DD (UTC); defaults to six months before to", "in": "query", "name": "from", "type": "string", "x-example": "2026-04-28"}, {"description": "Last day, YYYY-MM-DD (UTC); defaults to today", "in": "query", "name": "to", "type": "string", "x-example": "2026-10-28"}, {"description": "Zero-based offset; defaults to 0", "in": "query", "minimum": 0, "name": "offset", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 20", "in": "query", "maximum": 100, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/team-prize-money", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"in": "query", "name": "from", "type": "string"}, {"in": "query", "name": "to", "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-team-ranking-dates": {"bodyParam": null, "bodyRequired": false, "id": "bo3-team-ranking-dates", "method": "GET", "params": [{"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb; defaults to cs2", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}], "path": "/bo3/team-ranking-dates", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-team-rankings": {"bodyParam": null, "bodyRequired": false, "id": "bo3-team-rankings", "method": "GET", "params": [{"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb; defaults to cs2", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"description": "Region label for the game as listed by bo3-team-ranking-dates, for example Europe; omit for worldwide", "in": "query", "name": "region", "type": "string"}, {"description": "Ranking day, YYYY-MM-DD; defaults to the latest", "in": "query", "name": "date", "type": "string", "x-example": "2026-10-05"}, {"description": "1-based page; defaults to 1", "in": "query", "minimum": 1, "name": "page", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 30", "in": "query", "maximum": 100, "minimum": 1, "name": "per_page", "type": "integer"}], "path": "/bo3/team-rankings", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"in": "query", "name": "region", "type": "string"}, {"in": "query", "name": "date", "type": "string"}, {"in": "query", "name": "page", "type": "integer"}, {"in": "query", "name": "per_page", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-team-recent-matches": {"bodyParam": null, "bodyRequired": false, "id": "bo3-team-recent-matches", "method": "GET", "params": [{"description": "Team slug, for example vitality", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "vitality"}, {"description": "Opposing team slug for head-to-head matches, for example natus-vincere", "in": "query", "name": "opponent", "type": "string"}, {"description": "Tournament slug from bo3-tournaments", "in": "query", "name": "tournament", "type": "string"}, {"default": 10, "description": "Newest matches to return, 1 to 30, default 10", "in": "query", "maximum": 30, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/team-recent-matches", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}, {"in": "query", "name": "opponent", "type": "string"}, {"in": "query", "name": "tournament", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-team-stats": {"bodyParam": null, "bodyRequired": false, "id": "bo3-team-stats", "method": "GET", "params": [{"description": "Team slug, for example vitality", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "vitality"}, {"description": "Statistics view; one of general, advanced, accuracy, economy, map-pool; defaults to general", "enum": ["general", "advanced", "accuracy", "economy", "map-pool"], "in": "query", "name": "kind", "type": "string"}, {"description": "First day, YYYY-MM-DD; defaults to six months before to", "in": "query", "name": "from", "type": "string", "x-example": "2026-04-28"}, {"description": "Last day, YYYY-MM-DD; defaults to today (UTC)", "in": "query", "name": "to", "type": "string", "x-example": "2026-10-28"}], "path": "/bo3/team-stats", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}, {"enum": ["general", "advanced", "accuracy", "economy", "map-pool"], "in": "query", "name": "kind", "type": "string"}, {"in": "query", "name": "from", "type": "string"}, {"in": "query", "name": "to", "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-tournament": {"bodyParam": null, "bodyRequired": false, "id": "bo3-tournament", "method": "GET", "params": [{"description": "Tournament slug from bo3-tournaments, for example pgl-masters-bucharest-2026", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "pgl-masters-bucharest-2026"}, {"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb; defaults to cs2", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}], "path": "/bo3/tournament", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}, {"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-tournament-map-pool": {"bodyParam": null, "bodyRequired": false, "id": "bo3-tournament-map-pool", "method": "GET", "params": [{"description": "CS2 tournament slug from bo3-tournaments, for example pgl-masters-bucharest-2026", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "pgl-masters-bucharest-2026"}], "path": "/bo3/tournament-map-pool", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-tournament-mvps": {"bodyParam": null, "bodyRequired": false, "id": "bo3-tournament-mvps", "method": "GET", "params": [{"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb; defaults to every game", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"description": "Zero-based offset; defaults to 0", "in": "query", "minimum": 0, "name": "offset", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 20", "in": "query", "maximum": 100, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/tournament-mvps", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-tournament-squads": {"bodyParam": null, "bodyRequired": false, "id": "bo3-tournament-squads", "method": "GET", "params": [{"description": "CS2 tournament slug from bo3-tournaments, for example pgl-masters-bucharest-2026", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "pgl-masters-bucharest-2026"}], "path": "/bo3/tournament-squads", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "slug", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-tournament-stages": {"bodyParam": null, "bodyRequired": false, "id": "bo3-tournament-stages", "method": "GET", "params": [{"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb; defaults to cs2", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"description": "Tournament slug from bo3-tournaments, for example pgl-masters-bucharest-2026", "in": "query", "name": "slug", "required": true, "type": "string", "x-example": "pgl-masters-bucharest-2026"}], "path": "/bo3/tournament-stages", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"in": "query", "name": "slug", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "bo3-tournaments": {"bodyParam": null, "bodyRequired": false, "id": "bo3-tournaments", "method": "GET", "params": [{"description": "Game; one of cs2, valorant, lol, dota2, r6siege, mlbb; defaults to cs2", "enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"description": "Tournament status; one of current, upcoming, finished, canceled, postponed", "enum": ["current", "upcoming", "finished", "canceled", "postponed"], "in": "query", "name": "status", "type": "string"}, {"description": "Tournament tier; one of s, a, b, c, d", "enum": ["s", "a", "b", "c", "d"], "in": "query", "name": "tier", "type": "string"}, {"description": "Event type; one of lan, online", "enum": ["lan", "online"], "in": "query", "name": "event_type", "type": "string"}, {"description": "Order; one of newest, oldest, prize; defaults to newest", "enum": ["newest", "oldest", "prize"], "in": "query", "name": "sort", "type": "string"}, {"description": "Zero-based offset; defaults to 0", "in": "query", "minimum": 0, "name": "offset", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 20", "in": "query", "maximum": 100, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/tournaments", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "valorant", "lol", "dota2", "r6siege", "mlbb"], "in": "query", "name": "game", "type": "string"}, {"enum": ["current", "upcoming", "finished", "canceled", "postponed"], "in": "query", "name": "status", "type": "string"}, {"enum": ["s", "a", "b", "c", "d"], "in": "query", "name": "tier", "type": "string"}, {"enum": ["lan", "online"], "in": "query", "name": "event_type", "type": "string"}, {"enum": ["newest", "oldest", "prize"], "in": "query", "name": "sort", "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-transfers": {"bodyParam": null, "bodyRequired": false, "id": "bo3-transfers", "method": "GET", "params": [{"description": "BO3 team id; transfers into or out of this team", "in": "query", "minimum": 1, "name": "team_id", "type": "integer"}, {"description": "BO3 player id; this person's transfers", "in": "query", "minimum": 1, "name": "player_id", "type": "integer"}, {"description": "Transfer action; one of join, change, leave", "enum": ["join", "change", "leave"], "in": "query", "name": "action", "type": "string"}, {"description": "Role; one of player, coach", "enum": ["player", "coach"], "in": "query", "name": "role", "type": "string"}, {"description": "Order by date; one of newest, oldest; defaults to newest", "enum": ["newest", "oldest"], "in": "query", "name": "sort", "type": "string"}, {"description": "Zero-based offset; defaults to 0", "in": "query", "minimum": 0, "name": "offset", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 20", "in": "query", "maximum": 100, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/transfers", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "team_id", "type": "integer"}, {"in": "query", "name": "player_id", "type": "integer"}, {"enum": ["join", "change", "leave"], "in": "query", "name": "action", "type": "string"}, {"enum": ["player", "coach"], "in": "query", "name": "role", "type": "string"}, {"enum": ["newest", "oldest"], "in": "query", "name": "sort", "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "bo3-valorant-leaderboard": {"bodyParam": null, "bodyRequired": false, "id": "bo3-valorant-leaderboard", "method": "GET", "params": [{"description": "First day, YYYY-MM-DD (UTC); defaults to six months before to", "in": "query", "name": "from", "type": "string", "x-example": "2026-04-28"}, {"description": "Last day, YYYY-MM-DD (UTC); defaults to today", "in": "query", "name": "to", "type": "string", "x-example": "2026-10-28"}, {"description": "Stat to rank by; one of acs, kills, deaths, damage, assists, first_kills, clutches, first_duels, games, rounds; defaults to acs", "enum": ["acs", "kills", "deaths", "damage", "assists", "first_kills", "clutches", "first_duels", "games", "rounds"], "in": "query", "name": "sort", "type": "string"}, {"description": "Direction; one of desc, asc; defaults to desc", "enum": ["desc", "asc"], "in": "query", "name": "order", "type": "string"}, {"description": "Zero-based offset; defaults to 0", "in": "query", "minimum": 0, "name": "offset", "type": "integer"}, {"description": "Page size, 1 to 100; defaults to 20", "in": "query", "maximum": 100, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/bo3/valorant-leaderboard", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "from", "type": "string"}, {"in": "query", "name": "to", "type": "string"}, {"enum": ["acs", "kills", "deaths", "damage", "assists", "first_kills", "clutches", "first_duels", "games", "rounds"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["desc", "asc"], "in": "query", "name": "order", "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}}
23
+ JSON
24
+ OPERATION_IDS = JSON.parse(<<~'JSON').freeze
25
+ ["bo3-economy-baseline", "bo3-forum", "bo3-forum-categories", "bo3-match", "bo3-match-games", "bo3-match-history", "bo3-match-players", "bo3-news-categories", "bo3-news-feed", "bo3-player", "bo3-player-leaderboard", "bo3-player-recent-matches", "bo3-player-stats", "bo3-records", "bo3-team", "bo3-team-prize-money", "bo3-team-ranking-dates", "bo3-team-rankings", "bo3-team-recent-matches", "bo3-team-stats", "bo3-tournament", "bo3-tournament-map-pool", "bo3-tournament-mvps", "bo3-tournament-squads", "bo3-tournament-stages", "bo3-tournaments", "bo3-transfers", "bo3-valorant-leaderboard"]
26
+ JSON
27
+ OPERATION_COUNT = OPERATION_IDS.length
28
+
29
+ class Client
30
+ attr_reader :base_url
31
+
32
+ def initialize(api_key: ENV["CRAWLORA_API_KEY"], base_url: "https://api.crawlora.net/api/v1", timeout: 30, user_agent: "crawlora-bo3-ruby/0.1.0", transport: nil)
33
+ @api_key = api_key
34
+ @base_url = base_url.to_s.sub(%r{/+$}, "")
35
+ @timeout = Float(timeout)
36
+ @user_agent = user_agent
37
+ @transport = transport
38
+ @closed = false
39
+ end
40
+
41
+ def request(operation_id, params = {}, response_type: :auto)
42
+ raise Errors::ClientError, "client is closed" if @closed
43
+ operation_id = operation_id.to_s
44
+ operation = OPERATIONS[operation_id]
45
+ raise Errors::ClientError.new("unknown operation: #{operation_id}", operation_id: operation_id) unless operation
46
+ raise Errors::ClientError.new("Crawlora API key is required", operation_id: operation_id) if @api_key.nil? || @api_key.to_s.empty?
47
+ normalized = params.each_with_object({}) { |(key, value), out| out[key.to_s] = value }
48
+ payload = request_body(operation, normalized)
49
+ url = build_url(operation, normalized)
50
+ uri = URI.parse(url)
51
+ request = operation["method"] == "POST" ? Net::HTTP::Post.new(uri) : Net::HTTP::Get.new(uri)
52
+ unless payload.nil?
53
+ request.body = payload
54
+ request["Content-Type"] = "application/json"
55
+ end
56
+ request["x-api-key"] = @api_key
57
+ request["User-Agent"] = @user_agent
58
+ request["Accept"] = operation["produces"].include?("text/plain") ? "application/json, text/plain" : "application/json"
59
+ begin
60
+ if @transport
61
+ response = if operation["method"] == "POST"
62
+ @transport.call(url, request.to_hash, @timeout, "POST", payload)
63
+ else
64
+ @transport.call(url, request.to_hash, @timeout)
65
+ end
66
+ status = Integer(response.fetch(:status) { response.fetch("status") })
67
+ body = response.fetch(:body) { response.fetch("body", "") }
68
+ headers = response.fetch(:headers) { response.fetch("headers", {}) }
69
+ content_type = headers["content-type"] || headers["Content-Type"]
70
+ else
71
+ http = Net::HTTP.new(uri.host, uri.port)
72
+ http.use_ssl = uri.scheme == "https"
73
+ http.open_timeout = @timeout
74
+ http.read_timeout = @timeout
75
+ response = http.start { |connection| connection.request(request) }
76
+ status = response.code.to_i
77
+ body = response.body
78
+ content_type = response["content-type"]
79
+ end
80
+ rescue Timeout::Error, SocketError, SystemCallError, IOError, EOFError, Net::HTTPBadResponse, Net::ProtocolError, OpenSSL::SSL::SSLError => error
81
+ raise Errors::NetworkError.new("Crawlora request failed: #{error.message}", operation_id: operation_id)
82
+ end
83
+ unless status >= 200 && status < 300
84
+ klass = status >= 500 ? Errors::ServerError : Errors::ClientError
85
+ raise klass.new("Crawlora returned HTTP #{status}", status: status, operation_id: operation_id, body: body)
86
+ end
87
+ parse_response(body, content_type, operation, normalized, response_type)
88
+ end
89
+
90
+ def close
91
+ @closed = true
92
+ end
93
+
94
+ def closed?
95
+ @closed
96
+ end
97
+
98
+ def with
99
+ return self unless block_given?
100
+ yield self
101
+ ensure
102
+ close if block_given?
103
+ end
104
+
105
+ def self.operation_count
106
+ OPERATION_COUNT
107
+ end
108
+
109
+ def self.operation_ids
110
+ OPERATION_IDS
111
+ end
112
+
113
+ def self.operations
114
+ OPERATIONS
115
+ end
116
+
117
+ define_method('economy_baseline') do |**params|
118
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
119
+ request('bo3-economy-baseline', params, response_type: response_type)
120
+ end
121
+ define_method('forum') do |**params|
122
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
123
+ request('bo3-forum', params, response_type: response_type)
124
+ end
125
+ define_method('forum_categories') do |**params|
126
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
127
+ request('bo3-forum-categories', params, response_type: response_type)
128
+ end
129
+ define_method('match') do |**params|
130
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
131
+ request('bo3-match', params, response_type: response_type)
132
+ end
133
+ define_method('match_games') do |**params|
134
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
135
+ request('bo3-match-games', params, response_type: response_type)
136
+ end
137
+ define_method('match_history') do |**params|
138
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
139
+ request('bo3-match-history', params, response_type: response_type)
140
+ end
141
+ define_method('match_players') do |**params|
142
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
143
+ request('bo3-match-players', params, response_type: response_type)
144
+ end
145
+ define_method('news_categories') do |**params|
146
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
147
+ request('bo3-news-categories', params, response_type: response_type)
148
+ end
149
+ define_method('news_feed') do |**params|
150
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
151
+ request('bo3-news-feed', params, response_type: response_type)
152
+ end
153
+ define_method('player') do |**params|
154
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
155
+ request('bo3-player', params, response_type: response_type)
156
+ end
157
+ define_method('player_leaderboard') do |**params|
158
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
159
+ request('bo3-player-leaderboard', params, response_type: response_type)
160
+ end
161
+ define_method('player_recent_matches') do |**params|
162
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
163
+ request('bo3-player-recent-matches', params, response_type: response_type)
164
+ end
165
+ define_method('player_stats') do |**params|
166
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
167
+ request('bo3-player-stats', params, response_type: response_type)
168
+ end
169
+ define_method('records') do |**params|
170
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
171
+ request('bo3-records', params, response_type: response_type)
172
+ end
173
+ define_method('team') do |**params|
174
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
175
+ request('bo3-team', params, response_type: response_type)
176
+ end
177
+ define_method('team_prize_money') do |**params|
178
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
179
+ request('bo3-team-prize-money', params, response_type: response_type)
180
+ end
181
+ define_method('team_ranking_dates') do |**params|
182
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
183
+ request('bo3-team-ranking-dates', params, response_type: response_type)
184
+ end
185
+ define_method('team_rankings') do |**params|
186
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
187
+ request('bo3-team-rankings', params, response_type: response_type)
188
+ end
189
+ define_method('team_recent_matches') do |**params|
190
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
191
+ request('bo3-team-recent-matches', params, response_type: response_type)
192
+ end
193
+ define_method('team_stats') do |**params|
194
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
195
+ request('bo3-team-stats', params, response_type: response_type)
196
+ end
197
+ define_method('tournament') do |**params|
198
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
199
+ request('bo3-tournament', params, response_type: response_type)
200
+ end
201
+ define_method('tournament_map_pool') do |**params|
202
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
203
+ request('bo3-tournament-map-pool', params, response_type: response_type)
204
+ end
205
+ define_method('tournament_mvps') do |**params|
206
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
207
+ request('bo3-tournament-mvps', params, response_type: response_type)
208
+ end
209
+ define_method('tournament_squads') do |**params|
210
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
211
+ request('bo3-tournament-squads', params, response_type: response_type)
212
+ end
213
+ define_method('tournament_stages') do |**params|
214
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
215
+ request('bo3-tournament-stages', params, response_type: response_type)
216
+ end
217
+ define_method('tournaments') do |**params|
218
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
219
+ request('bo3-tournaments', params, response_type: response_type)
220
+ end
221
+ define_method('transfers') do |**params|
222
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
223
+ request('bo3-transfers', params, response_type: response_type)
224
+ end
225
+ define_method('valorant_leaderboard') do |**params|
226
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
227
+ request('bo3-valorant-leaderboard', params, response_type: response_type)
228
+ end
229
+
230
+ private
231
+
232
+ # POST operations take their JSON body under the body parameter name or "body".
233
+ def request_body(operation, params)
234
+ name = operation["bodyParam"]
235
+ return nil if name.nil?
236
+ value = params.key?(name) ? params[name] : params["body"]
237
+ if value.nil?
238
+ raise Errors::ClientError.new("missing request body: #{name}", operation_id: operation["id"]) if operation["bodyRequired"]
239
+ return nil
240
+ end
241
+ value.is_a?(String) ? value : JSON.generate(value)
242
+ end
243
+
244
+ def build_url(operation, params)
245
+ known = operation["params"].map { |param| param["name"] }
246
+ known << "body" if operation["bodyParam"]
247
+ unknown = params.keys - known
248
+ raise Errors::ClientError.new("unknown parameters: #{unknown.join(', ')}", operation_id: operation["id"]) unless unknown.empty?
249
+ path = operation["path"].dup
250
+ operation["params"].select { |param| param["in"] == "path" }.each do |param|
251
+ value = params[param["name"]]
252
+ raise Errors::ClientError.new("missing path parameter: #{param['name']}", operation_id: operation["id"]) if value.nil?
253
+ path.sub!("{" + param["name"] + "}", percent_encode(value.to_s))
254
+ end
255
+ pairs = []
256
+ operation["queryParams"].each do |param|
257
+ name = param["name"]
258
+ value = params.key?(name) ? params[name] : param["default"]
259
+ if value.nil?
260
+ raise Errors::ClientError.new("missing query parameter: #{name}", operation_id: operation["id"]) if param["required"]
261
+ next
262
+ end
263
+ enum_values = param["enum"] || (param["items"] && param["items"]["enum"])
264
+ if enum_values && !(value.is_a?(Array) ? value : [value]).all? { |item| enum_values.map(&:to_s).include?(item.to_s) }
265
+ raise Errors::ClientError.new("invalid value for #{name}", operation_id: operation["id"])
266
+ end
267
+ if value.is_a?(Array)
268
+ format = param["collectionFormat"] || "csv"
269
+ if format == "multi"
270
+ value.each { |item| pairs << [name, scalar(item)] }
271
+ else
272
+ separator = {"csv" => ",", "ssv" => " ", "tsv" => "\t", "pipes" => "|"}[format] || ","
273
+ pairs << [name, value.map { |item| scalar(item) }.join(separator)]
274
+ end
275
+ else
276
+ pairs << [name, scalar(value)]
277
+ end
278
+ end
279
+ query = pairs.map { |name, value| "#{percent_encode(name)}=#{percent_encode(value)}" }.join("&")
280
+ @base_url + path + (query.empty? ? "" : "?" + query)
281
+ end
282
+
283
+ def scalar(value)
284
+ value == true ? "true" : (value == false ? "false" : value.to_s)
285
+ end
286
+
287
+ def percent_encode(value)
288
+ URI::DEFAULT_PARSER.escape(value.to_s, /[^A-Za-z0-9\-._~]/)
289
+ end
290
+
291
+ def parse_response(body, content_type, operation, params, response_type)
292
+ type = response_type.to_s
293
+ raise Errors::ClientError.new("response_type must be auto, json, or text", operation_id: operation["id"]) unless %w[auto json text].include?(type)
294
+ format = operation["params"].find { |param| param["name"] == "format" }
295
+ text_formats = format && format["enum"] ? format["enum"].reject { |value| %w[json application/json].include?(value.to_s.downcase) } : []
296
+ raw_format = params["format"] && text_formats.include?(params["format"].to_s)
297
+ json_format = format && format["enum"] && format["enum"].any? { |value| %w[json application/json].include?(value.to_s.downcase) } && %w[json application/json].include?(params["format"].to_s.downcase)
298
+ is_json = json_format || content_type.to_s.downcase.include?("json") || operation["produces"] == ["application/json"]
299
+ return body if type == "text" || raw_format || (type == "auto" && !is_json)
300
+ JSON.parse(body)
301
+ rescue JSON::ParserError => error
302
+ raise Errors::Error.new("invalid JSON response from Crawlora: #{error.message}", operation_id: operation["id"], body: body)
303
+ end
304
+
305
+ public
306
+ end
307
+ end
308
+ end
@@ -0,0 +1,5 @@
1
+ module Crawlora
2
+ module Bo3
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require_relative "bo3/version"
2
+ require_relative "bo3/client"
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crawlora-bo3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Crawlora
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-10-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client for Crawlora's hosted BO3.gg API. Covers Counter-Strike and
14
+ Valorant matches, teams, players, tournaments, rankings, news, and statistics across
15
+ 28 endpoints.
16
+ email:
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - LICENSE
23
+ - README.md
24
+ - lib/crawlora/bo3.rb
25
+ - lib/crawlora/bo3/client.rb
26
+ - lib/crawlora/bo3/version.rb
27
+ homepage: https://crawlora.net/?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=bo3-ruby-homepage
28
+ licenses:
29
+ - MIT
30
+ metadata:
31
+ source_code_uri: https://github.com/Crawlora-org/crawlora-bo3
32
+ documentation_uri: https://github.com/Crawlora-org/crawlora-bo3/blob/main/ruby/README.md
33
+ rubygems_mfa_required: 'true'
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '2.6'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.4.19
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: BO3.gg API client for Crawlora (28 endpoints)
53
+ test_files: []