garf - Python library for interacting with reporting APIs
What is garf?
garf is a Python library for building various connectors to reporting API that provides
users with a SQL-like interface to specify what needs to be extracted from the API.
Write a query and garf will do the rest - build the correct request to an API, parse response
and write it virtually anywhere.
Key features
- Rich SQL-like syntax to interact with reporting APIs.
- Built-in support for writing data into various local / remote storage.
- Easily extendable to support various APIs.
- Built-in support for post-processing saved data in BigQuery & SQL databases.
- Available as library, CLI, FastAPI endpoint.
Supported APIs
- YouTube Data API
- YouTube Analytics API
- Google Analytics
- Google Merchant Center
- Bid Manager
- Google Ads
- Search Ads 360
- REST
Installation
pip install garf-executors
uv pip install garf-executors
Usage
CLI
echo 'SELECT id, name AS model, data.color AS color FROM objects' > query.sql
garf query.sql --source rest --source.endpoint=https://api.restful-api.dev
Python library
from garf.core.fetchers import RestApiReportFetcher
from garf.io import writer
fetcher = RestApiReportFetcher(endpoint='https://api.restful-api.dev')
query = 'SELECT id, name AS model, data.color AS color FROM objects'
report = fetcher.fetch(query)
# Convert to Pandas
report.to_pandas()
# Write to CSV
writer.create_writer('csv').write(report, 'api_data')