# Google Product

Search Amazon to retrieve product listings with pricing, ratings, and availability in JSON format.

## Endpoint

```
GET /v1/product/search/{query}
```

## Description

The Google Product Search endpoint allows you to search for products on Amazon and retrieve structured product data. The query parameter should be a URL-encoded query string.

## Authentication

All requests require authentication using the `X-Api-Key` header. See the [Authentication guide](/docs/guides/authentication) for more details.

## Path Parameters

### `query` (required)

**Type:** `string`

A URL-encoded query string for product search.

**Examples:**
- `q=iphone+14`
- `q=laptops`

## Request Headers

### `X-Proxy-Location` (optional)

**Type:** `string`

Specify the proxy location for the search. Supported countries: `EU`, `CA`, `US`, `IE`, `GB`, `FR`, `DE`, `SE`, `IN`, `JP`, `KR`, `SG`, `AU`, `BR`.

### `X-User-Agent` (optional)

**Type:** `string`

Optional header to specify device type `desktop` or `mobile`. Defaults to `desktop`.

**Allowed values:** `desktop`, `mobile`

## Example Requests

### cURL

```bash
curl --request GET \
  --url 'https://api.serply.io/v1/product/search/q=iphone+14' \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: YOUR_API_KEY'
```

### JavaScript

```javascript
const response = await fetch('https://api.serply.io/v1/product/search/q=iphone+14', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'X-Api-Key': 'YOUR_API_KEY'
  }
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.serply.io/v1/product/search/q=iphone+14"
headers = {
    "Content-Type": "application/json",
    "X-Api-Key": "YOUR_API_KEY"
}

response = requests.get(url, headers=headers)
data = response.json()
print(data)
```

## Response

The response is a JSON object containing product listings from Amazon.

### Response Structure

```json
{
  "products": [
    {
      "link": "string",
      "asin": "string",
      "title": "string",
      "price": "number",
      "real_position": "number",
      "img_url": "string",
      "rating_stars": "string",
      "review_count": "number",
      "extras": ["string"],
      "bestseller": "boolean",
      "prime": "boolean",
      "is_sponsor": "boolean"
    }
  ],
  "ads": ["array"],
  "ts": "number",
  "device_type": "null"
}
```

### Response Fields

#### `products` (array)

An array of product objects, each containing:

- **`link`** (string): URL to the product page on Amazon
- **`asin`** (string): Amazon Standard Identification Number
- **`title`** (string): Product title
- **`price`** (number): Product price
- **`real_position`** (number): Position of the product in search results
- **`img_url`** (string): URL to the product image
- **`rating_stars`** (string): Star rating (e.g., "4.3 out of 5 stars")
- **`review_count`** (number): Number of reviews
- **`extras`** (array of strings): Additional product information (shipping, stock status, etc.)
- **`bestseller`** (boolean): Whether the product is a bestseller
- **`prime`** (boolean): Whether the product is Prime eligible
- **`is_sponsor`** (boolean): Whether the product is a sponsored listing

#### `ads` (array)

Array of advertisement objects (typically empty).

#### `ts` (number)

Timestamp of the response.

#### `device_type` (null)

Device type used for the search.

### Example Response

```json
{
  "products": [
    {
      "link": "https://www.amazon.com/Apple-iPhone-13-Pro-Sierra/dp/B09LPN7C8Z/ref=sr_1_2?keywords=iphone+14&qid=1668626152&sr=8-2",
      "asin": "B09LPN7C8Z",
      "title": "Apple iPhone 13 Pro, 256GB, Sierra Blue - Unlocked (Renewed)",
      "price": 914.97,
      "real_position": 3,
      "img_url": "https://m.media-amazon.com/images/I/51UuPZLMaCL._AC_UY218_.jpg",
      "rating_stars": "4.3 out of 5 stars",
      "review_count": 308,
      "extras": [
        "Get it as soon as Fri, Nov 18",
        "FREE Shipping",
        "Only 10 left in stock - order soon."
      ],
      "bestseller": false,
      "prime": false,
      "is_sponsor": false
    }
  ],
  "ads": [],
  "ts": 2.0670101642608643,
  "device_type": null
}
```

## Status Codes

- **200 OK**: Successful request
- **201 Created**: Request processed successfully
- **404 Not Found**: Resource not found
- **422 Unprocessable Entity**: Validation error
- **429 Too Many Requests**: Rate limit exceeded

## Error Handling

If an error occurs, the API will return an appropriate HTTP status code with an error message in the response body.
