crawlora-vlr 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: 559a5cc56f47de5d17a60218d0364f28d1d2b33d1b3735a8bfeafde1f2c778d7
4
+ data.tar.gz: 35bd29c8fa02abd208ba1db1728539677c850c1e2da7db128a2ab274b8522b30
5
+ SHA512:
6
+ metadata.gz: 82dfe151fe74e9fc354c5cafa10803db96ea0294c7219670e85667d29e1176554f51700d8c7c0ce5f6a640649fdd03e338ba7da0171a26518f3f7ce2045776f8
7
+ data.tar.gz: faab5953fd375ff7780eae2b0005c5c2208c0f34bc03f80cfc939319e41bf7575a0ca2f921dbfcab34a556217b6fdcb18c1c0d14fc8756e58e52d30532bd9b44
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - Initial focused VLR.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,63 @@
1
+ # Crawlora VLR.gg API client for Ruby (`crawlora-vlr`)
2
+
3
+ This Ruby gem calls Crawlora's hosted VLR.gg API at `https://api.crawlora.net/api/v1`. It exposes 23 endpoints covering Valorant matches, events, results, rankings, statistics, news, and forum data; it does not call or scrape VLR.gg directly. Requests require your Crawlora API key and use your account's service plan.
4
+
5
+ ## Install
6
+
7
+ ```ruby
8
+ gem "crawlora-vlr"
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=vlr-ruby-signup), open the [Crawlora console](https://crawlora.net/app?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=vlr-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/vlr"
16
+
17
+ client = Crawlora::Vlr::Client.new
18
+ result = client.request("vlr-search", JSON.parse("{\"q\": \"sample\"}"))
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 23 API operations.
24
+
25
+ ```ruby
26
+ client = Crawlora::Vlr::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 VLR.gg API endpoints
34
+
35
+ Browse every route included in this gem. The [endpoint reference](https://github.com/Crawlora-org/crawlora-vlr/blob/main/docs/usage.md) includes parameter and response details.
36
+
37
+ | Method | Endpoint | API operation | Description |
38
+ | --- | --- | --- | --- |
39
+ | `GET` | `/vlr/event` | `vlr-event` | VLR.gg Valorant event detail and participating teams |
40
+ | `GET` | `/vlr/event-agents` | `vlr-event-agents` | VLR.gg Valorant event agent pick rates by map |
41
+ | `GET` | `/vlr/event-matches` | `vlr-event-matches` | VLR.gg Valorant event match list |
42
+ | `GET` | `/vlr/event-stats` | `vlr-event-stats` | VLR.gg Valorant event player statistics |
43
+ | `GET` | `/vlr/events` | `vlr-events` | VLR.gg Valorant events |
44
+ | `GET` | `/vlr/forum-categories` | `vlr-forum-categories` | VLR.gg forum categories |
45
+ | `GET` | `/vlr/forum-threads` | `vlr-forum-threads` | VLR.gg forum thread list |
46
+ | `GET` | `/vlr/match` | `vlr-match` | VLR.gg Valorant match detail and player statistics |
47
+ | `GET` | `/vlr/match-economy` | `vlr-match-economy` | VLR.gg Valorant match economy |
48
+ | `GET` | `/vlr/match-performance` | `vlr-match-performance` | VLR.gg Valorant match performance |
49
+ | `GET` | `/vlr/match-rounds` | `vlr-match-rounds` | VLR.gg Valorant match round-by-round log |
50
+ | `GET` | `/vlr/matches` | `vlr-matches` | VLR.gg upcoming and live Valorant matches |
51
+ | `GET` | `/vlr/news` | `vlr-news` | VLR.gg Valorant esports news |
52
+ | `GET` | `/vlr/news-article` | `vlr-news-article` | VLR.gg news article |
53
+ | `GET` | `/vlr/player` | `vlr-player` | VLR.gg Valorant player profile and agent statistics |
54
+ | `GET` | `/vlr/player-matches` | `vlr-player-matches` | VLR.gg Valorant player match history |
55
+ | `GET` | `/vlr/rankings` | `vlr-rankings` | VLR.gg Valorant team rankings by region |
56
+ | `GET` | `/vlr/results` | `vlr-results` | VLR.gg completed Valorant match results |
57
+ | `GET` | `/vlr/search` | `vlr-search` | VLR.gg search for teams, events and players |
58
+ | `GET` | `/vlr/stats` | `vlr-stats` | VLR.gg Valorant player statistics with filters |
59
+ | `GET` | `/vlr/team` | `vlr-team` | VLR.gg Valorant team profile and roster |
60
+ | `GET` | `/vlr/team-maps` | `vlr-team-maps` | VLR.gg Valorant team map win rates |
61
+ | `GET` | `/vlr/team-matches` | `vlr-team-matches` | VLR.gg Valorant team match history |
62
+
63
+ See [Crawlora](https://crawlora.net/?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=vlr-ruby-homepage), the [API documentation](https://crawlora.net/docs?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=vlr-ruby-api-docs), and [the package repository](https://github.com/Crawlora-org/crawlora-vlr) for account setup, the API operation reference, and release history.
@@ -0,0 +1,288 @@
1
+ require "json"
2
+ require "net/http"
3
+ require "uri"
4
+
5
+ module Crawlora
6
+ module Vlr
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
+ {"vlr-event": {"bodyParam": null, "bodyRequired": false, "id": "vlr-event", "method": "GET", "params": [{"description": "Numeric VLR event id from vlr-events", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "3166"}], "path": "/vlr/event", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-event-agents": {"bodyParam": null, "bodyRequired": false, "id": "vlr-event-agents", "method": "GET", "params": [{"description": "Numeric VLR event id from vlr-events", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "3166"}], "path": "/vlr/event-agents", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-event-matches": {"bodyParam": null, "bodyRequired": false, "id": "vlr-event-matches", "method": "GET", "params": [{"description": "Numeric VLR event id from vlr-events", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "3166"}, {"description": "Stage id from the stages list of an earlier response (a week, group or bracket round); omit for every stage", "in": "query", "name": "series_id", "type": "string", "x-example": "6080"}, {"description": "Match group; one of completed, upcoming; omit for both", "enum": ["completed", "upcoming"], "in": "query", "name": "group", "type": "string"}], "path": "/vlr/event-matches", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}, {"in": "query", "name": "series_id", "type": "string"}, {"enum": ["completed", "upcoming"], "in": "query", "name": "group", "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-event-stats": {"bodyParam": null, "bodyRequired": false, "id": "vlr-event-stats", "method": "GET", "params": [{"description": "Numeric VLR event id from vlr-events", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "3166"}, {"description": "Side; one of all, t, ct; defaults to all", "enum": ["all", "t", "ct"], "in": "query", "name": "side", "type": "string"}, {"description": "Comma-separated agent roles; any of controller, initiator, sentinel, duelist", "in": "query", "name": "role", "type": "string", "x-example": "duelist"}, {"description": "Comma-separated agents, for example jett,sage; the same 29 agents as vlr-stats", "in": "query", "name": "agent", "type": "string", "x-example": "jett"}, {"description": "Comma-separated map names, for example ascent,bind; the same 13 maps as vlr-stats", "in": "query", "name": "map", "type": "string", "x-example": "ascent"}, {"description": "Comma-separated stage ids from the stages list of vlr-event-matches", "in": "query", "name": "stage", "type": "string", "x-example": "6080"}, {"description": "Minimum rounds played; 0 to 100000", "in": "query", "maximum": 100000, "minimum": 0, "name": "min_rounds", "type": "integer"}, {"description": "Sort column, the same set as vlr-stats; defaults to rating", "in": "query", "name": "sort", "type": "string"}, {"description": "Sort direction; one of desc, asc; defaults to desc", "enum": ["desc", "asc"], "in": "query", "name": "dir", "type": "string"}], "path": "/vlr/event-stats", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}, {"enum": ["all", "t", "ct"], "in": "query", "name": "side", "type": "string"}, {"in": "query", "name": "role", "type": "string"}, {"in": "query", "name": "agent", "type": "string"}, {"in": "query", "name": "map", "type": "string"}, {"in": "query", "name": "stage", "type": "string"}, {"in": "query", "name": "min_rounds", "type": "integer"}, {"in": "query", "name": "sort", "type": "string"}, {"enum": ["desc", "asc"], "in": "query", "name": "dir", "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-events": {"bodyParam": null, "bodyRequired": false, "id": "vlr-events", "method": "GET", "params": [{"description": "Event tier; one of all, vct, vcl, t3, gc, cg, off; defaults to all", "enum": ["all", "vct", "vcl", "t3", "gc", "cg", "off"], "in": "query", "name": "tier", "type": "string"}, {"description": "Event region; one of all, americas, emea, pacific, china; defaults to all", "enum": ["all", "americas", "emea", "pacific", "china"], "in": "query", "name": "region", "type": "string"}, {"description": "1-based page number; defaults to 1", "in": "query", "maximum": 500, "minimum": 1, "name": "page", "type": "integer"}], "path": "/vlr/events", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["all", "vct", "vcl", "t3", "gc", "cg", "off"], "in": "query", "name": "tier", "type": "string"}, {"enum": ["all", "americas", "emea", "pacific", "china"], "in": "query", "name": "region", "type": "string"}, {"in": "query", "name": "page", "type": "integer"}], "security": ["ApiKeyAuth"]}, "vlr-forum-categories": {"bodyParam": null, "bodyRequired": false, "id": "vlr-forum-categories", "method": "GET", "params": [], "path": "/vlr/forum-categories", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "vlr-forum-threads": {"bodyParam": null, "bodyRequired": false, "id": "vlr-forum-threads", "method": "GET", "params": [{"description": "Forum category; one of valorant-discussion, off-topic, site-feedback; omit for the combined list", "enum": ["valorant-discussion", "off-topic", "site-feedback"], "in": "query", "name": "category", "type": "string"}, {"description": "1-based page number; defaults to 1", "in": "query", "maximum": 500, "minimum": 1, "name": "page", "type": "integer"}, {"description": "Order; one of hot, new, top; omit for the site default (recent activity)", "enum": ["hot", "new", "top"], "in": "query", "name": "sort", "type": "string"}], "path": "/vlr/forum-threads", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["valorant-discussion", "off-topic", "site-feedback"], "in": "query", "name": "category", "type": "string"}, {"in": "query", "name": "page", "type": "integer"}, {"enum": ["hot", "new", "top"], "in": "query", "name": "sort", "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-match": {"bodyParam": null, "bodyRequired": false, "id": "vlr-match", "method": "GET", "params": [{"description": "Numeric VLR match id from vlr-matches, vlr-results or vlr-event-matches", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "777956"}], "path": "/vlr/match", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-match-economy": {"bodyParam": null, "bodyRequired": false, "id": "vlr-match-economy", "method": "GET", "params": [{"description": "Numeric VLR match id from vlr-matches, vlr-results or vlr-event-matches", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "754737"}], "path": "/vlr/match-economy", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-match-performance": {"bodyParam": null, "bodyRequired": false, "id": "vlr-match-performance", "method": "GET", "params": [{"description": "Numeric VLR match id from vlr-matches, vlr-results or vlr-event-matches", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "754737"}], "path": "/vlr/match-performance", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-match-rounds": {"bodyParam": null, "bodyRequired": false, "id": "vlr-match-rounds", "method": "GET", "params": [{"description": "Numeric VLR match id from vlr-matches, vlr-results or vlr-event-matches", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "754737"}], "path": "/vlr/match-rounds", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-matches": {"bodyParam": null, "bodyRequired": false, "id": "vlr-matches", "method": "GET", "params": [{"description": "1-based page number; defaults to 1", "in": "query", "maximum": 500, "minimum": 1, "name": "page", "type": "integer"}], "path": "/vlr/matches", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "page", "type": "integer"}], "security": ["ApiKeyAuth"]}, "vlr-news": {"bodyParam": null, "bodyRequired": false, "id": "vlr-news", "method": "GET", "params": [{"description": "1-based page number; defaults to 1", "in": "query", "maximum": 500, "minimum": 1, "name": "page", "type": "integer"}], "path": "/vlr/news", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "page", "type": "integer"}], "security": ["ApiKeyAuth"]}, "vlr-news-article": {"bodyParam": null, "bodyRequired": false, "id": "vlr-news-article", "method": "GET", "params": [{"description": "Numeric VLR news article id from vlr-news", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "781119"}], "path": "/vlr/news-article", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-player": {"bodyParam": null, "bodyRequired": false, "id": "vlr-player", "method": "GET", "params": [{"description": "Numeric VLR player id from vlr-team or vlr-stats", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "9780"}, {"description": "Window of the agent statistics; one of all, 30d, 60d, 90d; omit for the site default", "enum": ["all", "30d", "60d", "90d"], "in": "query", "name": "timespan", "type": "string"}], "path": "/vlr/player", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}, {"enum": ["all", "30d", "60d", "90d"], "in": "query", "name": "timespan", "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-player-matches": {"bodyParam": null, "bodyRequired": false, "id": "vlr-player-matches", "method": "GET", "params": [{"description": "Numeric VLR player id from vlr-team or vlr-stats", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "9780"}, {"description": "1-based page number; defaults to 1", "in": "query", "maximum": 500, "minimum": 1, "name": "page", "type": "integer"}], "path": "/vlr/player-matches", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}, {"in": "query", "name": "page", "type": "integer"}], "security": ["ApiKeyAuth"]}, "vlr-rankings": {"bodyParam": null, "bodyRequired": false, "id": "vlr-rankings", "method": "GET", "params": [{"description": "Ranking region; one of north-america, europe, brazil, asia-pacific, korea, china, japan, la-s, la-n, oceania, mena, gc, collegiate; defaults to north-america", "enum": ["north-america", "europe", "brazil", "asia-pacific", "korea", "china", "japan", "la-s", "la-n", "oceania", "mena", "gc", "collegiate"], "in": "query", "name": "region", "type": "string"}, {"description": "Number of top teams to return, 1 to 250; defaults to 50", "in": "query", "maximum": 250, "minimum": 1, "name": "limit", "type": "integer"}], "path": "/vlr/rankings", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["north-america", "europe", "brazil", "asia-pacific", "korea", "china", "japan", "la-s", "la-n", "oceania", "mena", "gc", "collegiate"], "in": "query", "name": "region", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "vlr-results": {"bodyParam": null, "bodyRequired": false, "id": "vlr-results", "method": "GET", "params": [{"description": "1-based page number; defaults to 1", "in": "query", "maximum": 500, "minimum": 1, "name": "page", "type": "integer"}], "path": "/vlr/results", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "page", "type": "integer"}], "security": ["ApiKeyAuth"]}, "vlr-search": {"bodyParam": null, "bodyRequired": false, "id": "vlr-search", "method": "GET", "params": [{"description": "Search text, 1 to 100 characters", "in": "query", "name": "q", "required": true, "type": "string", "x-example": "sentinels"}, {"description": "Result group; one of all, teams, events, players; defaults to all", "enum": ["all", "teams", "events", "players"], "in": "query", "name": "type", "type": "string"}], "path": "/vlr/search", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "q", "required": true, "type": "string"}, {"enum": ["all", "teams", "events", "players"], "in": "query", "name": "type", "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-stats": {"bodyParam": null, "bodyRequired": false, "id": "vlr-stats", "method": "GET", "params": [{"description": "Comma-separated tiers from vct, vcl, t3, gc, cg, off; site default vct", "in": "query", "name": "tier", "type": "string"}, {"description": "Comma-separated regions from americas, emea, pacific, china, intl", "in": "query", "name": "region", "type": "string"}, {"description": "Timespan; one of all, 30d, 60d, 90d, 2026, 2025, 2024, 2023, 2022, 2021, 2020; site default 60d", "enum": ["all", "30d", "60d", "90d", "2026", "2025", "2024", "2023", "2022", "2021", "2020"], "in": "query", "name": "timespan", "type": "string"}, {"description": "Side; one of all, t, ct", "enum": ["all", "t", "ct"], "in": "query", "name": "side", "type": "string"}, {"description": "Comma-separated roles from controller, initiator, sentinel, duelist", "in": "query", "name": "role", "type": "string"}, {"description": "Comma-separated agents from astra, brimstone, clove, harbor, miks, omen, viper, breach, fade, gekko, kayo, skye, sova, tejo, chamber, cypher, deadlock, killjoy, sage, veto, vyse, iso, jett, neon, phoenix, raze, reyna, waylay, yoru", "in": "query", "name": "agent", "type": "string"}, {"description": "Comma-separated maps from abyss, bind, corrode, haven, lotus, summit, sunset, ascent, breeze, fracture, icebox, pearl, split", "in": "query", "name": "map", "type": "string"}, {"description": "Minimum rounds played; site default 100", "in": "query", "minimum": 0, "name": "min_rounds", "type": "integer"}, {"description": "First day of a custom date range, YYYY-MM-DD (UTC); requires to and replaces timespan", "in": "query", "name": "from", "type": "string", "x-example": "2026-09-01"}, {"description": "Last day of a custom date range, YYYY-MM-DD (UTC); requires from and replaces timespan", "in": "query", "name": "to", "type": "string", "x-example": "2026-10-01"}, {"description": "Minimum player rating; one of 0, 1300, 1400, 1500, 1550, 1650, 1750, 1850", "enum": [0, 1300, 1400, 1500, 1550, 1650, 1750, 1850], "in": "query", "name": "min_rating", "type": "integer"}, {"description": "Sort column; one of rating, maps, rnd, acs, kd, kast, adr, kpr, apr, fkfd, fkpr, fdpr, hsp, clp, cl, kmax, k, d, a, fk, fd; defaults to rating", "enum": ["rating", "maps", "rnd", "acs", "kd", "kast", "adr", "kpr", "apr", "fkfd", "fkpr", "fdpr", "hsp", "clp", "cl", "kmax", "k", "d", "a", "fk", "fd"], "in": "query", "name": "sort", "type": "string"}, {"description": "Sort direction; one of asc, desc; defaults to desc", "enum": ["asc", "desc"], "in": "query", "name": "dir", "type": "string"}, {"description": "1-based page number; defaults to 1", "in": "query", "maximum": 500, "minimum": 1, "name": "page", "type": "integer"}], "path": "/vlr/stats", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "tier", "type": "string"}, {"in": "query", "name": "region", "type": "string"}, {"enum": ["all", "30d", "60d", "90d", "2026", "2025", "2024", "2023", "2022", "2021", "2020"], "in": "query", "name": "timespan", "type": "string"}, {"enum": ["all", "t", "ct"], "in": "query", "name": "side", "type": "string"}, {"in": "query", "name": "role", "type": "string"}, {"in": "query", "name": "agent", "type": "string"}, {"in": "query", "name": "map", "type": "string"}, {"in": "query", "name": "min_rounds", "type": "integer"}, {"in": "query", "name": "from", "type": "string"}, {"in": "query", "name": "to", "type": "string"}, {"enum": ["0", "1300", "1400", "1500", "1550", "1650", "1750", "1850"], "in": "query", "name": "min_rating", "type": "integer"}, {"enum": ["rating", "maps", "rnd", "acs", "kd", "kast", "adr", "kpr", "apr", "fkfd", "fkpr", "fdpr", "hsp", "clp", "cl", "kmax", "k", "d", "a", "fk", "fd"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["asc", "desc"], "in": "query", "name": "dir", "type": "string"}, {"in": "query", "name": "page", "type": "integer"}], "security": ["ApiKeyAuth"]}, "vlr-team": {"bodyParam": null, "bodyRequired": false, "id": "vlr-team", "method": "GET", "params": [{"description": "Numeric VLR team id from vlr-rankings, vlr-event or vlr-match", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "2059"}], "path": "/vlr/team", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-team-maps": {"bodyParam": null, "bodyRequired": false, "id": "vlr-team-maps", "method": "GET", "params": [{"description": "Numeric VLR team id from vlr-rankings, vlr-event or vlr-match", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "2059"}], "path": "/vlr/team-maps", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "vlr-team-matches": {"bodyParam": null, "bodyRequired": false, "id": "vlr-team-matches", "method": "GET", "params": [{"description": "Numeric VLR team id from vlr-rankings, vlr-event or vlr-match", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "2059"}, {"description": "1-based page number; defaults to 1", "in": "query", "maximum": 500, "minimum": 1, "name": "page", "type": "integer"}, {"description": "Match group; one of completed (default), upcoming", "enum": ["completed", "upcoming"], "in": "query", "name": "group", "type": "string"}], "path": "/vlr/team-matches", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}, {"in": "query", "name": "page", "type": "integer"}, {"enum": ["completed", "upcoming"], "in": "query", "name": "group", "type": "string"}], "security": ["ApiKeyAuth"]}}
23
+ JSON
24
+ OPERATION_IDS = JSON.parse(<<~'JSON').freeze
25
+ ["vlr-event", "vlr-event-agents", "vlr-event-matches", "vlr-event-stats", "vlr-events", "vlr-forum-categories", "vlr-forum-threads", "vlr-match", "vlr-match-economy", "vlr-match-performance", "vlr-match-rounds", "vlr-matches", "vlr-news", "vlr-news-article", "vlr-player", "vlr-player-matches", "vlr-rankings", "vlr-results", "vlr-search", "vlr-stats", "vlr-team", "vlr-team-maps", "vlr-team-matches"]
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-vlr-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('event') do |**params|
118
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
119
+ request('vlr-event', params, response_type: response_type)
120
+ end
121
+ define_method('event_agents') do |**params|
122
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
123
+ request('vlr-event-agents', params, response_type: response_type)
124
+ end
125
+ define_method('event_matches') do |**params|
126
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
127
+ request('vlr-event-matches', params, response_type: response_type)
128
+ end
129
+ define_method('event_stats') do |**params|
130
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
131
+ request('vlr-event-stats', params, response_type: response_type)
132
+ end
133
+ define_method('events') do |**params|
134
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
135
+ request('vlr-events', params, response_type: response_type)
136
+ end
137
+ define_method('forum_categories') do |**params|
138
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
139
+ request('vlr-forum-categories', params, response_type: response_type)
140
+ end
141
+ define_method('forum_threads') do |**params|
142
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
143
+ request('vlr-forum-threads', params, response_type: response_type)
144
+ end
145
+ define_method('match') do |**params|
146
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
147
+ request('vlr-match', params, response_type: response_type)
148
+ end
149
+ define_method('match_economy') do |**params|
150
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
151
+ request('vlr-match-economy', params, response_type: response_type)
152
+ end
153
+ define_method('match_performance') do |**params|
154
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
155
+ request('vlr-match-performance', params, response_type: response_type)
156
+ end
157
+ define_method('match_rounds') do |**params|
158
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
159
+ request('vlr-match-rounds', params, response_type: response_type)
160
+ end
161
+ define_method('matches') do |**params|
162
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
163
+ request('vlr-matches', params, response_type: response_type)
164
+ end
165
+ define_method('news') do |**params|
166
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
167
+ request('vlr-news', params, response_type: response_type)
168
+ end
169
+ define_method('news_article') do |**params|
170
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
171
+ request('vlr-news-article', params, response_type: response_type)
172
+ end
173
+ define_method('player') do |**params|
174
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
175
+ request('vlr-player', params, response_type: response_type)
176
+ end
177
+ define_method('player_matches') do |**params|
178
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
179
+ request('vlr-player-matches', params, response_type: response_type)
180
+ end
181
+ define_method('rankings') do |**params|
182
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
183
+ request('vlr-rankings', params, response_type: response_type)
184
+ end
185
+ define_method('results') do |**params|
186
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
187
+ request('vlr-results', params, response_type: response_type)
188
+ end
189
+ define_method('search') do |**params|
190
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
191
+ request('vlr-search', params, response_type: response_type)
192
+ end
193
+ define_method('stats') do |**params|
194
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
195
+ request('vlr-stats', params, response_type: response_type)
196
+ end
197
+ define_method('team') do |**params|
198
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
199
+ request('vlr-team', params, response_type: response_type)
200
+ end
201
+ define_method('team_maps') do |**params|
202
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
203
+ request('vlr-team-maps', params, response_type: response_type)
204
+ end
205
+ define_method('team_matches') do |**params|
206
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
207
+ request('vlr-team-matches', params, response_type: response_type)
208
+ end
209
+
210
+ private
211
+
212
+ # POST operations take their JSON body under the body parameter name or "body".
213
+ def request_body(operation, params)
214
+ name = operation["bodyParam"]
215
+ return nil if name.nil?
216
+ value = params.key?(name) ? params[name] : params["body"]
217
+ if value.nil?
218
+ raise Errors::ClientError.new("missing request body: #{name}", operation_id: operation["id"]) if operation["bodyRequired"]
219
+ return nil
220
+ end
221
+ value.is_a?(String) ? value : JSON.generate(value)
222
+ end
223
+
224
+ def build_url(operation, params)
225
+ known = operation["params"].map { |param| param["name"] }
226
+ known << "body" if operation["bodyParam"]
227
+ unknown = params.keys - known
228
+ raise Errors::ClientError.new("unknown parameters: #{unknown.join(', ')}", operation_id: operation["id"]) unless unknown.empty?
229
+ path = operation["path"].dup
230
+ operation["params"].select { |param| param["in"] == "path" }.each do |param|
231
+ value = params[param["name"]]
232
+ raise Errors::ClientError.new("missing path parameter: #{param['name']}", operation_id: operation["id"]) if value.nil?
233
+ path.sub!("{" + param["name"] + "}", percent_encode(value.to_s))
234
+ end
235
+ pairs = []
236
+ operation["queryParams"].each do |param|
237
+ name = param["name"]
238
+ value = params.key?(name) ? params[name] : param["default"]
239
+ if value.nil?
240
+ raise Errors::ClientError.new("missing query parameter: #{name}", operation_id: operation["id"]) if param["required"]
241
+ next
242
+ end
243
+ enum_values = param["enum"] || (param["items"] && param["items"]["enum"])
244
+ if enum_values && !(value.is_a?(Array) ? value : [value]).all? { |item| enum_values.map(&:to_s).include?(item.to_s) }
245
+ raise Errors::ClientError.new("invalid value for #{name}", operation_id: operation["id"])
246
+ end
247
+ if value.is_a?(Array)
248
+ format = param["collectionFormat"] || "csv"
249
+ if format == "multi"
250
+ value.each { |item| pairs << [name, scalar(item)] }
251
+ else
252
+ separator = {"csv" => ",", "ssv" => " ", "tsv" => "\t", "pipes" => "|"}[format] || ","
253
+ pairs << [name, value.map { |item| scalar(item) }.join(separator)]
254
+ end
255
+ else
256
+ pairs << [name, scalar(value)]
257
+ end
258
+ end
259
+ query = pairs.map { |name, value| "#{percent_encode(name)}=#{percent_encode(value)}" }.join("&")
260
+ @base_url + path + (query.empty? ? "" : "?" + query)
261
+ end
262
+
263
+ def scalar(value)
264
+ value == true ? "true" : (value == false ? "false" : value.to_s)
265
+ end
266
+
267
+ def percent_encode(value)
268
+ URI::DEFAULT_PARSER.escape(value.to_s, /[^A-Za-z0-9\-._~]/)
269
+ end
270
+
271
+ def parse_response(body, content_type, operation, params, response_type)
272
+ type = response_type.to_s
273
+ raise Errors::ClientError.new("response_type must be auto, json, or text", operation_id: operation["id"]) unless %w[auto json text].include?(type)
274
+ format = operation["params"].find { |param| param["name"] == "format" }
275
+ text_formats = format && format["enum"] ? format["enum"].reject { |value| %w[json application/json].include?(value.to_s.downcase) } : []
276
+ raw_format = params["format"] && text_formats.include?(params["format"].to_s)
277
+ 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)
278
+ is_json = json_format || content_type.to_s.downcase.include?("json") || operation["produces"] == ["application/json"]
279
+ return body if type == "text" || raw_format || (type == "auto" && !is_json)
280
+ JSON.parse(body)
281
+ rescue JSON::ParserError => error
282
+ raise Errors::Error.new("invalid JSON response from Crawlora: #{error.message}", operation_id: operation["id"], body: body)
283
+ end
284
+
285
+ public
286
+ end
287
+ end
288
+ end
@@ -0,0 +1,5 @@
1
+ module Crawlora
2
+ module Vlr
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require_relative "vlr/version"
2
+ require_relative "vlr/client"
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crawlora-vlr
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-11-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client for Crawlora's hosted VLR.gg API. Covers Valorant matches,
14
+ events, results, rankings, statistics, news, and forum data across 23 endpoints.
15
+ email:
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG.md
21
+ - LICENSE
22
+ - README.md
23
+ - lib/crawlora/vlr.rb
24
+ - lib/crawlora/vlr/client.rb
25
+ - lib/crawlora/vlr/version.rb
26
+ homepage: https://crawlora.net/?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=vlr-ruby-homepage
27
+ licenses:
28
+ - MIT
29
+ metadata:
30
+ source_code_uri: https://github.com/Crawlora-org/crawlora-vlr
31
+ documentation_uri: https://github.com/Crawlora-org/crawlora-vlr/blob/main/ruby/README.md
32
+ rubygems_mfa_required: 'true'
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '2.6'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubygems_version: 3.4.19
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: VLR.gg API client for Crawlora (23 endpoints)
52
+ test_files: []