mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-29 12:43:48 +00:00
* quick econ fix * black * keys and feature flags * terminal name 👀 * some more replacements * some more replacements * edit pyproject * gst -> openbb * add example portfolios back to git * Update api from gst * sorry. skipping some tests * another round of names * another round of test edits * Missed some .gst refs and update timezone * water mark stuff * Fixing Names in terminal.spec and name of GTFF_DEFAULTS to OBBFF_DEFAULTS * fix more GST to OpenBB Terminal * Logging : merge conflicts with main * Revert wrong files Co-authored-by: Andrew <andrew.kenreich@gmail.com> Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt> Co-authored-by: Chavithra PARANA <chavithra@gmail.com>
69 lines
1.7 KiB
Python
69 lines
1.7 KiB
Python
"""CoinPaprika model"""
|
|
__docformat__ = "numpy"
|
|
|
|
import logging
|
|
from typing import Any, Optional
|
|
|
|
import pandas as pd
|
|
|
|
from openbb_terminal.cryptocurrency.coinpaprika_helpers import PaprikaSession
|
|
from openbb_terminal.decorators import log_start_end
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
CATEGORIES = [
|
|
"currencies",
|
|
"exchanges",
|
|
"icos",
|
|
"people",
|
|
"tags",
|
|
"all",
|
|
]
|
|
|
|
FILTERS = ["category", "id", "name"]
|
|
|
|
|
|
@log_start_end(log=logger)
|
|
def get_search_results(
|
|
query: str, category: Optional[Any] = None, modifier: Optional[Any] = None
|
|
) -> pd.DataFrame:
|
|
"""Search CoinPaprika. [Source: CoinPaprika]
|
|
|
|
Parameters
|
|
----------
|
|
query: str
|
|
phrase for search
|
|
category: Optional[Any]
|
|
one or more categories (comma separated) to search.
|
|
Available options: currencies|exchanges|icos|people|tags
|
|
Default: currencies,exchanges,icos,people,tags
|
|
modifier: Optional[Any]
|
|
set modifier for search results. Available options: symbol_search -
|
|
search only by symbol (works for currencies only)
|
|
|
|
Returns
|
|
-------
|
|
pandas.DataFrame
|
|
Search Results
|
|
Columns: Metric, Value
|
|
"""
|
|
|
|
session = PaprikaSession()
|
|
if category is None:
|
|
category = "currencies,exchanges,icos,people,tags"
|
|
data = session.make_request(
|
|
session.ENDPOINTS["search"], q=query, c=category, modifier=modifier, limit=100
|
|
)
|
|
results = []
|
|
for item in data:
|
|
category = data[item]
|
|
for r in category:
|
|
results.append(
|
|
{
|
|
"id": r.get("id"),
|
|
"name": r.get("name"),
|
|
"category": item,
|
|
}
|
|
)
|
|
return pd.DataFrame(results)
|