rtCamp / search-with-google

A plugin for replacing WordPress default search with Google Custom Search results.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replacing the "Custom Search Site Restricted JSON API" by "Custom Search JSON API"

dhawalepranav opened this issue · comments

We need to document our findings in the following manner.

  • How Custom Search Site Restricted JSON API works?
  • How Custom Search JSON API works?
  • Currently used API in the Plugin and the errors associated with it.
  • Why to replace with Custom Search JSON API?
  • End results and its limitations

Replacing Custom Search JSON API

How Custom Search Site Restricted JSON API work?

  • To use Custom Site Restricted Search JSON API we have make GET request on this https://www.googleapis.com/customsearch/v1/siterestrict API endpoint with necessary parameters like key and cx.
  • Custom Site Restricted Search JSON API can be used as Internal Search because we can only add 10 or fewer sites in PSE (Programmable Search Engine). Search result will return the list from these sites only.
  • Custom Site Restricted Search JSON API has no daily limit and it costs $5 per 1000 queries.
  • From 2023-10-05 new customers attempting to make requests to the Custom Search Site Restricted JSON API will receive a 403 error message response.

How Custom Search JSON API works?

  • To use Custom Search JSON API we have to make GET request on this https://www.googleapis.com/customsearch/v1 API endpoint with necessary parameters like key and cx.
  • Custom Search JSON API provides 100 search queries per day for free. Additional requests cost $5 per 1000 queries, up to 10k queries per day.
  • Custom Search JSON API can search the entire web or list of sites.

Currently used API in the Plugin and the errors associated with it.

  • Currently we are using the Custom Site Restricted Search API in our plugin which will not work for the new users because From 2023-10-05 new customers attempting to make requests to the Custom Search Site Restricted JSON API will receive a 403 error message response.

Why to replace with Custom Search JSON API?

  • If we continue to use the Custom Site Restricted Search API than at one point plugin won't be useful anymore. It will not be able to fetch any data from the web. But by replacing it with Custom Search JSON API plugin will be useful for those users who wants to use Custom Search JSON API.

End results and its limitations

  • Custom Search JSON API has daily search limit so if it runs out the search will stop working.
  • We have to add notice that we are using which API to fetch the search results.

Note: The Custom Search Site Restricted JSON API endpoints will cease to serve traffic on December 18, 2024. ref

  • As per the discussion with @pradeep910 , we have decided to add support for the "Custom Search JSON API"(free 100 search queries) along with the "Custom Search Site Restricted JSON API" in our plugin.

  • "Custom Search Site Restricted JSON API" will be selected as a default API endpoint and we will be adding a toggle button in our plugin settings to enable the "Custom Search JSON API"

@SH4LIN we need to complete the following set of tasks.

  • Add a support for “Custom Search JSON API"
  • Add the toggle button for enabling "Custom Search JSON API"
  • Remove the existing deprecation warning note.
  • Add a new note/notice in WP dashboard to inform all users about newly added support with a settings link and the “Custom Search Site Restricted JSON API” deprecation warning with it's reference link.
  • Documentation update

Before starting any work on this, please add your time estimations for the task and get it reviewed by your Project Co-ordinator or Project Manager

Task Estimation: ~3~4hr

  • Add a toggle button on the settings page to toggle between custom search and custom site-restricted search API. ~1hr~1:30hr
  • Remove the existing deprecation warning note ~5mins
  • Add a new note for the user to display new updates. ~30mins
  • Add logic to provide the support for custom search JSON API ~30mins
  • Test the plugin ~30mins~1hr
  • Document the changes ~30mins

CC: @dhawalepranav

Task Update:

  • A slider button was added on the settings screen to select between Custom Site-restricted Search API and Custom Search API.
  • Notice for the current changes added with the necessary URLs.
  • Plugin functionality tested.
  • Documentation updated with the changelog.
  • Plugin update test is completed. The plugin is getting updated without any issues.
  • Feature is merged into develop.
  • PR for the master branch is in review.

CC: @dhawalepranav