|
3 | 3 | `garf` is a framework for building various connectors to reporting API that provides |
4 | 4 | users with a SQL-like interface to specify what needs to be extracted from the API. |
5 | 5 |
|
6 | | -The framework allows you to define SQL-like queries alongside aliases and custom extractors and specify where the results of such query should be stored. |
7 | | -Based on such a query the library constructs the correct query to a reporting API of your choice, automatically extract all necessary fields from API schema |
8 | | -and transform them into a structure suitable for writing data. |
| 6 | +It allows you to define SQL-like queries alongside aliases and custom extractors and specify where the results of such query should be stored.\ |
| 7 | +Based on a query `garf` builds the correct request to a reporting API, parses response |
| 8 | +and transform it into a structure suitable for writing data. |
9 | 9 |
|
10 | | -`garf` consist of several core libraries: |
| 10 | +## Key features |
11 | 11 |
|
12 | | -* [`garf-core`](libs/garf_core) - exposes interfaces and core classes such as `GarfReport`. |
13 | | -* [`garf-io`](libs/garf_io) - handles reading queries and writing `GarfReport` to various local/remote storages. |
14 | | -* [`garf-executors`](libs/garf_executors) - responsible for orchestrating process of fetching from API and storing data in a storage. |
| 12 | +* SQL-like syntax to interact with reporting APIs |
| 13 | +* Built-in support for writing data into various local / remote storage |
| 14 | +* Available as library, CLI, FastAPI endpoint |
| 15 | +* Easily extendable to support various APIs |
| 16 | + |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +```bash |
| 21 | +pip install garf-executors |
| 22 | +``` |
15 | 23 |
|
16 | | -[`garf-community`](libs/garf_community) folder contains concrete implementation of the framework for various APIs. |
17 | 24 |
|
18 | 25 | ## Usage |
19 | 26 |
|
20 | | -Check usage of `garf` as a [library](docs/use-garf-as-a-library.md). |
| 27 | +### Get data from API to use in your code |
| 28 | + |
| 29 | +```python |
| 30 | +from garf_core import ApiReportFetcher |
| 31 | +from garf_core.api_clients import FakeApiClient |
| 32 | +from garf_io import writer |
| 33 | + |
| 34 | +my_api_client = FakeApiClient(results=[{'field': 1}]) |
| 35 | +fetcher = ApiReportFetcher(my_api_client) |
| 36 | +report = fetcher.fetch('SELECT field FROM resource_name') |
| 37 | + |
| 38 | +# Convert to Pandas |
| 39 | +report.to_pandas() |
| 40 | + |
| 41 | +# Write to CSV |
| 42 | +writer.create_writer('csv').write(report, 'api_data') |
| 43 | + |
| 44 | +``` |
| 45 | + |
| 46 | +### Use `garf` CLI tool to fetch data from an API |
| 47 | + |
| 48 | + |
| 49 | +```bash |
| 50 | +garf /path/to/queries \ |
| 51 | + --source youtube --source.channel=MY_CHANNEL_ID \ |
| 52 | + --output csv |
| 53 | +``` |
| 54 | + |
| 55 | +## Documentation |
21 | 56 |
|
22 | | -## Building your own libraries |
| 57 | +Explore full documentation on using and extending `garf` |
23 | 58 |
|
24 | | -If you wish to build your own garf-based libraries please refer to [documentation](docs/creating-your-own-libraries.md). |
| 59 | +* [Documentation](https://google.github.io/garf/) |
25 | 60 |
|
26 | 61 | ## Disclaimer |
27 | 62 | This is not an officially supported Google product. This project is not |
|
0 commit comments