Metadata-Version: 2.1
Name: accern-data
Version: 0.1.0rc3
Summary: Client for consuming Accern data feeds.
Home-page: https://github.com/Accern/accern-data-client
Author: Accern Corp.
Author-email: datascience@accern.com
License: MIT
Keywords: api client data feed NLP processing
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7.1
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas (>=1.3.0)
Requires-Dist: requests (>=2.27.1)
Requires-Dist: tqdm (>=4.64.0)
Requires-Dist: typing-extensions (>=4.3.0)
Provides-Extra: jupyter
Requires-Dist: ipywidgets ; extra == 'jupyter'

# Accern Data Library
[![Python Checks](https://github.com/Accern/accern-data-client/actions/workflows/python-app.yml/badge.svg)](https://github.com/Accern/accern-data-client/actions/workflows/python-app.yml)
[![Latest release](https://img.shields.io/pypi/v/accern-data.svg)](https://pypi.org/project/accern-data/)
[![Python versions](https://img.shields.io/pypi/pyversions/accern-data.svg?logo=python&logoColor=white)](https://pypi.org/project/accern-data/#history)
[![Downloads](https://static.pepy.tech/personalized-badge/accern-data?period=total&units=international_system&left_color=grey&right_color=red&left_text=Downloads)](https://pepy.tech/project/accern-data)


Client library for consuming Accern data feed API.

PyPI page: [Click here](https://pypi.org/project/accern-data/)

### Installation:
```
pip install accern-data
```


### Sample snippet:


```python
import accern_data
# Create a data client.
client = accern_data.create_data_client("https://api.example.com/", "SomeRandomToken")
# Set a data format/mode in which the data has to be downloaded.
# Split dates lets you divide files on the basis of dates.
client.set_mode(mode="csv", split_dates=True)  # Other modes: {"df", "json"}
```


### Set filters:
```python
client.set_filters({
    "provider_id": 5,
    "entity_name": "Hurco Companies, Inc.",
    "event": "Governance - Product Development, R&D and Innovation",
    "entity_ticker": "HURC",
    "entity_accern_id": "BBG000BLLFK1",
})
```



### Set parameters to the download function:
```python
client.download_range(
    start_date="2022-01-03",
    output_path=".",
    output_pattern="data",
    end_date="2022-03-04")
```

Note: To download single day's data, set `end_date=None` or can leave that unset:
```python
client.download_range(
    start_date="2022-01-03",
    output_path=".",
    output_pattern="data",
    end_date=None)
```
OR

```python
client.download_range(
    start_date="2022-01-03",
    output_path=".",
    output_pattern="data")
```


### One-liner download:
```python
accern_data.create_data_client("https://api.example.com/", "SomeRandomToken").download_range(start_date="2022-01-03", output_path=".", output_pattern="data", end_date="2022-03-04", mode="csv", filters={"entity_ticker": "HURC"})
```


### Getting data using iterator:
```python
for res in client.iterate_range(
        start_date="2022-01-03",
        end_date="2022-03-04"):
    do_something(res)
```


### Error logging:

While downloading the data any critical error will get raised.
Any non-critical errors, such as API timeouts, get silenced and API calls are repeated. To see a list of the last `n` errors use:

```python
client.get_last_silenced_errors()
```
