A Python Library for Consuming Transactions from Pro Sports Transactions (https://www.prosportstransactions.com)
Project description
Pro Sports Transactions API
Pro Sports Transactions is a Python API client-library for https://www.prosportstransactions.com enabling software engineers, data scientists, and sports fans with the ability to easily retrieve trades, free agent movements, signings, injuries, disciplinary actions, legal/criminal actions, and much more for five of the North American professional leagues: MLB, MLS, NBA, NFL, and NHL.
About
What is sports data without the transactions?
- "Did he just throw his mouthpiece into the stands?"
- "Yep."
2023-01-27 | Warriors | • Stephen Curry | fined $25,000 by NBA for throwing his mouthpiece into the stands
Getting Started
Usage
from datetime import date
import asyncio
import pro_sports_transactions as pst
# League (MLB, MLS, NBA, NFL, and NHL)
league = pst.League.NBA
# Disciplinary Actions, Injured List, Injuries,
# Legal Incidents, Minor League To/For, Personal Reasons,
# and Movement (e.g., Trades, Acquisitions, Waivers, Draft Picks, etc.)
transaction_types = tuple([t for t in pst.TransactionType])
# From the start of the 2022-23 NBA Regular Season
start_date = date.fromisoformat("2022-10-18")
# From the end of the 2022-23 NBA Regular Season
end_date = date.fromisoformat("2023-04-09")
# Pro Sports Transactions provides 25 rows (one page) at a time.
# The first row of the first page is always 0, and ends with 24.
# The first row of the second page is always 25, and ends with 49.
# Note: If the starting_row is set to 9; the 10th row of the results,
# then the last row of the first page wil be 34 (9 + 25)..
starting_row = 0
# Define the corouting that will be called by our code
async def search_transactions() -> str:
# How to Search for Transactions
return await pst.Search(
# Required
league=league,
# Required (at least one)
transaction_types=transaction_types,
# Optional
start_date=start_date,
# Optional
end_date=end_date,
# Optional
player="LeBron James",
# Optional
team="Lakers",
# Optional
starting_row=starting_row,
).get_dataframe() # Supports get_dict(), and get_json()
# Example execution block
if __name__ == "__main__":
df = asyncio.run(search_transactions())
Results
# DataFrame
print(df)
# returns
Date Team Acquired Relinquished Notes
0 2022-11-10 Lakers • LeBron James placed on IL with strained left adductor
1 2022-11-25 Lakers • LeBron James activated from IL
2 2022-12-07 Lakers • LeBron James placed on IL with sore left ankle
3 2022-12-09 Lakers • LeBron James activated from IL
4 2022-12-19 Lakers • LeBron James placed on IL with sore left ankle
5 2022-12-21 Lakers • LeBron James activated from IL
6 2023-01-09 Lakers • LeBron James placed on IL with sore left ankle
7 2023-01-12 Lakers • LeBron James activated from IL
8 2023-02-09 Lakers • LeBron James placed on IL with sore left ankle
9 2023-02-15 Lakers • LeBron James activated from IL
10 2023-02-27 Lakers • LeBron James placed on IL with right foot injury
11 2023-03-26 Lakers • LeBron James activated from IL
# Pages
print(df.attrs["pages])
# returns
1
Requirements
Pro Sports Transactions presents data in an HTML table. To make retrieval easy, pandas.read_html
is used which in turn results in additional depencies. The following are a list of required libraries:
- python = "^3.11"
- aiohttp = "^3.8.4"
- pandas = "^2.0.0"
- brotli = "^1.0.9"
- lxml = "^4.9.2"
- html5lib = "^1.1"
- bs4 = "^0.0.1"
Thank You Frank Marousek!
Huge thanks to Frank Marousek @ Pro Sports Transactions for all of his efforts, and the efforts of those who have helped him, in compiling an excellent source of transactional information.
Disclaimer on accuracy, usage, and completeness of information.
The Pro Sports Transactions API is in no way affiliated with Pro Sports Transactions. The Pro Sports Transactions API provides a means for programatic access to Pro Sports Transactions. While the The Pro Sports Transactions API is open source under an MIT License, usage of all information obtained via the Pro Sports Transactions API is subject to all rights reserved by Pro Sports Transactions. No warranty, express or implied, is made regarding accuracy, adequacy, completeness, legality, reliability or usefulness of any information.
For questions, concerns, or other regarding the information provided via the Pro Sports Transaction API, please visit Pro Sports Transactions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pro_sports_transactions-1.0.0.tar.gz
.
File metadata
- Download URL: pro_sports_transactions-1.0.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.90.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17afa7e9de8cb5cdd709651fdd13cdd1f110e37ba14883efa793b38725fae4d2 |
|
MD5 | f4c9b66415b6231a694f784d5a716305 |
|
BLAKE2b-256 | 4e7692bae012aabaaed03bb5a0262867690a870b7b59154d55b152f6a499398d |
File details
Details for the file pro_sports_transactions-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pro_sports_transactions-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.90.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b71fd81bfa395f0592e3f131a6923e90b2d13c14ba33d7e806e1ce8aabbe93a |
|
MD5 | 12be3113037eee53f5bd042e9fbd56b4 |
|
BLAKE2b-256 | 3013846b04e65656de820858afb2864964473129d7d78ed96d91c847b179b437 |