Skip to content
This repository was archived by the owner on Jun 15, 2024. It is now read-only.

Commit 5782aeb

Browse files
authored
Merge pull request #237 from iexcloud/metadata
add metadata
2 parents e994991 + d314321 commit 5782aeb

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

pyEX/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .files import *
2323
from .fx import *
2424
from .markets import *
25+
from .metadata import *
2526
from .options import *
2627
from .points import *
2728
from .premium import *

pyEX/client.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99
import types
1010
from functools import partial, wraps
11+
import warnings
1112

1213
from .account import messageBudget, metadata, metadataDF, usage, usageDF
1314
from .alternative import ceoCompensation, ceoCompensationDF, sentiment, sentimentDF
@@ -32,6 +33,7 @@
3233
latestFXDF,
3334
)
3435
from .markets import markets, marketsDF
36+
from .metadata import queryMetadata, queryMetadataDF
3537
from .options import optionExpirations, options, optionsDF
3638
from .points import points, pointsDF
3739
from .premium import (
@@ -863,6 +865,10 @@
863865
("searchDF", searchDF),
864866
("tags", tags),
865867
("tagsDF", tagsDF),
868+
# Metadata
869+
# TODO move?
870+
("queryMetadata", queryMetadata),
871+
("queryMetadataDF", queryMetadataDF),
866872
]
867873

868874
_INCLUDE_FUNCTIONS_MARKET = [
@@ -1624,9 +1630,10 @@ def __init__(self, api_token=None, version="v1", api_limit=DEFAULT_API_LIMIT):
16241630
raise PyEXception("Unrecognized api version: {}".format(version))
16251631

16261632
if self._token.startswith("T") and version != "sandbox":
1627-
raise PyEXception(
1628-
"Using test key but attempting to connect to non-sandbox environment"
1633+
warnings.warn(
1634+
"Using test key but attempting to connect to non-sandbox environment. Switching to sandbox"
16291635
)
1636+
version = "sandbox"
16301637

16311638
self._version = version
16321639
self._api_limit = api_limit

pyEX/metadata/__init__.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# *****************************************************************************
2+
#
3+
# Copyright (c) 2022, the pyEX authors.
4+
#
5+
# This file is part of the pyEX library, distributed under the terms of
6+
# the Apache License 2.0. The full license can be found in the LICENSE file.
7+
#
8+
from functools import wraps
9+
import pandas as pd
10+
from ..common import _get
11+
12+
13+
def queryMetadata(
14+
id="", key="", subkey="", token="", version="stable", filter="", format="json"
15+
):
16+
"""Get inventory of available time series endpoints
17+
18+
Args:
19+
id (str): Timeseries ID
20+
key (str): Timeseries Key
21+
subkey (str): Timeseries Subkey
22+
token (str): Access token
23+
version (str): API version
24+
filter (str): https://iexcloud.io/docs/api/#filter-results
25+
format (str): output format
26+
"""
27+
url = "metadata/time-series"
28+
if id:
29+
url += "/{}".format(id)
30+
if key:
31+
url += "/{}".format(key)
32+
if subkey:
33+
url += "/{}".format(subkey)
34+
return _get(url, token=token, version=version, filter=filter, format=format)
35+
36+
37+
@wraps(queryMetadata)
38+
def queryMetadataDF(*args, **kwargs):
39+
return pd.DataFrame(queryMetadata(*args, **kwargs))

pyEX/tests/test_api.py

+2
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ def test_all(self):
527527
"productEventsWallStreetHorizon",
528528
"productEventsWallStreetHorizonDF",
529529
"propane",
530+
"queryMetadata",
531+
"queryMetadataDF",
530532
"quote",
531533
"quoteDF",
532534
"recent",

pyEX/tests/test_api_client.py

+7
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ def test_all_markets(self):
107107
assert hasattr(self.c, meth)
108108
assert hasattr(self.c.market, meth)
109109

110+
def test_all_metadata(self):
111+
for meth in (
112+
"queryMetadata",
113+
"queryMetadataDF",
114+
):
115+
assert hasattr(self.c, meth)
116+
110117
def test_all_stats(self):
111118
for meth in (
112119
"systemStats",

0 commit comments

Comments
 (0)