Skip to content

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 writes 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

Installation

pip install garf-executors
uv add 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.report_fetcher import ApiReportFetcher
from garf_core.api_clients import RestApiClient
from garf_io import writer

api_client = RestApiClient(endpoint='https://api.restful-api.dev')
fetcher = ApiReportFetcher(api_client)
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('console').write(report, 'api_data')