How the integration works
The service builds a URL using the spreadsheet ID stored inSharedService, fetches the sheet as a JSON payload, strips a fixed-length wrapper added by the Visualization API, and hands the resulting data to the import component for parsing.
Spreadsheet ID
The spreadsheet ID is stored as a field onSharedService:
shared.service.ts
Updating the spreadsheet ID
Copy your spreadsheet ID
Open your Google Spreadsheet. From the address bar, copy the segment between
/d/ and /edit. For example:Open shared.service.ts
Locate
src/app/services/shared.service.ts in the project source. Find the sheetPalabrasClave field.Visualization API URL
SharedService.getPalabrasClave() constructs the fetch URL using the stored ID:
shared.service.ts
tqx=out:json query parameter instructs the Visualization API to return data as JSON. The response is typed as text rather than json because the API wraps its payload in a non-standard prefix that must be removed before parsing.
Response parsing
The Visualization API response is not raw JSON — it is wrapped in a JavaScript callback stub. The import component strips this wrapper before callingJSON.parse:
importar.component.ts
| Operation | Effect |
|---|---|
data.substring(47) | Removes the 47-character prefix (e.g. /*O_o*/\ngoogle.visualization.Query.setResponse() |
.slice(0, -2) | Removes the 2-character suffix ();) |
JSON.parse(...) | Parses the remaining string as standard JSON |
Spreadsheet column structure
The application reads two logical datasets from the same sheet. Both datasets share the same rows — each row may contribute to keywords, the media catalog, or both.| Column | Index | Field name | Description |
|---|---|---|---|
| A | 0 | palabra | Keyword or phrase used for text matching |
| B | 1 | padre | Parent category (government area). Use semicolons to assign multiple categories, e.g. Salud;Destacadas |
| C | 2 | (unused) | Reserved; not read by the application |
| D | 3 | sigla | Media outlet or program abbreviation (e.g. LV4) |
| E | 4 | nombre | Full name of the media outlet or program (e.g. La Voz 4) |
The first row is treated as a header. After loading, the application calls
.splice(0, 1) on both the keywords array and the media catalog array to discard it.Permissions
The spreadsheet must be accessible without authentication. The Visualization API fetches the sheet as an anonymous HTTP request — there is no OAuth flow in the application.Set access to Anyone with the link
Under General access, select Anyone with the link and set the role to Viewer.
Troubleshooting
Import fails with no keywords or media loaded
Import fails with no keywords or media loaded
- Confirm the spreadsheet ID in
shared.service.tsis correct. - Open the Visualization API URL directly in your browser:
If you see an HTML page or a
401error, the spreadsheet is not publicly accessible. Review the permissions steps above.
Parsing error after response is received
Parsing error after response is received
The 47-character prefix strip assumes the standard Visualization API wrapper. Log the raw response to verify:Adjust the
substring offset if Google has changed the wrapper format.Header row appears as a keyword or media entry
Header row appears as a keyword or media entry
The application removes the first row of each array with
.splice(0, 1) after loading. If your spreadsheet does not have a header row in row 1, real data will be discarded. Ensure row 1 contains column labels (e.g. Keyword, Category, (blank), Sigla, Nombre).