Getting Started
Stormware provides a unified interface to various external APIs via simple but powerful connectors. It makes data engineering and data science work fast, efficient and enjoyable.
Using the Connectors
Let’s say we need to load the results from our latest Facebook campaign into a Google Sheets spreadsheet. We install Stormware with the appropriate connectors from pypi:
pip install stormware[google,facebook]
We go through the authentication configuration steps for Google and Facebook, and when done, we load the data into a data frame using the Facebook Ads connector:
from stormware.facebook import FacebookAds
facebook = FacebookAds(account_name='Logikal')
report = facebook.report(
metrics=['spend', 'impressions', 'clicks'],
dimensions=['campaign_name'],
parameters={
'level': 'campaign',
'time_range': {'since': '2023-01-01', 'until': '2023-01-07'},
},
)[['campaign_name', 'spend', 'impressions', 'clicks']]
report.head()
campaign_name | spend | impressions | clicks | |
---|---|---|---|---|
0 | (y_2023)(p_mindlab)(g_discover)(o_traffic)(c_USA) | 3.31 | 115 | 1 |
Finally, we push the data into the desired spreadsheet:
from stormware.google.sheets import Spreadsheet
with Spreadsheet(key='1YKTWQtHk7cBIcWoy3VlHTKQvkhKXUtE8iQDmGK3pIkY') as sheet:
sheet.set_sheet(name='Facebook Campaign', data=report)
Of course, if we wanted to push the data into Google BigQuery as well, it would be equally easy:
from stormware.google.bigquery import BigQuery
with BigQuery() as bigquery:
bigquery.set_table(name='test.facebook_campaign', data=report)
That’s it! Connectors are designed to be composable (for example, they will often return a
pandas.DataFrame
or expect one as an input), which makes common tasks much easier to
solve. Additionally, this approach also makes further analysis work with tools like MindLab simple and effortless.