[![Data-Golf-API](https://github.com/coreyjs/data-golf-api/actions/workflows/python-app.yml/badge.svg)](https://github.com/coreyjs/data-golf-api/actions/workflows/python-app.yml)
[![PyPI version](https://badge.fury.io/py/data_golf.svg)](https://badge.fury.io/py/data_golf)
# Data Golf API (Unofficial)
### An Unofficial API Library for DataGolf.com APIs
This is a Python library for interacting with the DataGolf APIs. DataGolf is a golf analytics platform that provides a wide range of data and analytics for golf tournaments, players, and courses.
**This is an unofficial API lib, and it is not affiliated with DataGolf in any way.**
This is being built to support some ML projects I am working on. I will be
continuing to add more endpoints as I need them. If you have a specific endpoint you need, please open a ticket for submit a PR.
---
## Developer Note:
This is in development. Code structure will change as I get
all the endpoints added. So expect some renaming and convention changes.
### Contact
Im available on [Bluesky](https://bsky.app/profile/coreyjs.dev) for any questions or just general chats about enhancements.
---
# Usage + Installation & Setup
(Currently this only supports JSON formats, CSV is on the roadmap)
```python
pip install data_golf
```
```python
from data_golf import DataGolfClient
client = DataGolfClient(api_key="YOUR_API_KEY")
# For more request logging
client = DataGolfClient(api_key="YOUR_API_KEY", verbose=True)
```
---
# Main Modules
These modules map directly to the [DataGolf API Documentation](https://datagolf.com/api-access) available on their site:
1. General
2. Predictions
3. Live Predictions
The Data Golf API is a paid service via [DataGolf.com](https://datagolf.com/api-access), there they will provide you with an API Key. This library is
only a helper utility, to make interacting and consuming the API easier.
---
# General APIs
### Player List
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/get-player-list`
**Method:** GET
**Formats:** JSON
</details>
```python
players = client.general.player_list()
```
### Current Season Tour Schedule
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/get-schedule`
**Method:** GET
**Formats:** JSON
| Param | Type | Ex |
|-------|--------|---------------------------------------------------------------------------|
| tour | str | all, pga, euro, kft, alt, liv |
</details>
```python
# Can use optinal parameter 'tour' to filter by tour: pga, euro, kft, alt, liv
tour_schedule = client.general.tour_schedule()
tour_schedule = client.general.tour_schedule(tour="pga")
tour_schedule = client.general.tour_schedule(tour="liv")
```
### Field Updates
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/field-updates`
**Method:** GET
**Formats:** JSON
| Param | Type | Ex |
|-------|--------|---------------------------------------------------------------------------|
| tour | str | all, pga, euro, kft, alt, liv |
</details>
```python
# tour = pga (default), euro, kft, opp, alt
rsp = client.general.field_updates() # defaults to pga
rsp = client.general.field_updates(tour="kft")
```
---
# Model Prediction APIs
## Rankings
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/preds/get-dg-rankings`
**Method:** GET
**Formats:** JSON
</details>
```python
rankings = client.predictions.rankings()
```
## Pre Tournament Predictions
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/preds/pre-tournament`
**Method:** GET
**Formats:** JSON
</details>
```python
rsp = client.predictions.pre_tournament()
rsp = client.predictions.pre_tournament(
tour='pga',
dead_heat=True,
odds_format='american'
)
```
## Pre Tournament Prediction Archive
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/preds/pre-tournament-archive`
**Method:** GET
**Formats:** JSON
</details>
```python
# Supports optional parameters event_id:, year:, odds_format:
rsp = client.predictions.pre_tournament_pred_archive()
rsp = client.predictions.pre_tournament_pred_archive(
year=2021,
)
```
## Player Skill Decomposition
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/preds/player-decompositions`
**Method:** GET
**Formats:** JSON
</details>
```python
# Supports optional parameters tour:
rsp = client.predictions.player_skill_decompositions()
rsp = client.predictions.player_skill_decompositions(tour='alt')
```
## Player Skill Ratings
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/preds/skill-ratings`
**Method:** GET
**Formats:** JSON
</details>
```python
# Supports optional param display: (value, rank)
rsp = client.predictions.player_skill_ratings()
rsp = client.predictions.player_skill_ratings(display="rank")
```
## Detailed Approach Skill
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/preds/approach-skill`
**Method:** GET
**Formats:** JSON
| Param | Type | Ex |
|--------|--------|---------------------------------------------------------------------------|
| period | str | l24 (last 24 months) (default), <br/> l12 (last 12 months), ytd (year to date) |
</details>
```python
rsp = client.predictions.detailed_approach_skill()
rsp = client.predictions.detailed_approach_skill(period='ytd')
```
## Fantasy Projections
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/preds/fantasy-projection-defaults`
**Method:** GET
**Formats:** JSON
| Param | Type | Ex |
|-------|-----|---------------------------------------------------------------|
| tour | str | pga (default), euro, opp (opposite field PGA TOUR event), alt |
| site | str | draftkings (default), fanduel, yahoo |
| slate | str | main (default), showdown, showdown_late, weekend, captain |
</details>
```python
rsp = client.predictions.fantasy_projection()
rsp = client.predictions.fantasy_projection(tour='pga', site='fanduel', slate='showdown')
```
---
# Live Predictions
### Live Model Predictions
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/preds/in-play`
**Method:** GET
**Formats:** JSON
| Param | Type | Ex |
|-------------|------|---------------------------------------------------------------|
| tour | str | pga (default), euro, opp (opposite field PGA TOUR event), alt |
| dead_head | bool | False (default), True |
| odds_format | str | percent (default), american, decimal, fraction |
</details>
```python
data = dg.live_predictions.live_in_play()
data = dg.live_predictions.live_in_play(tour='kft', odds_format='american')
```
### Live Tournament Stats
Returns live strokes-gained and traditional stats for every player during PGA Tour tournaments.
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/preds/live-tournament-stats`
**Method:** GET
**Formats:** JSON
| Param | Type | Ex |
|---------|---------|---------------------------------------------------------------|
| stats | csv str | Comma-separated list of statistics to be returned. Supports: sg_putt, sg_arg, sg_app, sg_ott, sg_t2g, sg_bs, sg_total, <br/>distance, accuracy, gir, prox_fw, prox_rgh, scrambling |
| round | str | event_avg, 1, 2, 3, 4 |
| display | str | value (default), rank |
</details>
```python
data = dg.live_predictions.live_tournament_stats()
data = dg.live_predictions.live_tournament_stats(stats="sq_arg, sg_bs", disppaly="rank")
```
### Live Hole Scoring Distruibution
Returns live hole scoring averages and distrubutions (birdies, pars, bogeys, etc.) broken down by tee time wave.
<details>
<summary>API Endpoint Info</summary>
**Endpoint:** `/preds/live-hole-stats`
**Method:** GET
**Formats:** JSON
| Param | Type | Ex |
|---------|------|--------------------------------------------------------------|
| tour | str | pga (default), euro, opp (opposite field PGA TOUR event), kft, alt |
| round | str | event_avg, 1, 2, 3, 4 |
| display | str | value (default), rank |
</details>
```python
data = dg.live_predictions.live_hole_stats()
data = dg.live_predictions.live_hole_stats(tour='kft')
```
Raw data
{
"_id": null,
"home_page": "https://github.com/coreyjs/data-golf-api",
"name": "data_golf",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "golf, datagolf, data golf, golf data, golf AI, golf machine learning, golf ML, golf stats",
"author": "Corey Schaf",
"author_email": "cschaf@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/90/13/88f944576acf395ebe81f10d072d1f1d9d7c4757572182a8f5629f094600/data_golf-0.4.0.tar.gz",
"platform": null,
"description": "[![Data-Golf-API](https://github.com/coreyjs/data-golf-api/actions/workflows/python-app.yml/badge.svg)](https://github.com/coreyjs/data-golf-api/actions/workflows/python-app.yml)\n[![PyPI version](https://badge.fury.io/py/data_golf.svg)](https://badge.fury.io/py/data_golf)\n\n\n# Data Golf API (Unofficial)\n\n### An Unofficial API Library for DataGolf.com APIs\n\nThis is a Python library for interacting with the DataGolf APIs. DataGolf is a golf analytics platform that provides a wide range of data and analytics for golf tournaments, players, and courses.\n\n**This is an unofficial API lib, and it is not affiliated with DataGolf in any way.**\n\n\nThis is being built to support some ML projects I am working on. I will be \ncontinuing to add more endpoints as I need them. If you have a specific endpoint you need, please open a ticket for submit a PR.\n\n---\n## Developer Note:\nThis is in development. Code structure will change as I get\nall the endpoints added. So expect some renaming and convention changes.\n\n### Contact\nIm available on [Bluesky](https://bsky.app/profile/coreyjs.dev) for any questions or just general chats about enhancements.\n\n---\n# Usage + Installation & Setup\n(Currently this only supports JSON formats, CSV is on the roadmap)\n\n```python\npip install data_golf\n```\n\n```python\nfrom data_golf import DataGolfClient\n\nclient = DataGolfClient(api_key=\"YOUR_API_KEY\")\n\n# For more request logging\nclient = DataGolfClient(api_key=\"YOUR_API_KEY\", verbose=True)\n```\n\n---\n\n# Main Modules\n\nThese modules map directly to the [DataGolf API Documentation](https://datagolf.com/api-access) available on their site:\n\n1. General\n2. Predictions\n3. Live Predictions\n\nThe Data Golf API is a paid service via [DataGolf.com](https://datagolf.com/api-access), there they will provide you with an API Key. This library is\nonly a helper utility, to make interacting and consuming the API easier.\n---\n\n# General APIs\n\n### Player List\n\n<details>\n <summary>API Endpoint Info</summary>\n\n**Endpoint:** `/get-player-list` \n**Method:** GET \n**Formats:** JSON\n\n</details>\n\n```python\nplayers = client.general.player_list()\n```\n\n\n### Current Season Tour Schedule\n\n<details>\n <summary>API Endpoint Info</summary>\n\n**Endpoint:** `/get-schedule` \n**Method:** GET \n**Formats:** JSON\n\n| Param | Type | Ex |\n|-------|--------|---------------------------------------------------------------------------|\n| tour | str | all, pga, euro, kft, alt, liv |\n\n</details>\n\n```python\n# Can use optinal parameter 'tour' to filter by tour: pga, euro, kft, alt, liv\ntour_schedule = client.general.tour_schedule()\ntour_schedule = client.general.tour_schedule(tour=\"pga\")\ntour_schedule = client.general.tour_schedule(tour=\"liv\")\n```\n\n### Field Updates\n\n<details>\n <summary>API Endpoint Info</summary>\n\n**Endpoint:** `/field-updates` \n**Method:** GET \n**Formats:** JSON\n\n| Param | Type | Ex |\n|-------|--------|---------------------------------------------------------------------------|\n| tour | str | all, pga, euro, kft, alt, liv |\n\n</details>\n\n```python\n# tour = pga (default), euro, kft, opp, alt\nrsp = client.general.field_updates() # defaults to pga\nrsp = client.general.field_updates(tour=\"kft\")\n```\n\n---\n\n# Model Prediction APIs\n\n## Rankings\n\n<details>\n <summary>API Endpoint Info</summary>\n\n\n**Endpoint:** `/preds/get-dg-rankings` \n**Method:** GET \n**Formats:** JSON\n\n</details>\n\n```python\nrankings = client.predictions.rankings()\n```\n\n## Pre Tournament Predictions\n\n<details>\n <summary>API Endpoint Info</summary>\n\n**Endpoint:** `/preds/pre-tournament` \n**Method:** GET \n**Formats:** JSON\n\n</details>\n\n```python\nrsp = client.predictions.pre_tournament()\n\nrsp = client.predictions.pre_tournament(\n tour='pga',\n dead_heat=True,\n odds_format='american'\n)\n```\n\n## Pre Tournament Prediction Archive\n\n<details>\n <summary>API Endpoint Info</summary>\n\n**Endpoint:** `/preds/pre-tournament-archive` \n**Method:** GET \n**Formats:** JSON\n\n</details>\n\n```python\n# Supports optional parameters event_id:, year:, odds_format:\nrsp = client.predictions.pre_tournament_pred_archive()\n\nrsp = client.predictions.pre_tournament_pred_archive(\n year=2021,\n)\n```\n\n## Player Skill Decomposition\n\n<details>\n <summary>API Endpoint Info</summary>\n\n**Endpoint:** `/preds/player-decompositions` \n**Method:** GET \n**Formats:** JSON\n\n</details>\n\n```python\n# Supports optional parameters tour:\nrsp = client.predictions.player_skill_decompositions()\nrsp = client.predictions.player_skill_decompositions(tour='alt')\n```\n\n## Player Skill Ratings\n\n<details>\n <summary>API Endpoint Info</summary>\n\n**Endpoint:** `/preds/skill-ratings` \n**Method:** GET \n**Formats:** JSON\n\n</details>\n\n```python\n# Supports optional param display: (value, rank)\nrsp = client.predictions.player_skill_ratings()\nrsp = client.predictions.player_skill_ratings(display=\"rank\")\n```\n\n## Detailed Approach Skill\n\n<details>\n <summary>API Endpoint Info</summary>\n\n**Endpoint:** `/preds/approach-skill` \n**Method:** GET \n**Formats:** JSON\n\n| Param | Type | Ex |\n|--------|--------|---------------------------------------------------------------------------|\n| period | str | l24 (last 24 months) (default), <br/> l12 (last 12 months), ytd (year to date) |\n\n</details>\n\n```python\nrsp = client.predictions.detailed_approach_skill()\nrsp = client.predictions.detailed_approach_skill(period='ytd')\n```\n\n## Fantasy Projections\n<details>\n <summary>API Endpoint Info</summary>\n\n\n**Endpoint:** `/preds/fantasy-projection-defaults` \n**Method:** GET \n**Formats:** JSON\n\n| Param | Type | Ex |\n|-------|-----|---------------------------------------------------------------|\n| tour | str | pga (default), euro, opp (opposite field PGA TOUR event), alt |\n| site | str | draftkings (default), fanduel, yahoo |\n| slate | str | main (default), showdown, showdown_late, weekend, captain |\n\n</details>\n\n```python\nrsp = client.predictions.fantasy_projection()\nrsp = client.predictions.fantasy_projection(tour='pga', site='fanduel', slate='showdown')\n```\n\n---\n\n# Live Predictions\n\n\n### Live Model Predictions\n\n<details>\n <summary>API Endpoint Info</summary>\n\n\n**Endpoint:** `/preds/in-play` \n**Method:** GET \n**Formats:** JSON\n\n| Param | Type | Ex |\n|-------------|------|---------------------------------------------------------------|\n| tour | str | pga (default), euro, opp (opposite field PGA TOUR event), alt |\n| dead_head | bool | False (default), True |\n| odds_format | str | percent (default), american, decimal, fraction |\n\n</details>\n\n```python\ndata = dg.live_predictions.live_in_play()\ndata = dg.live_predictions.live_in_play(tour='kft', odds_format='american')\n```\n\n\n### Live Tournament Stats\n\nReturns live strokes-gained and traditional stats for every player during PGA Tour tournaments.\n\n\n<details>\n <summary>API Endpoint Info</summary>\n\n\n**Endpoint:** `/preds/live-tournament-stats` \n**Method:** GET \n**Formats:** JSON\n\n| Param | Type | Ex |\n|---------|---------|---------------------------------------------------------------|\n| stats | csv str | Comma-separated list of statistics to be returned. Supports: sg_putt, sg_arg, sg_app, sg_ott, sg_t2g, sg_bs, sg_total, <br/>distance, accuracy, gir, prox_fw, prox_rgh, scrambling |\n| round | str | event_avg, 1, 2, 3, 4 |\n| display | str | value (default), rank |\n\n</details>\n\n```python\ndata = dg.live_predictions.live_tournament_stats()\ndata = dg.live_predictions.live_tournament_stats(stats=\"sq_arg, sg_bs\", disppaly=\"rank\")\n```\n\n\n### Live Hole Scoring Distruibution\n\nReturns live hole scoring averages and distrubutions (birdies, pars, bogeys, etc.) broken down by tee time wave.\n\n\n<details>\n <summary>API Endpoint Info</summary>\n\n\n**Endpoint:** `/preds/live-hole-stats` \n**Method:** GET \n**Formats:** JSON\n\n| Param | Type | Ex |\n|---------|------|--------------------------------------------------------------|\n| tour | str | pga (default), euro, opp (opposite field PGA TOUR event), kft, alt |\n| round | str | event_avg, 1, 2, 3, 4 |\n| display | str | value (default), rank |\n\n</details>\n\n```python\ndata = dg.live_predictions.live_hole_stats()\ndata = dg.live_predictions.live_hole_stats(tour='kft')\n```\n\n\n\n\n\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "API Wrapper for DataGolf.com endpoints.",
"version": "0.4.0",
"project_urls": {
"Homepage": "https://github.com/coreyjs/data-golf-api",
"Repository": "https://github.com/coreyjs/data-golf-api"
},
"split_keywords": [
"golf",
" datagolf",
" data golf",
" golf data",
" golf ai",
" golf machine learning",
" golf ml",
" golf stats"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3e778259d024ba161b44dd1ecf6f27ec974b1141898d5fbc9fbf6ada167e6fd7",
"md5": "2fa96da0f2cc14c2877b8480bb2c513e",
"sha256": "33e77cc6ba1a00c691924f0550db1753ee84ce551ef66d5d91fecafc78b5a5a9"
},
"downloads": -1,
"filename": "data_golf-0.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2fa96da0f2cc14c2877b8480bb2c513e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 10087,
"upload_time": "2024-06-12T21:18:28",
"upload_time_iso_8601": "2024-06-12T21:18:28.488792Z",
"url": "https://files.pythonhosted.org/packages/3e/77/8259d024ba161b44dd1ecf6f27ec974b1141898d5fbc9fbf6ada167e6fd7/data_golf-0.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "901388f944576acf395ebe81f10d072d1f1d9d7c4757572182a8f5629f094600",
"md5": "0e6833f9622a2915c7c94349dd94bc37",
"sha256": "007c70d1e7906b000f26dbe8c4530e19fcba3120a0959f6b13758ac26a10e3ef"
},
"downloads": -1,
"filename": "data_golf-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "0e6833f9622a2915c7c94349dd94bc37",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 9186,
"upload_time": "2024-06-12T21:18:29",
"upload_time_iso_8601": "2024-06-12T21:18:29.558660Z",
"url": "https://files.pythonhosted.org/packages/90/13/88f944576acf395ebe81f10d072d1f1d9d7c4757572182a8f5629f094600/data_golf-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-12 21:18:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "coreyjs",
"github_project": "data-golf-api",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "data_golf"
}