Skip to content

Commit c81024b

Browse files
committed
Updated README: fixed API version (v19)
Change-Id: I613a574b27345ba37b06b7df33f8acf093e182f3
1 parent 3f9dff5 commit c81024b

File tree

1 file changed

+81
-47
lines changed

1 file changed

+81
-47
lines changed

js/README.md

Lines changed: 81 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,99 @@
11
# Google Ads API Report Fetcher (gaarf)
2+
23
Node.js version of Google Ads API Report Fetcher tool a.k.a. `gaarf`.
34
Please see the full documentation in the root [README](https://github.com/google/ads-api-report-fetcher/README.md).
45

5-
Supports [Ads API v17.1](https://developers.google.com/google-ads/api/docs/release-notes#v17).
6-
76
<p align="center">
87
<a href="https://developers.google.com/google-ads/api/docs/release-notes">
9-
<img src="https://img.shields.io/badge/google%20ads-v17.0.0-009688.svg?style=flat-square"/>
8+
<img src="https://img.shields.io/badge/google%20ads-v19.0.0-009688.svg?style=flat-square"/>
109
</a>
1110
<a href="https://www.npmjs.com/package/google-ads-api-report-fetcher">
1211
<img src="https://img.shields.io/npm/v/google-ads-api-report-fetcher.svg?style=flat-square" />
1312
</a>
1413
<a>
1514
<img src="https://img.shields.io/npm/dm/google-ads-api-report-fetcher.svg?style=flat-square" />
1615
</a>
17-
[![Code Style: Google](https://img.shields.io/badge/code%20style-google-blueviolet.svg)](https://github.com/google/gts)
16+
<a href="https://github.com/google/gts">
17+
<img src="https://img.shields.io/badge/code%20style-google-blueviolet.svg" />
18+
</a>
1819
</p>
1920

2021
## Table of content
2122

22-
- [Overview](#overview)
23-
- [Command Line](#command-line)
24-
- [Install globally](#install-globally)
25-
- [Running from folder](#running-from-folder)
26-
- [Config files](#config-files)
27-
- [Ads API config](#ads-api-config)
28-
- [Library](#library)
29-
- [Development](#development)
30-
23+
- [Overview](#overview)
24+
- [Command Line](#command-line)
25+
- [Install globally](#install-globally)
26+
- [Running from folder](#running-from-folder)
27+
- [Config files](#config-files)
28+
- [Ads API config](#ads-api-config)
29+
- [Library](#library)
30+
- [Development](#development)
3131

3232
## Overview
33-
>You need [Node.js](https://nodejs.org/) to run the tool.
34-
v16 should be sufficient.
33+
34+
> You need [Node.js](https://nodejs.org/) to run the tool.
35+
> v16 should be sufficient.
3536
3637
## Command Line
38+
3739
### Install globally
40+
3841
```shell
3942
npm i google-ads-api-report-fetcher -g
4043
```
44+
4145
then you can run the tool with `gaarf` and `gaarf-bq` commands:
46+
4247
```shell
4348
gaarf <files> [options]
4449
```
4550

51+
If you have both versions install (Python and Node) you can run the Node-version explicitly via `gaarf-node` alias.
52+
4653
Documentation on available options see in the root [README.md](../README.md).
4754

4855
### Running from folder
56+
4957
If you cloned the repo into "ads-api-fetcher" folder, then
5058
run `npm i --production` in ads-api-fetcher/js folder,
5159
after than we can run the tool directly:
60+
5261
```shell
5362
ads-api-fetcher/js/gaarf <files> [options]
5463
```
64+
5565
or
66+
5667
```shell
5768
node ads-api-fetcher/js/dist/cli.js <files> [options]
5869
```
5970

60-
6171
### Config files
72+
6273
Besides passing options explicitly (see the root [README.me](../README.md) for
6374
full description) you can use config files.
6475
By default the tool will try to find `.gaarfrc` starting from the current folder
6576
up to the root. If found, options from that file will be used if they weren't
6677
supplied via command line.
6778

6879
Example of `.gaarfrc`:
80+
6981
```json
7082
{
71-
"ads-config": ".config/google-ads.yaml",
72-
"output": "bq",
73-
"csv.destination-folder": "output",
74-
"macro": {
75-
"start_date": "2022-01-01",
76-
"end_date": "2022-02-10"
77-
},
78-
"account": 1234567890,
79-
"bq.project": "myproject",
80-
"bq.dataset": "mydataset",
81-
"bq.dump-schema": true
83+
"ads-config": ".config/google-ads.yaml",
84+
"output": "bq",
85+
"csv.destination-folder": "output",
86+
"macro": {
87+
"start_date": "2022-01-01",
88+
"end_date": "2022-02-10"
89+
},
90+
"account": 1234567890,
91+
"bq.project": "myproject",
92+
"bq.dataset": "mydataset",
93+
"bq.dump-schema": true
8294
}
8395
```
96+
8497
Please note that options with nested values, like 'bq.project', can be specified
8598
either as objects (see "macro") or as flatten names ("bq.project").
8699

@@ -91,6 +104,7 @@ file (as alternative to JSON) with a similar structure:
91104
`gaarf <files> --config=gaarf.yaml`
92105

93106
Example of a yaml config:
107+
94108
```yaml
95109
ads-config: .config/google-ads.yaml
96110
output: bq
@@ -104,26 +118,30 @@ bq.dataset: mydataset
104118
```
105119
106120
Similarly a config file can be provided for the gaarf-bq tool:
121+
107122
```
108123
gaarf-bq bq-queries/*.sql --config=gaarf-bq.yaml
109124
```
110-
(again it can be either YAML or JSON)
111125

126+
(again it can be either YAML or JSON)
112127

113128
#### Ads API config
129+
114130
There are two mechanisms for supplying Ads API configuration (developer token, etc ).
115131
Either via a separated yaml-file whose name is set in `ads-config` argument or
116132
via separated CLI arguments starting `ads.*` (e.g. `--ads.client_id`) or
117133
in a config file (`ads` object):
134+
118135
```json
119136
{
120-
"ads": {
121-
"client_id": "...",
122-
"developer_token": ".."
123-
},
124-
"output": "bq",
137+
"ads": {
138+
"client_id": "...",
139+
"developer_token": ".."
140+
},
141+
"output": "bq"
125142
}
126143
```
144+
127145
Such a yaml-file is a standard way to configure Ads API Python client -
128146
see [example](https://github.com/googleads/google-ads-python/blob/HEAD/google-ads.yaml).
129147

@@ -132,25 +150,26 @@ search for a local file "google-ads.yaml" and if it exists it will be used.
132150

133151
See more help with `--help` option.
134152

135-
136153
## Library
154+
137155
How to use Gaarf as a library in your own code.
138156
First you need to create an instance of `GoogleAdsApiClient` which represents the Ads API
139157
(it's a tiny wrapper around [Opteo/google-ads-api library](https://github.com/Opteo/google-ads-api) - open-source Ads API client for NodeJS).
140158

141159
> NOTE: there is no an official Ads API client for NodeJS from Google, but the Opteo's client
142-
is a result of collaboration between Opteo and Google, so it's kinda a semi-official client.
160+
> is a result of collaboration between Opteo and Google, so it's kinda a semi-official client.
143161
144162
`GoogleAdsApiClient` expects an object with Ads API access settings (TS-interface `GoogleAdsApiConfig`).
145163
You can construct it manually or load from a yaml or json file (e.g. google-ads.yaml)
146164
using `loadAdsConfigFromFile` function.
165+
147166
```ts
148167
import {
149168
GoogleAdsApiClient,
150169
AdsQueryExecutor,
151170
loadAdsConfigFromFile,
152-
CsvWriter}
153-
from 'google-ads-api-report-fetcher';
171+
CsvWriter,
172+
} from 'google-ads-api-report-fetcher';
154173

155174
const adsConfig = await loadAdsConfigFromFile('google-ads.yaml');
156175
const client = new GoogleAdsApiClient(adsConfig);
@@ -168,24 +187,39 @@ for (let scriptPath of scriptPaths) {
168187

169188
If you need to process results from queries (and not just rely on a writer) then
170189
use `executeGen` method (it's a async generator):
190+
171191
```ts
172-
let results = await executor
173-
.executeGen(scriptName, queryText, customers, params, writer);
174-
for await (let res of results) {
175-
//res.rows - array of rows for one customer
176-
}
192+
let results = await executor.executeGen(
193+
scriptName,
194+
queryText,
195+
customers,
196+
params,
197+
writer
198+
);
199+
for await (let res of results) {
200+
//res.rows - array of rows for one customer
201+
}
177202
```
178203

179-
180204
To execute a single query for a single customer use `executeOne` method:
205+
181206
```ts
182-
let query = executor.parseQuery(queryText, params);
183-
let result = await executor.executeOne(query, customerId);
207+
let query = executor.parseQuery(queryText, params);
208+
let result = await executor.executeOne(query, customerId);
184209
```
185210

186-
# Development
187-
## Run typescript directly
211+
## Development
212+
213+
### Run typescript directly
214+
188215
```
189216
node -r ./node_modules/ts-node/register src/cli.ts ...
190217
```
191218

219+
## License
220+
221+
[Apache-2.0](LICENSE)
222+
223+
## Disclaimer
224+
225+
This is not an officially supported Google product.

0 commit comments

Comments
 (0)