Skip to content

Commit

Permalink
Initial: Github workflow and README
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyjs committed Oct 17, 2024
0 parents commit dc7e95f
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: The-Odds-API

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# If you wanted to use multiple Python versions, you'd have specify a matrix in the job and
# reference the matrixe python version here.
- uses: actions/setup-python@v5
with:
python-version: 3.9.18

# Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
# from installing Poetry every time, which can be slow. Note the use of the Poetry version
# number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
# manually if/when you want to upgrade Poetry, or if something goes wrong. This could be
# mildly cleaner by using an environment variable, but I don't really care.
- name: cache poetry install
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-1.5.1-0

# Install Poetry. You could do this manually, or there are several actions that do this.
# `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
# Poetry's default install script, which feels correct. I pin the Poetry version here
# because Poetry does occasionally change APIs between versions and I don't want my
# actions to break if it does.
#
# The key configuration value here is `virtualenvs-in-project: true`: this creates the
# venv as a `.venv` in your testing directory, which allows the next step to easily
# cache it.
- uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true

# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). Note the cache
# key: if you're using multiple Python versions, or multiple OSes, you'd need to include
# them in the cache key. I'm not, so it can be simple and just depend on the poetry.lock.
- name: cache deps
id: cache-deps
uses: actions/cache@v3
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}

# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
# ensures this only runs on a cache miss.
- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'

# Now install _your_ project. This isn't necessary for many types of projects -- particularly
# things like Django apps don't need this. But it's a good idea since it fully-exercises the
# pyproject.toml and makes that if you add things like console-scripts at some point that
# they'll be installed and working.
- run: poetry install --no-interaction

# And finally run tests. I'm using pytest and all my pytest config is in my `pyproject.toml`
# so this line is super-simple. But it could be as complex as you need.
- run: poetry run pytest

# run a check for black
- name: poetry run black . --check
run: poetry run black . --check

# run a lint check with ruff
- name: poetry run ruff check .
run: poetry run ruff check .
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# The Odds API (Unofficial) Client for the-odds-api.com

You will need to acquire an API KEY from [The Odds API](https://the-odds-api.com/) to use this client.

```python
pip install the-odds
```

### Contact
Im available on [Bluesky](https://bsky.app/profile/coreyjs.dev) for any questions or just general chats about enhancements.


# Installation and Setup
```
pip install the-odds
```

```python
from the_odds import OddsApiClient

client = OddsApiClient(api_key='your_key')

# for debug logging and request logging
client = OddsApiClient(api_key='your_key', debug=True)
```

## Available Endpoints

### Get Sports

<details>
<summary>API Endpoint Info</summary>

**Endpoint:** `/v4/sports`
**Method:** GET
**Formats:** JSON


| Param | Type | Ex | Note |
|-------|------|--------------|----|
| all | bool | True / False | Optional - if this parameter is set to true (all=true), a list of both in and out of season sports will be returned |

</details>

```python
sports = client.v4.get_sports()
```

0 comments on commit dc7e95f

Please sign in to comment.