unusual-whales-api-client


Nameunusual-whales-api-client JSON
Version 1.3 PyPI version JSON
download
home_pageNone
SummaryA client library for accessing Unusual Whales API
upload_time2024-05-05 19:05:20
maintainerNone
docs_urlNone
authorMac Anderson
requires_python<4.0,>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # unusual-whales-api-client
A client library for accessing Unusual Whales API

Thank you @unusualwhales for providing an excellent api and for leaving your openapi schema unobfuscated from the network logs on your api documentation website :->)

For feature requests email mac@macanderson.com - I do not provide support

## Importing Modules
You can import modules using the following syntax:

from unusualwhales.client import Client
from unusualwhales.api.[tag] import [function]
from unusualwhales.models import [ModelNameHere]
from unusualwhales.types import Response

```python
import os
from dotenv import load_dotenv
from unusualwhales.client import AuthenticatedClient
from unusualwhales.api.[tag] import [function]
from unusualwhales.models import [ModelNameHere]
from unusualwhales.types import Response

load_dotenv('/path/to/.env')
# This app requires an api token to included when initializing a new AuthenticatedClient
# you can use python-dotenv as shown here to save it in a .env file so that you
# do not have unsecured code
API_TOKEN = os.environ.get("UNUSUAL_WHALES_API_TOKEN", None)

client = AuthenticatedClient(base_url="https://api.unusualwhales.com", token=API_TOKEN)
```


```python
import os

from dotenv import load_dotenv

from unusualwhales.client import AuthenticatedClient
from unusualwhales.models import TickerOptionsVolume
from unusualwhales.api.stock import getTickerOptionsVolume
from unusualwhales.types import Response

load_dotenv('/path/to/.env')
API_TOKEN = os.environ.get("UNUSUAL_WHALES_API_TOKEN", None)

client = AuthenticatedClient(base_url="https://api.unusualwhales.com", token=API_TOKEN)
with client as client:
    ticker_options_volume: Response[TickerOptionsVolume] = getTickerOptionsVolume.sync(client=client,ticker="AAPL",date="2024-05-03")
    for option_volume in ticker_options_volume:
        print(option_volume.strike, option_volume.volume)
```

## Async Support

This library works with async await to handle non blocking i/o for better performance!

```python
# same code as before but with async/await note that the function changes from sync_detailed to asyncio_detailed
# alternatively you can use sync and asyncio
from unusualwhales.client import AuthenticatedClient

async with client as client:
    ticker_options_volume: TickerOptionsVolume = await getTickerOptionsVolume.asyncio(client=client,ticker="AAPL",date="2024-05-03")
    for option_volume in ticker_options_volume:
        print(option_volume.strike, option_volume.volume)
```

Things to know:
1. Every path/method combo becomes a Python module with four functions:
    1. `sync`: Blocking request that returns parsed data (if successful) or `None`
    1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
    1. `asyncio`: Like `sync` but async instead of blocking
    1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking

1. All path/query params, and bodies become method arguments.

## Advanced customizations

There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):

```python
from unusual_whales_api_client import Client

def log_request(request):
    print(f"Request event hook: {request.method} {request.url} - Waiting for response")

def log_response(response):
    request = response.request
    print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")

client = Client(
    base_url="https://api.unusualwhales.com",
    httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "unusual-whales-api-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Mac Anderson",
    "author_email": "mac@macanderson.com",
    "download_url": "https://files.pythonhosted.org/packages/7e/98/6f3dcc0fb3cd7f78d9309eff84e0b7eb6785537f1e001b3ee4311622c661/unusual_whales_api_client-1.3.tar.gz",
    "platform": null,
    "description": "# unusual-whales-api-client\nA client library for accessing Unusual Whales API\n\nThank you @unusualwhales for providing an excellent api and for leaving your openapi schema unobfuscated from the network logs on your api documentation website :->)\n\nFor feature requests email mac@macanderson.com - I do not provide support\n\n## Importing Modules\nYou can import modules using the following syntax:\n\nfrom unusualwhales.client import Client\nfrom unusualwhales.api.[tag] import [function]\nfrom unusualwhales.models import [ModelNameHere]\nfrom unusualwhales.types import Response\n\n```python\nimport os\nfrom dotenv import load_dotenv\nfrom unusualwhales.client import AuthenticatedClient\nfrom unusualwhales.api.[tag] import [function]\nfrom unusualwhales.models import [ModelNameHere]\nfrom unusualwhales.types import Response\n\nload_dotenv('/path/to/.env')\n# This app requires an api token to included when initializing a new AuthenticatedClient\n# you can use python-dotenv as shown here to save it in a .env file so that you\n# do not have unsecured code\nAPI_TOKEN = os.environ.get(\"UNUSUAL_WHALES_API_TOKEN\", None)\n\nclient = AuthenticatedClient(base_url=\"https://api.unusualwhales.com\", token=API_TOKEN)\n```\n\n\n```python\nimport os\n\nfrom dotenv import load_dotenv\n\nfrom unusualwhales.client import AuthenticatedClient\nfrom unusualwhales.models import TickerOptionsVolume\nfrom unusualwhales.api.stock import getTickerOptionsVolume\nfrom unusualwhales.types import Response\n\nload_dotenv('/path/to/.env')\nAPI_TOKEN = os.environ.get(\"UNUSUAL_WHALES_API_TOKEN\", None)\n\nclient = AuthenticatedClient(base_url=\"https://api.unusualwhales.com\", token=API_TOKEN)\nwith client as client:\n    ticker_options_volume: Response[TickerOptionsVolume] = getTickerOptionsVolume.sync(client=client,ticker=\"AAPL\",date=\"2024-05-03\")\n    for option_volume in ticker_options_volume:\n        print(option_volume.strike, option_volume.volume)\n```\n\n## Async Support\n\nThis library works with async await to handle non blocking i/o for better performance!\n\n```python\n# same code as before but with async/await note that the function changes from sync_detailed to asyncio_detailed\n# alternatively you can use sync and asyncio\nfrom unusualwhales.client import AuthenticatedClient\n\nasync with client as client:\n    ticker_options_volume: TickerOptionsVolume = await getTickerOptionsVolume.asyncio(client=client,ticker=\"AAPL\",date=\"2024-05-03\")\n    for option_volume in ticker_options_volume:\n        print(option_volume.strike, option_volume.volume)\n```\n\nThings to know:\n1. Every path/method combo becomes a Python module with four functions:\n    1. `sync`: Blocking request that returns parsed data (if successful) or `None`\n    1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.\n    1. `asyncio`: Like `sync` but async instead of blocking\n    1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking\n\n1. All path/query params, and bodies become method arguments.\n\n## Advanced customizations\n\nThere are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):\n\n```python\nfrom unusual_whales_api_client import Client\n\ndef log_request(request):\n    print(f\"Request event hook: {request.method} {request.url} - Waiting for response\")\n\ndef log_response(response):\n    request = response.request\n    print(f\"Response event hook: {request.method} {request.url} - Status {response.status_code}\")\n\nclient = Client(\n    base_url=\"https://api.unusualwhales.com\",\n    httpx_args={\"event_hooks\": {\"request\": [log_request], \"response\": [log_response]}},\n)\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A client library for accessing Unusual Whales API",
    "version": "1.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "668ef17e138918920fe33abcefe0eac2d27f8dd91131bbdd685630652fee5785",
                "md5": "d1e30f19544bf2abb263c03d1fde4e8a",
                "sha256": "49dbcb13a16a9ebd4bd5d1975d4c4823fc9e9541fe9309c6316b21e1d4c45141"
            },
            "downloads": -1,
            "filename": "unusual_whales_api_client-1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d1e30f19544bf2abb263c03d1fde4e8a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 222521,
            "upload_time": "2024-05-05T19:05:18",
            "upload_time_iso_8601": "2024-05-05T19:05:18.830655Z",
            "url": "https://files.pythonhosted.org/packages/66/8e/f17e138918920fe33abcefe0eac2d27f8dd91131bbdd685630652fee5785/unusual_whales_api_client-1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7e986f3dcc0fb3cd7f78d9309eff84e0b7eb6785537f1e001b3ee4311622c661",
                "md5": "e86bf61c5d9ce9819b91ef7ab13ec835",
                "sha256": "378495e4de3935491f3f5dabb637279af6587a407117e911f56ae8f23218c65d"
            },
            "downloads": -1,
            "filename": "unusual_whales_api_client-1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "e86bf61c5d9ce9819b91ef7ab13ec835",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 95750,
            "upload_time": "2024-05-05T19:05:20",
            "upload_time_iso_8601": "2024-05-05T19:05:20.634696Z",
            "url": "https://files.pythonhosted.org/packages/7e/98/6f3dcc0fb3cd7f78d9309eff84e0b7eb6785537f1e001b3ee4311622c661/unusual_whales_api_client-1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-05 19:05:20",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "unusual-whales-api-client"
}
        
Elapsed time: 8.94891s