datafc 2.0.0__tar.gz → 2.2.0__tar.gz

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.
Files changed (57) hide show
  1. {datafc-2.0.0 → datafc-2.2.0}/PKG-INFO +68 -25
  2. {datafc-2.0.0 → datafc-2.2.0}/README.md +951 -908
  3. {datafc-2.0.0 → datafc-2.2.0}/datafc/__init__.py +2 -1
  4. {datafc-2.0.0 → datafc-2.2.0}/datafc/exceptions.py +46 -46
  5. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/__init__.py +82 -80
  6. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/_parsers.py +560 -524
  7. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/aio.py +2394 -2327
  8. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_average_positions_data.py +91 -91
  9. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_coordinates_data.py +102 -102
  10. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_goal_networks_data.py +148 -148
  11. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_incidents_data.py +87 -87
  12. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_league_player_stats_data.py +165 -165
  13. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_lineups_data.py +80 -80
  14. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_match_data.py +84 -84
  15. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_match_details_data.py +92 -92
  16. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_match_h2h_data.py +82 -82
  17. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_match_odds_data.py +73 -73
  18. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_match_stats_data.py +80 -80
  19. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_momentum_data.py +80 -80
  20. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_past_matches_data.py +140 -140
  21. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_player_career_stats_data.py +124 -124
  22. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_player_data.py +132 -132
  23. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_player_match_log_data.py +126 -126
  24. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_player_national_team_data.py +108 -108
  25. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_player_stats_data.py +126 -126
  26. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_player_transfers_data.py +122 -122
  27. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_pregame_form_data.py +109 -109
  28. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_referee_stats_data.py +104 -104
  29. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_search_data.py +93 -93
  30. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_season_rounds_data.py +99 -99
  31. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_seasons_data.py +86 -86
  32. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_shots_data.py +80 -80
  33. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_squad_data.py +124 -124
  34. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_standings_data.py +80 -80
  35. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_substitutions_data.py +80 -80
  36. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_team_data.py +132 -132
  37. datafc-2.2.0/datafc/sofascore/fetch_team_match_history_data.py +108 -0
  38. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_team_stats_data.py +123 -123
  39. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_team_transfers_data.py +128 -128
  40. {datafc-2.0.0 → datafc-2.2.0}/datafc/sofascore/fetch_upcoming_matches_data.py +105 -105
  41. {datafc-2.0.0 → datafc-2.2.0}/datafc/utils/__init__.py +35 -35
  42. {datafc-2.0.0 → datafc-2.2.0}/datafc/utils/_async_client.py +164 -164
  43. {datafc-2.0.0 → datafc-2.2.0}/datafc/utils/_cache.py +142 -142
  44. {datafc-2.0.0 → datafc-2.2.0}/datafc/utils/_client.py +136 -136
  45. {datafc-2.0.0 → datafc-2.2.0}/datafc/utils/_config.py +102 -93
  46. {datafc-2.0.0 → datafc-2.2.0}/datafc/utils/_helpers.py +26 -26
  47. {datafc-2.0.0 → datafc-2.2.0}/datafc/utils/_save_files.py +142 -142
  48. {datafc-2.0.0 → datafc-2.2.0}/datafc/utils/_tournament_info.py +66 -66
  49. {datafc-2.0.0 → datafc-2.2.0}/datafc/utils/_validate.py +99 -98
  50. {datafc-2.0.0 → datafc-2.2.0}/datafc.egg-info/PKG-INFO +68 -25
  51. {datafc-2.0.0 → datafc-2.2.0}/datafc.egg-info/SOURCES.txt +1 -0
  52. {datafc-2.0.0 → datafc-2.2.0}/pyproject.toml +55 -55
  53. {datafc-2.0.0 → datafc-2.2.0}/LICENSE +0 -0
  54. {datafc-2.0.0 → datafc-2.2.0}/datafc.egg-info/dependency_links.txt +0 -0
  55. {datafc-2.0.0 → datafc-2.2.0}/datafc.egg-info/requires.txt +0 -0
  56. {datafc-2.0.0 → datafc-2.2.0}/datafc.egg-info/top_level.txt +0 -0
  57. {datafc-2.0.0 → datafc-2.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datafc
3
- Version: 2.0.0
3
+ Version: 2.2.0
4
4
  Summary: Fetch, process, and export structured football data.
5
5
  Author-email: Uraz Akgül <urazdev@gmail.com>
6
6
  License: MIT
@@ -24,11 +24,11 @@ Requires-Dist: pytest>=8.0; extra == "dev"
24
24
  Requires-Dist: pytest-mock>=3.12; extra == "dev"
25
25
  Dynamic: license-file
26
26
 
27
- # datafc v2.0.0
27
+ # datafc v2.2.0
28
28
 
29
29
  ## Overview
30
30
 
31
- `datafc` fetches, processes, and exports structured football data. It provides **32 functions** covering tournament metadata, standings, squad rosters, match fixtures, shots, lineups, player heatmaps, odds, and more — all returning clean `pandas` DataFrames ready for analysis. Sofascore is currently the only supported data source.
31
+ `datafc` fetches, processes, and exports structured football data. It provides **33 functions** covering tournament metadata, standings, squad rosters, match fixtures, shots, lineups, player heatmaps, odds, and more — all returning clean `pandas` DataFrames ready for analysis. Sofascore is currently the only supported data source.
32
32
 
33
33
  > **Finding IDs:** `tournament_id` and `season_id` can be discovered two ways:
34
34
  > - **From the URL:** navigating to a league page on Sofascore (e.g. `sofascore.com/.../trendyol-super-lig/52#id:63814`) shows `tournament_id=52` and `season_id=63814`.
@@ -60,6 +60,7 @@ Dynamic: license-file
60
60
  | `player_stats_data` | Top player stats per team (goals, assists, key passes, …) |
61
61
  | `squad_data` | Squad roster with age, height, market value, contract expiry |
62
62
  | `upcoming_matches_data` | Upcoming fixtures for all teams in the standings |
63
+ | `team_match_history_data` | Full match history for a team across all competitions |
63
64
  | `league_player_stats_data` | Wide-format player rankings, sortable by any metric |
64
65
 
65
66
  ### Matchweek
@@ -425,6 +426,26 @@ Dependencies: `standings_data`
425
426
 
426
427
  ---
427
428
 
429
+ #### `team_match_history_data`
430
+
431
+ Fetch the complete match history for a single team across all competitions.
432
+
433
+ ```python
434
+ from datafc import team_match_history_data
435
+
436
+ df = team_match_history_data(team_id=4748) # Brazil
437
+ ```
438
+
439
+ The `team_id` can be obtained from `standings_data()`, `squad_data()`, or `search_data()`.
440
+
441
+ Columns: `country`, `tournament`, `season`, `week`, `game_id`, `home_team`, `home_team_id`, `away_team`, `away_team_id`, `home_score_period1`, `home_score_period2`, `home_score_normaltime`, `home_score_display`, `home_score_current`, `away_score_period1`, `away_score_period2`, `away_score_normaltime`, `away_score_display`, `away_score_current`, `start_timestamp`, `status`.
442
+
443
+ > **Note:** Results span all competitions in Sofascore's database (league, cup, international). Filter by the `tournament` column to narrow down to a specific competition.
444
+
445
+ Dependencies: none
446
+
447
+ ---
448
+
428
449
  #### `upcoming_matches_data`
429
450
 
430
451
  Fetch upcoming fixtures for all teams currently in the standings.
@@ -509,15 +530,34 @@ ucl_df = match_data(
509
530
  tournament_type="uefa",
510
531
  tournament_stage="round_of_16",
511
532
  )
533
+
534
+ # World Cup knockout stages — week_number not needed:
535
+ wc_df = match_data(
536
+ tournament_id=16,
537
+ season_id=58210,
538
+ tournament_type="world_cup",
539
+ tournament_stage="round_of_16",
540
+ )
541
+
542
+ # World Cup group stage — week_number required:
543
+ wc_group_df = match_data(
544
+ tournament_id=16,
545
+ season_id=58210,
546
+ week_number=1,
547
+ tournament_type="world_cup",
548
+ tournament_stage="group_stage_week",
549
+ )
512
550
  ```
513
551
 
514
552
  Parameters:
515
553
 
516
554
  - `tournament_id` (int)
517
555
  - `season_id` (int)
518
- - `week_number` (int)
519
- - `tournament_type` (str, optional): `"uefa"` for UEFA competitions. `None` assumes a domestic league.
520
- - `tournament_stage` (str, optional): Required when `tournament_type="uefa"`. Options: `preliminary_semifinals`, `preliminary_final`, `qualification_round`, `qualification_playoff`, `group_stage_week`, `playoff_round`, `round_of_16`, `quarterfinals`, `semifinals`, `match_for_3rd_place`, `final`.
556
+ - `week_number` (int, optional): Required for league rounds, UEFA stages, and `world_cup` + `group_stage_week`. Not needed for other `world_cup` stages.
557
+ - `tournament_type` (str, optional): `"uefa"` for UEFA competitions, `"world_cup"` for FIFA World Cup. `None` assumes a domestic league.
558
+ - `tournament_stage` (str, optional): Required when `tournament_type` is set.
559
+ - `"uefa"` options: `preliminary_semifinals`, `preliminary_final`, `qualification_round`, `qualification_playoff`, `group_stage_week`, `playoff_round`, `round_of_16`, `quarterfinals`, `semifinals`, `match_for_3rd_place`, `final`.
560
+ - `"world_cup"` options: `group_stage_week`, `round_of_32`, `round_of_16`, `quarterfinals`, `semifinals`, `match_for_3rd_place`, `final`.
521
561
 
522
562
  Columns: `country`, `tournament`, `season`, `week`, `game_id`, `home_team`, `home_team_id`, `away_team`, `away_team_id`, `injury_time_1`, `injury_time_2`, `start_timestamp`, `status`, `home_score_current`, `home_score_display`, `home_score_period1`, `home_score_period2`, `home_score_normaltime`, `away_score_current`, `away_score_display`, `away_score_period1`, `away_score_period2`, `away_score_normaltime`.
523
563
 
@@ -754,9 +794,9 @@ Parameters:
754
794
 
755
795
  - `tournament_id` (int)
756
796
  - `season_id` (int)
757
- - `week_number` (int)
758
- - `tournament_type` (str, optional): `"uefa"` for UEFA competitions.
759
- - `tournament_stage` (str, optional): Required when `tournament_type="uefa"`. Same options as `match_data`.
797
+ - `week_number` (int, optional): Required for league rounds, UEFA stages, and `world_cup` + `group_stage_week`. Not needed for other `world_cup` stages.
798
+ - `tournament_type` (str, optional): `"uefa"` for UEFA competitions, `"world_cup"` for FIFA World Cup.
799
+ - `tournament_stage` (str, optional): Required when `tournament_type` is set. Same options as `match_data`.
760
800
 
761
801
  Same columns as `match_data`.
762
802
 
@@ -876,29 +916,32 @@ Columns: `referee_id`, `referee_name`, `tournament_id`, `tournament_name`, `stat
876
916
 
877
917
  ## Changelog
878
918
 
879
- ### v2.0.0
880
-
881
- **Chrome / Selenium removed — no browser required.** datafc now makes direct HTTP requests. Installation is simpler, and fetches are significantly faster than before.
919
+ ### v2.2.0
882
920
 
883
- **18 new functions.** `seasons_data`, `season_rounds_data`, `team_data`, `team_transfers_data`, `upcoming_matches_data`, `league_player_stats_data`, `match_details_data`, `match_h2h_data`, `pregame_form_data`, `incidents_data`, `average_positions_data`, `player_data`, `player_transfers_data`, `player_career_stats_data`, `player_national_team_data`, `player_match_log_data`, `referee_stats_data`, `search_data`.
921
+ - Added `tournament_type="world_cup"` support to `match_data` and `past_matches_data` for FIFA World Cup competitions. Knockout stage rounds are fixed internally; only `group_stage_week` requires `week_number`.
922
+ - `week_number` is now optional (`None` by default). It is required for league rounds, UEFA stages, and `world_cup` + `group_stage_week`. Omitting it when required raises `InvalidParameterError`.
884
923
 
885
- **Async API.** All 32 functions are available in `datafc.aio` for parallel fetching with `asyncio.gather()`, letting you download an entire matchweek's worth of data concurrently.
886
-
887
- **Disk caching.** Pass a `DiskCache` instance to any function to avoid re-fetching data you've already downloaded. Cached responses are returned instantly on subsequent calls.
888
-
889
- **Automatic rate limiting and retries.** All functions accept a `rate_limit` parameter. Temporary failures (rate limits, server errors) are retried automatically without any extra code on your side.
890
-
891
- **New Parquet export.** Use `save_parquet()` on any DataFrame returned by a fetch function to save output as `.parquet`. Requires `pyarrow` (`pip install datafc[parquet]`).
924
+ ---
892
925
 
893
- **Heatmap fetch no longer crashes on partial access errors.** `coordinates_data` now skips players that the API refuses to serve and returns data for everyone else. The function only raises an error if no player yields any coordinates at all.
926
+ ### v2.1.0
894
927
 
895
- **Exported filenames are human-readable.** JSON, Excel, and Parquet files now use the league name (e.g. `trendyol_superlig_shots_data.json`) instead of raw numeric IDs. Turkish and other non-ASCII characters are transliterated correctly — `Şampiyonlar` becomes `sampiyonlar`, not `ampiyonlar`.
928
+ - Added `team_match_history_data`: fetches the complete match history for a single team across all competitions using `team_id` directly (no standings dependency).
896
929
 
897
- **Valid JSON output.** Exported `.json` files no longer contain invalid `NaN` literals; they use `null` instead, making them compatible with every JSON parser and spreadsheet tool.
930
+ ---
898
931
 
899
- **Cleaner numeric columns.** Score fields, ratings, and market values that were previously returned as strings or empty strings are now proper numeric types (`null` when missing, not `""`).
932
+ ### v2.0.0
900
933
 
901
- **Clearer errors.** When something goes wrong, the exception type tells you what happened: data not available, invalid parameter, API access error, rate limit hit, or server error.
934
+ - **Chrome / Selenium removed no browser required.** datafc now makes direct HTTP requests. Installation is simpler, and fetches are significantly faster than before.
935
+ - **18 new functions.** `seasons_data`, `season_rounds_data`, `team_data`, `team_transfers_data`, `upcoming_matches_data`, `league_player_stats_data`, `match_details_data`, `match_h2h_data`, `pregame_form_data`, `incidents_data`, `average_positions_data`, `player_data`, `player_transfers_data`, `player_career_stats_data`, `player_national_team_data`, `player_match_log_data`, `referee_stats_data`, `search_data`.
936
+ - **Async API.** All functions are available in `datafc.aio` for parallel fetching with `asyncio.gather()`, letting you download an entire matchweek's worth of data concurrently.
937
+ - **Disk caching.** Pass a `DiskCache` instance to any function to avoid re-fetching data you've already downloaded. Cached responses are returned instantly on subsequent calls.
938
+ - **Automatic rate limiting and retries.** All functions accept a `rate_limit` parameter. Temporary failures (rate limits, server errors) are retried automatically without any extra code on your side.
939
+ - **New Parquet export.** Use `save_parquet()` on any DataFrame returned by a fetch function to save output as `.parquet`. Requires `pyarrow` (`pip install datafc[parquet]`).
940
+ - **Heatmap fetch no longer crashes on partial access errors.** `coordinates_data` now skips players that the API refuses to serve and returns data for everyone else. The function only raises an error if no player yields any coordinates at all.
941
+ - **Exported filenames are human-readable.** JSON, Excel, and Parquet files now use the league name (e.g. `trendyol_superlig_shots_data.json`) instead of raw numeric IDs. Turkish and other non-ASCII characters are transliterated correctly — `Şampiyonlar` becomes `sampiyonlar`, not `ampiyonlar`.
942
+ - **Valid JSON output.** Exported `.json` files no longer contain invalid `NaN` literals; they use `null` instead, making them compatible with every JSON parser and spreadsheet tool.
943
+ - **Cleaner numeric columns.** Score fields, ratings, and market values that were previously returned as strings or empty strings are now proper numeric types (`null` when missing, not `""`).
944
+ - **Clearer errors.** When something goes wrong, the exception type tells you what happened: data not available, invalid parameter, API access error, rate limit hit, or server error.
902
945
 
903
946
  ### v1.5.0
904
947