Skip to main content

smug-api

Some endpoints for your smug-broker to talk to immediately.

Want weather in your slack channel? Want stock quotes? We've got you covered.

quickstart

The fastest way to get started is to use the docker image.

docker pull threatsimple/smugapi:latest
export SMUGAPI_WEATHERBIT=YourWeatherKey
export SMUGAPI_WORLDTRADINGDATA=YourStockQuoteKey
docker run -p 8088 \
    -e SMUGAPI_WEATHERBIT -e SMUGAPI_WORLDTRADINGDATA -it \
    threatsimple/smugapi:latest

Another option is to use the package from pypi.org.

pip3 install smugapi
export SMUGAPI_WEATHERBIT
export SMUGAPI_WORLDTRADINGDATA=YourStockQuoteKey
smugapi run

Either way, you'll have the api running and listening on localhost, port 8088.

running the service

There is a command line tool, smugapi that allows for easy starting of the api service.

smugapi run

This will run the web service and bind to localhost.

This doesn't get you anything useful, though. You'll want to pass api keys via either the cmd line or environment variables, as discussed in the endpoints section below.

endpoints

weather

Current weather and forecasts are provided by the very excellent https://weatherbit.io folks. They have a free plan that works for most channels, but if you have a larger volume, they offer a paid option.

To use the weather endpoints, set your api key via either the command line with the --weatherbit option smugapi run or via the SMUGAPI_WEATHERBIT environment variable.

export SMUGAPI_WEATHERBIT=<Your API Key Here>
smugapi run

stock price lookups

Global stock prices can be looked up. The data is provided by the excellent folks at worldtradingdata.com. They have a free account that can provide for most channels, and a paid option is available for larger demands.

To use the stock price endpoint, set your api key either the command line with the --worldtradingdata option to smugapi run or with the SMUGAPI_WORLDTRADINGDATA environment variable.

export SMUGAPI_WORLDTRADINGDATA=<Your API Key Here>
smugapi run

Chartmoji

It is recommended using Chartmoji in your slack workspace. It adds a bit of flair to your stock quotes and weather.

To use chartmoji, you can use either the --chartmoji option to smugapi run or by setting SMUGAPI_CHARTMOJI=true in the runtime environment.

developing

All development related tasks are managed via the Makefile.

dev environment

make dev

This creates a python virtualenv in pyvenv and installs the required libs, as referenced in reqs.pip.

This also sets up the current source directory as the smugapi module in the venv for ease of development.

testing

make test

Assuming you've run make dev, you can use make test to run tests. This will handle the executing the tests in the virtualenv for you, so no need to handle that in your shell.

Metadata

Release files for smugapi 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smugapi 0.8.1
File Size Uploaded
smugapi-0.8.1.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for smugapi 0.8.1
File Interpreter ABI Platform
smugapi-0.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.1 kB

Release files / smugapi-0.8.1.tar.gz

Download URL smugapi-0.8.1.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6679c1ddea02508d881b9972b662783e27804f9fdebad8893deb24a487b28fff
BLAKE2b-256 checksum
How to use checksums
339f630d79e19aa11665acd0163970496942f53362a70fe24270da9f9a9b63b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.3

Release files / smugapi-0.8.1-py3-none-any.whl

Download URL smugapi-0.8.1-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0ee4bd8b5cada0cf87852a7dab2c376c5dab33d7b34557007859cfd3f2353c4
BLAKE2b-256 checksum
How to use checksums
a175da35480424d10b3f73e7c638cc488b8c912c20813bd17d18f8afebd602f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.8.1 This release

2 release files

0.7.0

2 release files

0.6.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page