Inofficial Marketstack OpenAPI Python client
Project description
marketstack-python
Inofficial Python OpenAPI implementation of the marketstack API based on the marketstack OpenAPI spec.
Usage
Configuration (recommended)
Set up your API key and TLS support as ENV variables.
MARKETSTACK_API_KEY="xyz"
MARKETSTACK_TLS_SUPPORT="1"
Create your client
from marketstack.client import Client
import os
tls_support = os.getenv("MARKETSTACK_TLS_SUPPORT")
protocol = "https" if tls_support == "1" else "http"
client = Client(base_url=f"{protocol}://api.marketstack.com/v1")
Call operations
from marketstack.api.eod import eod
import os
response = eod.sync(
client=client,
access_key=os.getenv("MARKETSTACK_API_KEY"),
symbols="AAPL,AMZN",
limit=10,
)
All endpoint features are implemented and tested. For examples see the repository's tests/
directory.
Error handling
from marketstack.models import ErrorCode, ErrorResponse
assert isinstance(response, ErrorResponse)
assert response.error.code == ErrorCode.FUNCTION_ACCESS_RESTRICTED
Map to Pandas dataframe
import pandas as pd
df = pd.DataFrame(map(lambda x: x.__dict__, response.data))
Developers area
Generate the client
- Install the OpenAPI client generator
pip install openapi-python-client
- Regenerate the client
./regenerate.sh
Run the tests
- Setup your marketstack API key in
tests/test.env
- Run the tests via pytest
PYTHONPATH="." pytest --cov=marketstack tests/
Release update
- Update version in
setup.py
- Package library
python setup.py sdist
- Publish library
twine upload dist/{packaged file}.tar.gz
References
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
marketstack-0.5.tar.gz
(29.7 kB
view details)
File details
Details for the file marketstack-0.5.tar.gz
.
File metadata
- Download URL: marketstack-0.5.tar.gz
- Upload date:
- Size: 29.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef93e841726b04790244b498bda70b8b4d0538f118406ac159b9809d6ea2294c |
|
MD5 | 82b063f1803e0f85ab0ef33f3952fedb |
|
BLAKE2b-256 | 234bc188ba2de4768d6ead6d713789a4c764cca36f2782c0e078ed4cad80a749 |