# Amazon Autocomplete Scraper

You have to send a GET request to **`https://api.scrapingdog.com/amazon/autocomplete`** with the below-given parameters.

### Parameters

#### Scrapingdog Parameters

| Parameter                                                          | Description                                                                                                           |
| ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
| <p>api\_key</p><p><br><mark style="color:red;">required</mark></p> | <p>Your personal API key.<br><br>Available on your dashboard </p><p></p><p>Type: <em><strong>String</strong></em></p> |

#### Search Query

| Parameter    | Description                                                                                                                                                                                                                  |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| prefix       | <p><code>prefix</code> represent the partial search term that Amazon uses to generate keyword suggestions.<br><br>Type: <em><strong>String</strong></em></p>                                                                 |
| last\_prefix | <p>This indicate that the user first typed "i" and then continued typing "phone" (leading to "iphone").<br><br>Type: <em><strong>String</strong></em></p>                                                                    |
| mid          | <p>In Amazon URLs, <code>mid</code> often refers to the <strong>Merchant IDrting</strong>, which identifies a specific seller on the platform.<br><br>Type: <em><strong>String</strong></em></p>                             |
| suffix       | <p>The <strong><code>suffix</code></strong> parameter in the Amazon Suggestions API plays a key role in handling <strong>search query completion and predictions</strong>.<br><br>Type: <em><strong>String</strong></em></p> |

#### Localization

| Parameter | Description                                                                                                                                                                                                                                                              |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| language  | <p>Language of the results. Possible Values - <strong><code>en</code></strong>, <strong><code>es</code></strong>, <strong><code>fr</code></strong>, <strong><code>de</code></strong>, etc. <br><br>Default Value - en<br><br>Type - <em><strong>String</strong></em></p> |
| domain    | <p>This is the TLD extension of the Amazon page. <br><br>Example - in, com, tr, etc <br><br>Type: <strong><code>String</code></strong></p>                                                                                                                               |

### API Example

{% tabs %}
{% tab title="cURL" %}

```json
curl "https://api.scrapingdog.com/amazon/autocomplete?api_key=5eaa61a6e562fc52fe763tr516e4653&domain=com&prefix=spoon"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

# API URL and key
api_url = "https://api.scrapingdog.com/amazon/autocomplete"
api_key = "5eaa61a6e562fc52fe763tr516e4653"

# Search parameters
domain = "com"
prefix = "spoon"

# Create a dictionary with the query parameters
params = {
    "api_key": api_key,
    "prefix": prefix
}

# Send the GET request with the specified parameters
response = requests.get(api_url, params=params)

# Check if the request was successful (status code 200)
if response.status_code == 200:
    data = response.json()
    print(data)
else:
    print(f"HTTP Request Error: {response.status_code}")

```

{% endtab %}

{% tab title="Node JS" %}

```javascript
const axios = require('axios');

// API URL and key
const apiURL = 'https://api.scrapingdog.com/amazon/autocomplete';
const apiKey = '5eaa61a6e562fc52fe763tr516e4653';

// Search parameters
const prefix = 'spoon';

// Create an object with the query parameters
const params = {
  api_key: apiKey,
  prefix: prefix
};

// Send a GET request with the specified parameters
axios
  .get(apiURL, { params: params })
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error('HTTP Request Error:', error);
  });

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

// API URL and key
$apiURL = 'https://api.scrapingdog.com/amazon/autocomplete';
$apiKey = '5eaa61a6e562fc52fe763tr516e4653';

// Search parameters
$prefix = 'spoon';

// Create an array with the query parameters
$params = [
    'api_key' => $apiKey,
    'prefix' => $prefix
];

// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $apiURL . '?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute cURL session and get the response
$response = curl_exec($ch);

// Check for cURL errors
if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
}

// Close cURL session
curl_close($ch);

// Parse and use the response data
if ($response) {
    $jsonData = json_decode($response, true);
    print_r($jsonData);
} else {
    echo 'No response received.';
}
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'

api_url = 'https://api.scrapingdog.com/amazon/autcomplete'
api_key = '5eaa61a6e562fc52fe763tr516e4653'
query = 'spoon'

params = {
  'api_key' => api_key,
  'query' => query
}

uri = URI(api_url)
uri.query = URI.encode_www_form(params)

response = Net::HTTP.get_response(uri)

if response.is_a?(Net::HTTPSuccess)
  data = JSON.parse(response.body)
  puts data
else
  puts "Request failed with status code #{response.code}"
end

```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        String apiURL = "https://api.scrapingdog.com/amazon/autocomplete";
        String apiKey = "5eaa61a6e562fc52fe763tr516e4653";
        String prefix = "spoon";

        try {
            // Create the URL with query parameters
            URL url = new URL(apiURL + "?api_key=" + apiKey + '"&prefix=" + prefix);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();

            // Set the request method to GET
            connection.setRequestMethod("GET");

            // Get the response code
            int responseCode = connection.getResponseCode();

            if (responseCode == 200) {
                // Read the response data
                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String line;
                StringBuilder response = new StringBuilder();

                while ((line = reader.readLine()) != null) {
                    response.append(line);
                }
                reader.close();

                // Print the response data
                System.out.println(response.toString());
            } else {
                System.out.println("Request failed with response code: " + responseCode);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}
{% endtabs %}

### API Response

```json
[
    {
        "type": "KEYWORD",
        "keyword": "cricket noise maker prank"
    },
    {
        "type": "KEYWORD",
        "keyword": "cricket printer"
    },
    {
        "type": "KEYWORD",
        "keyword": "cricket"
    },
    {
        "type": "KEYWORD",
        "keyword": "cricket bat"
    },
    {
        "type": "KEYWORD",
        "keyword": "live crickets"
    },
    {
        "type": "KEYWORD",
        "keyword": "cricket phones"
    },
    {
        "type": "KEYWORD",
        "keyword": "cricket keeper"
    },
    {
        "type": "KEYWORD",
        "keyword": "live crickets for reptiles"
    },
    {
        "type": "KEYWORD",
        "keyword": "cricket ball"
    },
    {
        "type": "KEYWORD",
        "keyword": "cricket shoes men"
    }
]
```
