Extract GSC data, create endpoint json output
-
hi I’m looking for a way to extract google search console data (like impressions, clicks and visitors) to use this for other purposes. Is it possible to create a sort of api endpoint which generates a json?
-
Yes it’s possible.
I’m planning to add an export feature. Do you need to export json or do you need an endpoint to extract data by yourself?
Yes an endpoint url which contains the data in json format so I’m able to extract it myself.
You’re a life saver if you could create something like that. I’m looking for ages for such functionality. Let me know if I can test or anything else. That would be great. Thanks!
-
This reply was modified 1 month, 3 weeks ago by
piet00.
But do you want this to be consumed inside wordpress or should be externally available? Can you contact me on my site for further explanation?
Thanks
External available because I want to scrape/extract the data with another solution, outside WordPress.
For instance I do the same with Plausible, website analytics, they created an API which I use and looks like this (as an example):
but it doesn’t have to be extensive with filters and such. Data of the current day, week or month is good enough, but I don’t know which data you have/store from search console at this point.
Yes if you prefer that: is https://www.francescopepe.com the website?
Yes the website is francescopepe.com.
This plugin does not store any data from Search Console. It fetch it in real time.
I’ve created a sample repo to get what you’re looking for.
Please be aware that you need to be autenticated to access this data from outside WP.
Here’s the repo: https://github.com/Tropicalista/search-console-addon
exactly what I was looking for, many thanks!
I responded to your email about a dimentions question
Please check the updated code at: https://github.com/Tropicalista/search-console-addon
Hi! I’m testing the new update but it results in an error. Am I doing something wrong? see what I’m trying to do: https://ibb.co/PYYhsBH
it keeps saying “startDate field is required.”
What I’m trying to do is this: https://developers.google.com/webmaster-tools/v1/how-tos/search_analytics#top-10-pages,-sorted-by-click-count,-descending
but that fails on the same reason. also when I try to use “[‘page’] as dimention.
Do you know what the correct way is use this dimention?
You must pass the startDate and endDate in payload, not in the url. I’ve changed the code to be more in sync with the API.
fetch('http://localhost:10005/wp-json/searchconsole/v1/json_data?site=MYSITE', { method: 'POST', headers: { 'Authorization': 'Basic ' + btoa('YOURUSER:XXXX XXXX XXXX XXXX XXXX') }, body: JSON.stringify({ startDate: '2024-05-01', endDate: '2024-05-21', dimensions: ['page'], type: 'web', rowLimit: 10 }) }) .then(response => response.json()) .then(json => console.log(json));
-
This reply was modified 1 month, 1 week ago by
tropicalista.
Ah ofcourse, it works now as expected. Thanks!
One last thing, the only account in WordPress that is able to execute commands is the admin account.
I’ve tested with a new account and different permissions, all fails.
Is there a way to grant another account permissions to only execute/use your plugin/addon?
-
This reply was modified 1 month, 3 weeks ago by
- You must be logged in to reply to this topic.