serpapi / public-roadmap

Public Roadmap for SerpApi, LLC (https://serpapi.com)
45 stars 3 forks source link

[Google Reverse Image API] Use tbs parameter on the Google Reverse Image API #1573

Open schaferyan opened 2 months ago

schaferyan commented 2 months ago

A user reached out to ask how tbs can be used with our Google Reverse Image API.

Google seems to support tbs for Reverse Image Search, the same way other Google search engines do.

If you open the search_metadata.google_reverse_image_url, then select Tools > Time > Past Week, qdr:w is appended to the tbs value in the URL, and filtered results are returned:

Screenshot 2024-04-25 at 3 52 08 PM

Reverse Google Image Search w/ Past Week filter

However, if you add qdr:w as the tbs value when using our Google Reverse Images API, empty results are returned:

Screenshot 2024-04-25 at 10 25 48 AM

Playground

I also tried adding the full value of the tbs from the Google Reverse Image Search URL:

Playground 2

But that also seems to return empty.

My guess is that this has something to do with the direct relationship of tbs to the Reverse Search endpoint.

I noticed that when opening the url from search_metadata.google_reverse_image_url https://www.google.com/searchbyimage?image_url=https://i.imgur.com/HBrB8p0.png&sbisrc=cr_1_5_2 seems to resolve to

https://www.google.com/search?tbs=sbi:AMhZZiuwaausYDRNlYv7ikD3kLXQw_1qqygKUbvPYV1ezepeTR6pH_1YbdDDprErbdXwKPQz96ssueMFIa6Gidx9Cj8B8uu0hQRelRpSine4A0XyGXQXAZhhQNNhR4YOpZpPVWi2LgddNtMiot182cv3MWMENhxF2FQMiNd-KB3MMy9rLDR2mUAfaCPJaTc6u0cDvy7LolSmW_1ky3ohoHfP_1UNrvLdvakGK-92euFuzwMfsf-s8Lw6uoeB_1G-A6F6nQlJfsVKsoBIFJ6crb8bL0nxrQeLALfFmf2oo9MztGo-MoMaD8rWjedDpen47Xo_1imI3KEJcKRuY7X3crYwEIfcQYOKpE5FvY9Q

which is mostly a very long tbs value.

My best guess is that somehow the way we are handling additional tbs values passed to our API is somehow interfering with the tbs value generated for Reverse Image Search.

Intercom

schaferyan commented 2 months ago

As an update it appears that using the full tbs value form the resolved URL and appending the new tbs value seems to work:

https://serpapi.com/playground?engine=google_reverse_image&image_url=https%3A%2F%2Fi.imgur.com%2FHBrB8p0.png&tbs=sbi%3AAMhZZis1_15bdc3YcxOaJ95u-y78A1ynPou8uGqjUM0ZKT5YdZ7P8SMt7kr8-T5RqIkjBu301L9MSrJex6Qr37hMzeF4xW_1THZgwdlaIGhCbfwYoIRvN5yHRbO9aYHHzwGfhCcPXFPiq9jn3Z_1ozkxmC0aeTh-opJd26wuyp-OuIs8ccHZupdASRJVhnmowsJZVHCRotU7dpPB4oiJrLQUZUPdbNy4jg5TS2Ssb_1U1vDp75SPvc2SMYTdTXB_1Ntyy2K2EgpjpbbFV1pUgOlsFw8csaMaO7qbwKp12tWInDnnn4CbX3h_13I1AKc0G6RhSEEef1S5cHEKNzE5UGKaLSL4J7hzwYtb9WGA%2Cqdr%3Aw

If possible we should try to do this from our side to make it simpler for the user. If not we should update our documentation.