crawlora-fotmob 0.1.4

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: f76bdce03506fd86fbd6c03102db997c91cea272ad6b4b63e028d8af7aed350b
4
+ data.tar.gz: 4f56103d868c9a643c806442843637fcab22d58617787288fe94b78b1b84dce5
5
+ SHA512:
6
+ metadata.gz: e6bf70b6980426dec37936c1fbd9c415dbca0b200179d155ca4d7502215cf6a13062048b554bf8dbde092e1074f58e4a7b999598235b997fea41753f915641d6
7
+ data.tar.gz: 4353b763685d442ca46ac6e89ba2dc4e9068169c14bf92bd1855814eaeb9644517b842f685cbc3f0eeeb126c95590cc6a18859703726f02a059dc77155fa7876
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.4
4
+
5
+ - Initial focused FotMob 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,33 @@
1
+ # Crawlora FotMob Ruby client
2
+
3
+ This gem calls the Crawlora hosted API at `https://api.crawlora.net/api/v1`. It does not call or scrape FotMob directly. Requests require your Crawlora API key and use your account's service plan.
4
+
5
+ ## Install
6
+
7
+ ```ruby
8
+ gem "crawlora-fotmob"
9
+ ```
10
+
11
+ Create an account at [crawlora.net](https://crawlora.net/signup), open the [Crawlora console](https://crawlora.net/app) to get an API key, and set `CRAWLORA_API_KEY` before running the client:
12
+
13
+ ```ruby
14
+ require "json"
15
+ require "crawlora/fotmob"
16
+
17
+ client = Crawlora::Fotmob::Client.new
18
+ result = client.request("fotmob-search", JSON.parse("{\"term\": \"Premier League\"}"))
19
+ puts result
20
+ client.close
21
+ ```
22
+
23
+ Use a generated operation 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 contains 31 operations and follows contract revision `sha256:d40e5ee2b400b1b40b5ca6998063cde26b6bb3e7f84da679b5047d26380f3fa1`.
24
+
25
+ ```ruby
26
+ client = Crawlora::Fotmob::Client.new(api_key: ENV.fetch("CRAWLORA_API_KEY"), timeout: 30)
27
+ # client.<operation_method>(<contract parameters>)
28
+ client.close
29
+ ```
30
+
31
+ Client options include `api_key`, `base_url`, and `timeout`. Ruby stdlib provides the HTTP and JSON transport. The gem follows contract revision `sha256:d40e5ee2b400b1b40b5ca6998063cde26b6bb3e7f84da679b5047d26380f3fa1` and contains 31 operations.
32
+
33
+ See [Crawlora](https://crawlora.net/), the [API documentation](https://crawlora.net/docs), and [the package repository](https://github.com/Crawlora-org/crawlora-fotmob) for account setup, the generated operation reference, and release history.
@@ -0,0 +1,298 @@
1
+ require "json"
2
+ require "net/http"
3
+ require "uri"
4
+
5
+ module Crawlora
6
+ module Fotmob
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
+ {"fotmob-audio-matches": {"id": "fotmob-audio-matches", "method": "GET", "params": [], "path": "/fotmob/audio-matches", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "fotmob-fifa-ranking-periods": {"id": "fotmob-fifa-ranking-periods", "method": "GET", "params": [{"description": "Ranking gender", "enum": ["men", "women"], "in": "query", "name": "gender", "required": true, "type": "string", "x-example": "men"}], "path": "/fotmob/fifa-ranking-periods", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["men", "women"], "in": "query", "name": "gender", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-fifa-rankings": {"id": "fotmob-fifa-rankings", "method": "GET", "params": [{"description": "Ranking gender", "enum": ["men", "women"], "in": "query", "name": "gender", "required": true, "type": "string", "x-example": "men"}, {"description": "Period id returned for this gender by /fotmob/fifa-ranking-periods", "in": "query", "name": "period_id", "required": true, "type": "string", "x-example": "20260720"}], "path": "/fotmob/fifa-rankings", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["men", "women"], "in": "query", "name": "gender", "required": true, "type": "string"}, {"in": "query", "name": "period_id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-latest-news": {"id": "fotmob-latest-news", "method": "GET", "params": [{"description": "Zero-based news offset; defaults to 0", "in": "query", "maximum": 10000, "minimum": 0, "name": "start_index", "type": "integer"}], "path": "/fotmob/latest-news", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "start_index", "type": "integer"}], "security": ["ApiKeyAuth"]}, "fotmob-league": {"id": "fotmob-league", "method": "GET", "params": [{"description": "Numeric FotMob league id from /fotmob/leagues", "in": "query", "name": "league_id", "required": true, "type": "integer", "x-example": 47}, {"description": "Optional season value from /fotmob/seasons for this league", "in": "query", "name": "season", "type": "string", "x-example": "2025/2026"}, {"default": false, "description": "Include the optional overview shot map; increases response size", "in": "query", "name": "shotmap", "type": "boolean"}], "path": "/fotmob/league", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "league_id", "required": true, "type": "integer"}, {"in": "query", "name": "season", "type": "string"}, {"in": "query", "name": "shotmap", "type": "boolean"}], "security": ["ApiKeyAuth"]}, "fotmob-leagues": {"id": "fotmob-leagues", "method": "GET", "params": [], "path": "/fotmob/leagues", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "fotmob-lineup-builder-players": {"id": "fotmob-lineup-builder-players", "method": "GET", "params": [{"description": "Comma-separated list of 1 to 11 numeric FotMob player ids", "in": "query", "name": "player_ids", "required": true, "type": "string", "x-example": "961995,562727"}], "path": "/fotmob/lineup-builder-players", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "player_ids", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-lineup-builder-team": {"id": "fotmob-lineup-builder-team", "method": "GET", "params": [{"description": "Numeric FotMob team id discoverable through /fotmob/search", "in": "query", "name": "team_id", "required": true, "type": "string", "x-example": "9825"}], "path": "/fotmob/lineup-builder-team", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "team_id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-match": {"id": "fotmob-match", "method": "GET", "params": [{"description": "Numeric FotMob match id", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "5181825"}], "path": "/fotmob/match", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-match-media": {"id": "fotmob-match-media", "method": "GET", "params": [{"description": "Numeric FotMob match id, discoverable from /fotmob/matches or /fotmob/search", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "5795457"}], "path": "/fotmob/match-media", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-matches": {"id": "fotmob-matches", "method": "GET", "params": [{"description": "Date in YYYYMMDD format", "in": "query", "name": "date", "required": true, "type": "string", "x-example": "20260925"}, {"description": "IANA timezone; defaults to UTC", "in": "query", "name": "timezone", "type": "string", "x-example": "Asia/Shanghai"}], "path": "/fotmob/matches", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "date", "required": true, "type": "string"}, {"in": "query", "name": "timezone", "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-news": {"id": "fotmob-news", "method": "GET", "params": [{"description": "Numeric FotMob league id", "in": "query", "name": "league_id", "required": true, "type": "string", "x-example": "47"}, {"description": "Zero-based news offset; defaults to 0", "in": "query", "maximum": 10000, "minimum": 0, "name": "start_index", "type": "integer"}], "path": "/fotmob/news", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "league_id", "required": true, "type": "string"}, {"in": "query", "name": "start_index", "type": "integer"}], "security": ["ApiKeyAuth"]}, "fotmob-news-article": {"id": "fotmob-news-article", "method": "GET", "params": [{"description": "Complete FotMob top-news article id and slug from the public article URL", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "29776-fotmob-totw-premier-league-matchday-5s-best-xi"}], "path": "/fotmob/news-article", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-player": {"id": "fotmob-player", "method": "GET", "params": [{"description": "Numeric FotMob player id from fotmob/search", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "961995"}, {"default": true, "description": "Include market-value history; defaults to true", "in": "query", "name": "include_market_values", "type": "boolean"}], "path": "/fotmob/player", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}, {"in": "query", "name": "include_market_values", "type": "boolean"}], "security": ["ApiKeyAuth"]}, "fotmob-player-match-stats": {"id": "fotmob-player-match-stats", "method": "GET", "params": [{"description": "Numeric FotMob player id", "in": "query", "name": "player_id", "required": true, "type": "string", "x-example": "961995"}, {"description": "Numeric FotMob match id", "in": "query", "name": "match_id", "required": true, "type": "string", "x-example": "5795457"}], "path": "/fotmob/player-match-stats", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "player_id", "required": true, "type": "string"}, {"in": "query", "name": "match_id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-player-matches": {"id": "fotmob-player-matches", "method": "GET", "params": [{"description": "Numeric FotMob player id from fotmob/search", "in": "query", "name": "player_id", "required": true, "type": "string", "x-example": "961995"}, {"default": "all", "description": "all, or a numeric league id from fotmob/player matchFilters", "in": "query", "name": "league_id", "type": "string", "x-example": "47"}, {"default": "all", "description": "all, or a numeric team id paired with league_id in fotmob/player matchFilters", "in": "query", "name": "team_id", "type": "string", "x-example": "9825"}, {"description": "Numeric before timestamp from the upstream previous URL; omit for the newest page", "in": "query", "name": "before", "type": "string", "x-example": "1767902400"}], "path": "/fotmob/player-matches", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "player_id", "required": true, "type": "string"}, {"in": "query", "name": "league_id", "type": "string"}, {"in": "query", "name": "team_id", "type": "string"}, {"in": "query", "name": "before", "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-player-stats": {"id": "fotmob-player-stats", "method": "GET", "params": [{"description": "Numeric FotMob player id from fotmob/search", "in": "query", "name": "player_id", "required": true, "type": "string", "x-example": "961995"}, {"description": "Player-specific entryId from fotmob/player statSeasons", "in": "query", "name": "season_id", "required": true, "type": "string", "x-example": "0-1"}], "path": "/fotmob/player-stats", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "player_id", "required": true, "type": "string"}, {"in": "query", "name": "season_id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-search": {"id": "fotmob-search", "method": "GET", "params": [{"description": "Search phrase, 1 to 50 characters", "in": "query", "maxLength": 50, "minLength": 1, "name": "term", "required": true, "type": "string", "x-example": "Arsenal"}], "path": "/fotmob/search", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "term", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-seasons": {"id": "fotmob-seasons", "method": "GET", "params": [{"description": "Numeric FotMob league id from /fotmob/leagues", "in": "query", "name": "league_id", "required": true, "type": "integer", "x-example": 47}], "path": "/fotmob/seasons", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "league_id", "required": true, "type": "integer"}], "security": ["ApiKeyAuth"]}, "fotmob-stats": {"id": "fotmob-stats", "method": "GET", "params": [{"description": "Numeric FotMob league id", "in": "query", "name": "league_id", "required": true, "type": "string", "x-example": "47"}, {"description": "Numeric season id from /fotmob/stats-categories; defaults to the newest season", "in": "query", "name": "season_id", "type": "string", "x-example": "36781"}, {"description": "Stats subject", "enum": ["players", "teams"], "in": "query", "name": "type", "required": true, "type": "string", "x-example": "players"}, {"description": "Stat id returned by /fotmob/stats-categories for this league, season, and type", "in": "query", "name": "stat", "required": true, "type": "string", "x-example": "goals"}, {"description": "Optional numeric team id to filter player stats", "in": "query", "name": "team_id", "type": "string", "x-example": "8456"}, {"description": "Optional client-side player position filter", "enum": ["all", "striker", "winger", "attackingMidfielder", "midfielder", "fullback", "centerBack"], "in": "query", "name": "position", "type": "string", "x-example": "striker"}], "path": "/fotmob/stats", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "league_id", "required": true, "type": "string"}, {"in": "query", "name": "season_id", "type": "string"}, {"enum": ["players", "teams"], "in": "query", "name": "type", "required": true, "type": "string"}, {"in": "query", "name": "stat", "required": true, "type": "string"}, {"in": "query", "name": "team_id", "type": "string"}, {"enum": ["all", "striker", "winger", "attackingMidfielder", "midfielder", "fullback", "centerBack"], "in": "query", "name": "position", "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-stats-categories": {"id": "fotmob-stats-categories", "method": "GET", "params": [{"description": "Numeric FotMob league id", "in": "query", "name": "league_id", "required": true, "type": "string", "x-example": "47"}, {"description": "Numeric season id; omit to discover seasons", "in": "query", "name": "season_id", "type": "string", "x-example": "36781"}, {"description": "Stats subject", "enum": ["players", "teams"], "in": "query", "name": "type", "required": true, "type": "string", "x-example": "players"}], "path": "/fotmob/stats-categories", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "league_id", "required": true, "type": "string"}, {"in": "query", "name": "season_id", "type": "string"}, {"enum": ["players", "teams"], "in": "query", "name": "type", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-table": {"id": "fotmob-table", "method": "GET", "params": [{"description": "Numeric FotMob league id", "in": "query", "name": "league_id", "required": true, "type": "string", "x-example": "47"}], "path": "/fotmob/table", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "league_id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-team": {"id": "fotmob-team", "method": "GET", "params": [{"description": "Numeric FotMob team id", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "9825"}], "path": "/fotmob/team", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-team-fixtures": {"id": "fotmob-team-fixtures", "method": "GET", "params": [{"description": "Numeric FotMob team id", "in": "query", "name": "team_id", "required": true, "type": "string", "x-example": "9825"}, {"description": "Opaque cursor copied from fixtures.previousFixturesUrl in /fotmob/team or previous in the preceding response", "in": "query", "name": "cursor", "required": true, "type": "string", "x-example": "https://pub.fotmob.com/prod/db/api/team/9825/fixture-by-date?beforeTimestamp=1785607200"}], "path": "/fotmob/team-fixtures", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "team_id", "required": true, "type": "string"}, {"in": "query", "name": "cursor", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-team-news": {"id": "fotmob-team-news", "method": "GET", "params": [{"description": "Numeric FotMob team id", "in": "query", "name": "team_id", "required": true, "type": "integer", "x-example": 8456}, {"description": "Zero-based news offset from 0 through 10000", "in": "query", "maximum": 10000, "minimum": 0, "name": "start_index", "type": "integer", "x-example": 0}], "path": "/fotmob/team-news", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "team_id", "required": true, "type": "integer"}, {"in": "query", "name": "start_index", "type": "integer"}], "security": ["ApiKeyAuth"]}, "fotmob-transfers": {"id": "fotmob-transfers", "method": "GET", "params": [{"default": "all", "description": "Feed mode", "enum": ["all", "rumours", "popular"], "in": "query", "name": "mode", "type": "string"}, {"default": 1, "description": "One-based result page; 50 rows per page", "in": "query", "maximum": 200, "minimum": 1, "name": "page", "type": "integer"}, {"default": "6months", "description": "Time window", "enum": ["6months", "1year", "2years", "3years"], "in": "query", "name": "last", "type": "string"}, {"default": "all", "description": "Transfer direction; applied when league_ids or team_ids is supplied", "enum": ["all", "in", "out"], "in": "query", "name": "direction", "type": "string"}, {"description": "Minimum transfer fee in EUR", "in": "query", "minimum": 0, "name": "min_fee", "type": "integer"}, {"description": "Maximum transfer fee in EUR", "in": "query", "minimum": 0, "name": "max_fee", "type": "integer"}, {"description": "Comma-separated numeric FotMob league ids, up to 50; discover with /fotmob/leagues", "in": "query", "name": "league_ids", "type": "string", "x-example": "47"}, {"description": "Comma-separated numeric FotMob team ids, up to 50; discover with /fotmob/search", "in": "query", "name": "team_ids", "type": "string", "x-example": "8456"}, {"default": "lastModified", "description": "Sort column", "enum": ["lastModified", "fee", "date", "name", "fromClubName", "toClubName"], "in": "query", "name": "order_by", "type": "string"}, {"default": false, "description": "Exclude contract-extension records", "in": "query", "name": "exclude_extensions", "type": "boolean"}, {"default": false, "description": "Return only likely rumours; mode must be rumours", "in": "query", "name": "likely_only", "type": "boolean"}], "path": "/fotmob/transfers", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["all", "rumours", "popular"], "in": "query", "name": "mode", "type": "string"}, {"in": "query", "name": "page", "type": "integer"}, {"enum": ["6months", "1year", "2years", "3years"], "in": "query", "name": "last", "type": "string"}, {"enum": ["all", "in", "out"], "in": "query", "name": "direction", "type": "string"}, {"in": "query", "name": "min_fee", "type": "integer"}, {"in": "query", "name": "max_fee", "type": "integer"}, {"in": "query", "name": "league_ids", "type": "string"}, {"in": "query", "name": "team_ids", "type": "string"}, {"enum": ["lastModified", "fee", "date", "name", "fromClubName", "toClubName"], "in": "query", "name": "order_by", "type": "string"}, {"in": "query", "name": "exclude_extensions", "type": "boolean"}, {"in": "query", "name": "likely_only", "type": "boolean"}], "security": ["ApiKeyAuth"]}, "fotmob-trending-news": {"id": "fotmob-trending-news", "method": "GET", "params": [], "path": "/fotmob/trending-news", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "fotmob-trending-searches": {"id": "fotmob-trending-searches", "method": "GET", "params": [], "path": "/fotmob/trending-searches", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "fotmob-tv-guide": {"id": "fotmob-tv-guide", "method": "GET", "params": [{"description": "Market code from /fotmob/tv-guide-countries", "enum": ["us", "se", "gb", "de", "no", "es", "mx", "ar", "bo", "cl", "co", "cr", "ec", "gt", "hn", "ni", "pa", "py", "pe", "uy", "ve", "da", "ca", "au", "at", "be", "bg", "hr", "cy", "cz", "ee", "fi", "fr", "gr", "hu", "is", "ie", "il", "it", "nl", "pl", "pt", "ro", "ru", "ch", "tr", "za", "br", "in", "me", "id", "th", "mm", "al", "az", "bl", "ba", "ks", "la", "li", "mk", "rs", "sk", "ua", "essv", "nz", "bd", "cn", "gh", "hk", "jp", "kr", "ma", "mt", "my", "ng", "ph", "pk", "sg", "si", "tz"], "in": "query", "name": "country", "required": true, "type": "string", "x-example": "us"}, {"description": "IANA timezone for local times", "in": "query", "name": "timezone", "type": "string", "x-example": "America/New_York"}], "path": "/fotmob/tv-guide", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["us", "se", "gb", "de", "no", "es", "mx", "ar", "bo", "cl", "co", "cr", "ec", "gt", "hn", "ni", "pa", "py", "pe", "uy", "ve", "da", "ca", "au", "at", "be", "bg", "hr", "cy", "cz", "ee", "fi", "fr", "gr", "hu", "is", "ie", "il", "it", "nl", "pl", "pt", "ro", "ru", "ch", "tr", "za", "br", "in", "me", "id", "th", "mm", "al", "az", "bl", "ba", "ks", "la", "li", "mk", "rs", "sk", "ua", "essv", "nz", "bd", "cn", "gh", "hk", "jp", "kr", "ma", "mt", "my", "ng", "ph", "pk", "sg", "si", "tz"], "in": "query", "name": "country", "required": true, "type": "string"}, {"in": "query", "name": "timezone", "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-tv-guide-channels": {"id": "fotmob-tv-guide-channels", "method": "GET", "params": [{"description": "Market code from /fotmob/tv-guide-countries", "enum": ["us", "se", "gb", "de", "no", "es", "mx", "ar", "bo", "cl", "co", "cr", "ec", "gt", "hn", "ni", "pa", "py", "pe", "uy", "ve", "da", "ca", "au", "at", "be", "bg", "hr", "cy", "cz", "ee", "fi", "fr", "gr", "hu", "is", "ie", "il", "it", "nl", "pl", "pt", "ro", "ru", "ch", "tr", "za", "br", "in", "me", "id", "th", "mm", "al", "az", "bl", "ba", "ks", "la", "li", "mk", "rs", "sk", "ua", "essv", "nz", "bd", "cn", "gh", "hk", "jp", "kr", "ma", "mt", "my", "ng", "ph", "pk", "sg", "si", "tz"], "in": "query", "name": "country", "required": true, "type": "string", "x-example": "us"}], "path": "/fotmob/tv-guide-channels", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["us", "se", "gb", "de", "no", "es", "mx", "ar", "bo", "cl", "co", "cr", "ec", "gt", "hn", "ni", "pa", "py", "pe", "uy", "ve", "da", "ca", "au", "at", "be", "bg", "hr", "cy", "cz", "ee", "fi", "fr", "gr", "hu", "is", "ie", "il", "it", "nl", "pl", "pt", "ro", "ru", "ch", "tr", "za", "br", "in", "me", "id", "th", "mm", "al", "az", "bl", "ba", "ks", "la", "li", "mk", "rs", "sk", "ua", "essv", "nz", "bd", "cn", "gh", "hk", "jp", "kr", "ma", "mt", "my", "ng", "ph", "pk", "sg", "si", "tz"], "in": "query", "name": "country", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "fotmob-tv-guide-countries": {"id": "fotmob-tv-guide-countries", "method": "GET", "params": [], "path": "/fotmob/tv-guide-countries", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}}
23
+ JSON
24
+ OPERATION_IDS = JSON.parse(<<~'JSON').freeze
25
+ ["fotmob-audio-matches", "fotmob-fifa-ranking-periods", "fotmob-fifa-rankings", "fotmob-latest-news", "fotmob-league", "fotmob-leagues", "fotmob-lineup-builder-players", "fotmob-lineup-builder-team", "fotmob-match", "fotmob-match-media", "fotmob-matches", "fotmob-news", "fotmob-news-article", "fotmob-player", "fotmob-player-match-stats", "fotmob-player-matches", "fotmob-player-stats", "fotmob-search", "fotmob-seasons", "fotmob-stats", "fotmob-stats-categories", "fotmob-table", "fotmob-team", "fotmob-team-fixtures", "fotmob-team-news", "fotmob-transfers", "fotmob-trending-news", "fotmob-trending-searches", "fotmob-tv-guide", "fotmob-tv-guide-channels", "fotmob-tv-guide-countries"]
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-fotmob-ruby/0.1.4", 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
+ url = build_url(operation, normalized)
49
+ uri = URI.parse(url)
50
+ request = Net::HTTP::Get.new(uri)
51
+ request["x-api-key"] = @api_key
52
+ request["User-Agent"] = @user_agent
53
+ request["Accept"] = operation["produces"].include?("text/plain") ? "application/json, text/plain" : "application/json"
54
+ begin
55
+ if @transport
56
+ response = @transport.call(url, request.to_hash, @timeout)
57
+ status = Integer(response.fetch(:status) { response.fetch("status") })
58
+ body = response.fetch(:body) { response.fetch("body", "") }
59
+ headers = response.fetch(:headers) { response.fetch("headers", {}) }
60
+ content_type = headers["content-type"] || headers["Content-Type"]
61
+ else
62
+ http = Net::HTTP.new(uri.host, uri.port)
63
+ http.use_ssl = uri.scheme == "https"
64
+ http.open_timeout = @timeout
65
+ http.read_timeout = @timeout
66
+ response = http.start { |connection| connection.request(request) }
67
+ status = response.code.to_i
68
+ body = response.body
69
+ content_type = response["content-type"]
70
+ end
71
+ rescue Timeout::Error, SocketError, SystemCallError, IOError, EOFError, Net::HTTPBadResponse, Net::ProtocolError, OpenSSL::SSL::SSLError => error
72
+ raise Errors::NetworkError.new("Crawlora request failed: #{error.message}", operation_id: operation_id)
73
+ end
74
+ unless status >= 200 && status < 300
75
+ klass = status >= 500 ? Errors::ServerError : Errors::ClientError
76
+ raise klass.new("Crawlora returned HTTP #{status}", status: status, operation_id: operation_id, body: body)
77
+ end
78
+ parse_response(body, content_type, operation, normalized, response_type)
79
+ end
80
+
81
+ def close
82
+ @closed = true
83
+ end
84
+
85
+ def closed?
86
+ @closed
87
+ end
88
+
89
+ def with
90
+ return self unless block_given?
91
+ yield self
92
+ ensure
93
+ close if block_given?
94
+ end
95
+
96
+ def self.operation_count
97
+ OPERATION_COUNT
98
+ end
99
+
100
+ def self.operation_ids
101
+ OPERATION_IDS
102
+ end
103
+
104
+ def self.operations
105
+ OPERATIONS
106
+ end
107
+
108
+ define_method('audio_matches') do |**params|
109
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
110
+ request('fotmob-audio-matches', params, response_type: response_type)
111
+ end
112
+ define_method('fifa_ranking_periods') do |**params|
113
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
114
+ request('fotmob-fifa-ranking-periods', params, response_type: response_type)
115
+ end
116
+ define_method('fifa_rankings') do |**params|
117
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
118
+ request('fotmob-fifa-rankings', params, response_type: response_type)
119
+ end
120
+ define_method('latest_news') do |**params|
121
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
122
+ request('fotmob-latest-news', params, response_type: response_type)
123
+ end
124
+ define_method('league') do |**params|
125
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
126
+ request('fotmob-league', params, response_type: response_type)
127
+ end
128
+ define_method('leagues') do |**params|
129
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
130
+ request('fotmob-leagues', params, response_type: response_type)
131
+ end
132
+ define_method('lineup_builder_players') do |**params|
133
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
134
+ request('fotmob-lineup-builder-players', params, response_type: response_type)
135
+ end
136
+ define_method('lineup_builder_team') do |**params|
137
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
138
+ request('fotmob-lineup-builder-team', params, response_type: response_type)
139
+ end
140
+ define_method('match') do |**params|
141
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
142
+ request('fotmob-match', params, response_type: response_type)
143
+ end
144
+ define_method('match_media') do |**params|
145
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
146
+ request('fotmob-match-media', params, response_type: response_type)
147
+ end
148
+ define_method('matches') do |**params|
149
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
150
+ request('fotmob-matches', params, response_type: response_type)
151
+ end
152
+ define_method('news') do |**params|
153
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
154
+ request('fotmob-news', params, response_type: response_type)
155
+ end
156
+ define_method('news_article') do |**params|
157
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
158
+ request('fotmob-news-article', params, response_type: response_type)
159
+ end
160
+ define_method('player') do |**params|
161
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
162
+ request('fotmob-player', params, response_type: response_type)
163
+ end
164
+ define_method('player_match_stats') do |**params|
165
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
166
+ request('fotmob-player-match-stats', params, response_type: response_type)
167
+ end
168
+ define_method('player_matches') do |**params|
169
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
170
+ request('fotmob-player-matches', params, response_type: response_type)
171
+ end
172
+ define_method('player_stats') do |**params|
173
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
174
+ request('fotmob-player-stats', params, response_type: response_type)
175
+ end
176
+ define_method('search') do |**params|
177
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
178
+ request('fotmob-search', params, response_type: response_type)
179
+ end
180
+ define_method('seasons') do |**params|
181
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
182
+ request('fotmob-seasons', params, response_type: response_type)
183
+ end
184
+ define_method('stats') do |**params|
185
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
186
+ request('fotmob-stats', params, response_type: response_type)
187
+ end
188
+ define_method('stats_categories') do |**params|
189
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
190
+ request('fotmob-stats-categories', params, response_type: response_type)
191
+ end
192
+ define_method('table') do |**params|
193
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
194
+ request('fotmob-table', params, response_type: response_type)
195
+ end
196
+ define_method('team') do |**params|
197
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
198
+ request('fotmob-team', params, response_type: response_type)
199
+ end
200
+ define_method('team_fixtures') do |**params|
201
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
202
+ request('fotmob-team-fixtures', params, response_type: response_type)
203
+ end
204
+ define_method('team_news') do |**params|
205
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
206
+ request('fotmob-team-news', params, response_type: response_type)
207
+ end
208
+ define_method('transfers') do |**params|
209
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
210
+ request('fotmob-transfers', params, response_type: response_type)
211
+ end
212
+ define_method('trending_news') do |**params|
213
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
214
+ request('fotmob-trending-news', params, response_type: response_type)
215
+ end
216
+ define_method('trending_searches') do |**params|
217
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
218
+ request('fotmob-trending-searches', params, response_type: response_type)
219
+ end
220
+ define_method('tv_guide') do |**params|
221
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
222
+ request('fotmob-tv-guide', params, response_type: response_type)
223
+ end
224
+ define_method('tv_guide_channels') do |**params|
225
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
226
+ request('fotmob-tv-guide-channels', params, response_type: response_type)
227
+ end
228
+ define_method('tv_guide_countries') do |**params|
229
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
230
+ request('fotmob-tv-guide-countries', params, response_type: response_type)
231
+ end
232
+
233
+ private
234
+
235
+ def build_url(operation, params)
236
+ known = operation["params"].map { |param| param["name"] }
237
+ unknown = params.keys - known
238
+ raise Errors::ClientError.new("unknown parameters: #{unknown.join(', ')}", operation_id: operation["id"]) unless unknown.empty?
239
+ path = operation["path"].dup
240
+ operation["params"].select { |param| param["in"] == "path" }.each do |param|
241
+ value = params[param["name"]]
242
+ raise Errors::ClientError.new("missing path parameter: #{param['name']}", operation_id: operation["id"]) if value.nil?
243
+ path.sub!("{" + param["name"] + "}", percent_encode(value.to_s))
244
+ end
245
+ pairs = []
246
+ operation["queryParams"].each do |param|
247
+ name = param["name"]
248
+ value = params.key?(name) ? params[name] : param["default"]
249
+ if value.nil?
250
+ raise Errors::ClientError.new("missing query parameter: #{name}", operation_id: operation["id"]) if param["required"]
251
+ next
252
+ end
253
+ enum_values = param["enum"] || (param["items"] && param["items"]["enum"])
254
+ if enum_values && !(value.is_a?(Array) ? value : [value]).all? { |item| enum_values.map(&:to_s).include?(item.to_s) }
255
+ raise Errors::ClientError.new("invalid value for #{name}", operation_id: operation["id"])
256
+ end
257
+ if value.is_a?(Array)
258
+ format = param["collectionFormat"] || "csv"
259
+ if format == "multi"
260
+ value.each { |item| pairs << [name, scalar(item)] }
261
+ else
262
+ separator = {"csv" => ",", "ssv" => " ", "tsv" => "\t", "pipes" => "|"}[format] || ","
263
+ pairs << [name, value.map { |item| scalar(item) }.join(separator)]
264
+ end
265
+ else
266
+ pairs << [name, scalar(value)]
267
+ end
268
+ end
269
+ query = pairs.map { |name, value| "#{percent_encode(name)}=#{percent_encode(value)}" }.join("&")
270
+ @base_url + path + (query.empty? ? "" : "?" + query)
271
+ end
272
+
273
+ def scalar(value)
274
+ value == true ? "true" : (value == false ? "false" : value.to_s)
275
+ end
276
+
277
+ def percent_encode(value)
278
+ URI::DEFAULT_PARSER.escape(value.to_s, /[^A-Za-z0-9\-._~]/)
279
+ end
280
+
281
+ def parse_response(body, content_type, operation, params, response_type)
282
+ type = response_type.to_s
283
+ raise Errors::ClientError.new("response_type must be auto, json, or text", operation_id: operation["id"]) unless %w[auto json text].include?(type)
284
+ format = operation["params"].find { |param| param["name"] == "format" }
285
+ text_formats = format && format["enum"] ? format["enum"].reject { |value| %w[json application/json].include?(value.to_s.downcase) } : []
286
+ raw_format = params["format"] && text_formats.include?(params["format"].to_s)
287
+ 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)
288
+ is_json = json_format || content_type.to_s.downcase.include?("json") || operation["produces"] == ["application/json"]
289
+ return body if type == "text" || raw_format || (type == "auto" && !is_json)
290
+ JSON.parse(body)
291
+ rescue JSON::ParserError => error
292
+ raise Errors::Error.new("invalid JSON response from Crawlora: #{error.message}", operation_id: operation["id"], body: body)
293
+ end
294
+
295
+ public
296
+ end
297
+ end
298
+ end
@@ -0,0 +1,5 @@
1
+ module Crawlora
2
+ module Fotmob
3
+ VERSION = "0.1.4"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require_relative "fotmob/version"
2
+ require_relative "fotmob/client"
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crawlora-fotmob
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Crawlora
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-10-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Credential-free FotMob API access through Crawlora's hosted service.
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - CHANGELOG.md
20
+ - LICENSE
21
+ - README.md
22
+ - lib/crawlora/fotmob.rb
23
+ - lib/crawlora/fotmob/client.rb
24
+ - lib/crawlora/fotmob/version.rb
25
+ homepage: https://github.com/Crawlora-org/crawlora-fotmob
26
+ licenses:
27
+ - MIT
28
+ metadata:
29
+ source_code_uri: https://github.com/Crawlora-org/crawlora-fotmob
30
+ rubygems_mfa_required: 'true'
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '2.6'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubygems_version: 3.4.19
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: FotMob client for the Crawlora hosted API
50
+ test_files: []