Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swcpy_tydennis0501-0.0.3.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swcpy_tydennis0501-0.0.3-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

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

Hashes for swcpy_tydennis0501-0.0.3.tar.gz
Algorithm Hash digest
SHA256 05548681e176ca2a3239b0c5bc1b22fa9a5412da2f251f5a6e1e659329c9d4ad
MD5 b20b51f404fc2d59b13cfeecccecade5
BLAKE2b-256 eb158e03c2cf06a134d947cc41ab9ecd0e36238bc06504812f4343fcaf50caf2

See more details on using hashes here.

File details

Details for the file swcpy_tydennis0501-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for swcpy_tydennis0501-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 51e644b549df378e46feb793244259896b54f112c69cd63bf562e81eb3c8476e
MD5 7b6559f6cebc1d2f74b716af1d735210
BLAKE2b-256 5015b41cb7c2b9b7c72a4e70e42075a8e6224be09d66f1ec82b7e815f4b9a6ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page