-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
354e1eb
commit defcceb
Showing
15 changed files
with
882 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Using SDK in a Jupyter Notebook" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"from pyswc import SWCClient, SWCConfig\n", | ||
"import pandas as pd\n", | ||
"\n", | ||
"config = SWCConfig()\n", | ||
"client = SWCClient(config)\n", | ||
"sdk_players = client.list_players()\n", | ||
"\n", | ||
"#convert the list of player instances to dictionaries\n", | ||
"df = dp.DataFrame([player.model_dump() for player in sdk_players])\n", | ||
"print(df)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
262 changes: 0 additions & 262 deletions
262
notebooks_with_sdk/langgraph_notebook_with_toolkit.ipynb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# swcpy software development kit (SDK) | ||
This is the python SDK to to interact with the SportsWorldCentral Football API, which was created for the book [Hands-On APIs for AI and Data Science](https://hands-on-api-book.com). | ||
|
||
## Installing swcpy | ||
|
||
To install this SDK in your environment, execute the following command: | ||
|
||
`pip install swcpy@git+https://github.com/{owner of repo}/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. | ||
|
||
### 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(url="http://127.0.0.1:8000",backoff=False) | ||
client = SWCClient(config) | ||
leagues_response = client.list_leagues() | ||
print(leagues_response) | ||
``` | ||
|
||
### Example of bulk data functions | ||
|
||
The build data endpoint return 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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[build-system] | ||
requires = ["setuptools>=61.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "swcpy" | ||
version = "0.0.2" | ||
authors = [ | ||
{ name="[Your Name]" }, | ||
] | ||
description = "Example Software Development Kit (SDK) from Hands-On API Book for AI and Data Science" | ||
requires-python = ">=3.10" | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
] | ||
dependencies = [ | ||
'pytest>=8.1', | ||
'httpx>=0.27.0', | ||
'pydantic>=2.7.0', | ||
'backoff>=2.2.1,<2.3.0', | ||
'pyarrow>=16.0,<17.0', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .swc_client import SWCClient | ||
from .swc_config import SWCConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .schemas import * |
Oops, something went wrong.