Metadata-Version: 2.4
Name: swcpy-tydennis0501
Version: 0.0.3
Summary: An educational SDK for AI and Data Science on the SWC Platform
Author: [Tatenda Kabanda]
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: pytest>=8.1
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.4.0
Requires-Dist: backoff>=2.2.1
Requires-Dist: pyarrow>=16.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: python-dotenv

# 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:

```python
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:

```python
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)
```


