Google Shopping API (Async)

This endpoint will retrieve shopping data from a Google shopping result page and transform it into usable JSON.

Single Query Request:

require 'net/http'
require 'json'
require 'uri'
uri = URI('https://async.scraperapi.com/structured/google/shopping')
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = {
  apiKey: 'APIKEY',
    query: 'QUERY',
    tld: 'TLD',
    uule: 'UULE',
    num: 'NUM',
    hl: 'HOSTLANGUAGE',
    gl: 'GUESTLANGUAGE',
    ie: 'QUERYENCODING',
    oe: 'RESULTENCODING',
    start: 'START',  callback: {
    type: 'webhook',
    url: 'CALLBACK'
  }
}.to_json
begin
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end
  puts response.body
rescue => e
  puts "Error: #{e.message}"
end

Multiple Query Request:

require 'net/http'
require 'json'
require 'uri'
uri = URI('https://async.scraperapi.com/structured/google/shopping')
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = {
  apiKey: 'APIKEY',
    query: ['QUERY1', 'QUERY2', 'QUERY3'],
    tld: 'TLD',
    uule: 'UULE',
    num: 'NUM',
    hl: 'HOSTLANGUAGE',
    gl: 'GUESTLANGUAGE',
    ie: 'QUERYENCODING',
    oe: 'RESULTENCODING',
    start: 'START',  callback: {
    type: 'webhook',
    url: 'CALLBACK'
  }
}.to_json
begin
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end
  puts response.body
rescue => e
  puts "Error: #{e.message}"
end

Multiple Parameters can be used with this method:

Sample Response

Single Query Request:

{
	"id": "89b388bf-0cea-49c1-8db6-9e00042c8c3a",
	"status": "running",
	"statusUrl": "http://async.scraperapi.com/structured/google/shopping/89b388bf-0cea-49c1-8db6-9e00042c8c3a",
	"query": "Skateboard"
}

Multiple Query Request:

[
	{
		"id": "2955ad23-c812-475c-bc52-572576815d78",
		"status": "running",
		"statusUrl": "http://async.scraperapi.com/structured/google/shopping/2955ad23-c812-475c-bc52-572576815d78",
		"query": "Skateboard"
	},
	{
		"id": "120a7344-7832-4fd0-a64f-ce9cd39726f3",
		"status": "running",
		"statusUrl": "http://async.scraperapi.com/structured/google/shopping/120a7344-7832-4fd0-a64f-ce9cd39726f3",
		"query": "Charcoal Grill"
	}
]

After the job(s) finish, you will find the result under the response key in the response JSON object. The structure is the same as in the corresponding SYNC data endpoint.

Last updated