An educational SDK for AI and Data Science on the SWC Platform
Project description
swcpy software development kit (SDK)
This is the Python SDK to interact with the SportsWorldCentral Football API.
Installing swcpy
To install this SDK in your environment, execute the following command:
pip install swcpy@git+https://github.com/tatendaty/portfolio-project#subdirectory=sdk
Example usage
This SDK implements all the endpoints in the SWC API, in addition to providing bulk downloads of the SWC fantasy data in CSV format.
Setting base URL for the API
The SDK looks for a value of SWC_API_BASE_URL in the environment. The preferred method for setting the base URL for the SWC API is by creating a Python
.env file in your project directory with the following value:
SWC_API_BASE_URL={URL of your API}
You may also set this value as an environment variable in the environment you are using the SDK, or pass it as a parameter to the SWCConfig() method.
Example of normal API functions
To call the SDK functions for normal API endpoints, here is an example:
from swcpy import SWCClient
from swcpy import SWCConfig
config = SWCConfig(swc_base_url="http://0.0.0.0:8000",backoff=False)
client = SWCClient(config)
leagues_response = client.list_leagues()
print(leagues_response)
Example of bulk data functions
The build data endpoint returns a bytes object. Here is an example of saving a file locally from a bulk file endpoint:
import csv
import os
from io import StringIO
config = SWCConfig()
client = SWCClient(config)
"""Tests bulk player download through SDK"""
player_file = client.get_bulk_player_file()
# Write the file to disk to verify file download
output_file_path = data_dir + 'players_file.csv'
with open(output_file_path, 'wb') as f:
f.write(player_file)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swcpy_tydennis0501-0.0.3.tar.gz.
File metadata
- Download URL: swcpy_tydennis0501-0.0.3.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05548681e176ca2a3239b0c5bc1b22fa9a5412da2f251f5a6e1e659329c9d4ad
|
|
| MD5 |
b20b51f404fc2d59b13cfeecccecade5
|
|
| BLAKE2b-256 |
eb158e03c2cf06a134d947cc41ab9ecd0e36238bc06504812f4343fcaf50caf2
|
File details
Details for the file swcpy_tydennis0501-0.0.3-py3-none-any.whl.
File metadata
- Download URL: swcpy_tydennis0501-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51e644b549df378e46feb793244259896b54f112c69cd63bf562e81eb3c8476e
|
|
| MD5 |
7b6559f6cebc1d2f74b716af1d735210
|
|
| BLAKE2b-256 |
5015b41cb7c2b9b7c72a4e70e42075a8e6224be09d66f1ec82b7e815f4b9a6ca
|