# Locations List

We use Google Geographical Targeting, that’s why you can use it as a data source. These are the location types ‘Autonomous Community’, ‘Borough’, ‘City’, ‘Country’, ‘Governorate’, ‘Municipality’, ‘Postal Code’, ‘Prefecture’, ‘Province’, ‘Region’, ‘State’, ‘Territory’, ‘Union Territory’.\
\
Download the CSV file of full list of supported locations: [Google Locations](https://serphouse-space.nyc3.digitaloceanspaces.com/google_locations.csv) And [Bing Locations](https://serphouse-space.nyc3.digitaloceanspaces.com/bing_locations.csv).\
\
By calling this API you will receive the list of locations available for our SERP API

{% hint style="danger" %}
Requires authentication
{% endhint %}

## Get a  list of locations available for our SERP API

<mark style="color:blue;">`GET`</mark> `https://api.serphouse.com/location/search`

#### Query Parameters

| Name                                   | Type   | Description                                                                                                                                                                                                   |
| -------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| q<mark style="color:red;">\*</mark>    | String | search in our location database                                                                                                                                                                               |
| type<mark style="color:red;">\*</mark> | String | <p>Type can be <code>google</code> and <code>bing</code><br>Google and Bing have a different locations so if you are targeting on Bing then pass type as <code>bing</code> otherwise <code>google</code>.</p> |

#### Headers

| Name                                            | Type   | Description              |
| ----------------------------------------------- | ------ | ------------------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer \<YOUR\_API\_KEY> |

{% tabs %}
{% tab title="200: OK Successful operation" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    "status": "success",
    "msg": "ok",
    "results": [
        {
            "id": 9113189,
            "name": "Texas's 33rd Congressional District 2022 redistricting",
            "loc": "Texas's 33rd Congressional District 2022 redistricting,Texas,United States",
            "type": "Congressional District",
            "country_code": "US"
        },
        {
            "id": 9113190,
            "name": "Texas's 34th Congressional District 2022 redistricting",
            "loc": "Texas's 34th Congressional District 2022 redistricting,Texas,United States",
            "type": "Congressional District",
            "country_code": "US"
        },
        {
            "id": 9113191,
            "name": "Texas's 35th Congressional District 2022 redistricting",
            "loc": "Texas's 35th Congressional District 2022 redistricting,Texas,United States",
            "type": "Congressional District",
            "country_code": "US"
        },
        {
            "id": 9113192,
            "name": "Texas's 36th Congressional District 2022 redistricting",
            "loc": "Texas's 36th Congressional District 2022 redistricting,Texas,United States",
            "type": "Congressional District",
            "country_code": "US"
        },
        {
            "id": 9113193,
            "name": "Texas's 37th Congressional District 2022 redistricting",
            "loc": "Texas's 37th Congressional District 2022 redistricting,Texas,United States",
            "type": "Congressional District",
            "country_code": "US"
        },
        {
            "id": 9113194,
            "name": "Texas's 38th Congressional District 2022 redistricting",
            "loc": "Texas's 38th Congressional District 2022 redistricting,Texas,United States",
            "type": "Congressional District",
            "country_code": "US"
        },
        {
            "id": 9040743,
            "name": "Texas's 1st Congressional District 2012 redistricting",
            "loc": "Texas's 1st Congressional District 2012 redistricting,Texas,United States",
            "type": "Congressional District",
            "country_code": "US"
        },
        {
            "id": 9040744,
            "name": "Texas's 10th Congressional District 2012 redistricting",
            "loc": "Texas's 10th Congressional District 2012 redistricting,Texas,United States",
            "type": "Congressional District",
            "country_code": "US"
        },
        {
            "id": 9040745,
            "name": "Texas's 11th Congressional District 2012 redistricting",
            "loc": "Texas's 11th Congressional District 2012 redistricting,Texas,United States",
            "type": "Congressional District",
            "country_code": "US"
        },
        {
            "id": 9040746,
            "name": "Texas's 12th Congressional District 2012 redistricting",
            "loc": "Texas's 12th Congressional District 2012 redistricting,Texas,United States",
            "type": "Congressional District",
            "country_code": "US"
        }
    ]
}
</code></pre>

{% endtab %}

{% tab title="401: Unauthorized Unauthenticated" %}

```json
{
    "status": "error",
    "msg": "Unauthenticated"
}
```

{% endtab %}
{% endtabs %}

## Example request:

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

```bash
curl --location --request GET 'https://api.serphouse.com/location/search?q=texas&type=google' \
--header 'Authorization: Bearer <YOUR_API_KEY>'
```

{% endtab %}

{% tab title="RUBY" %}

```ruby
require "uri"
require "net/http"

url = URI("https://api.serphouse.com/location/search?q=texas&type=google")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <YOUR_API_KEY>"

response = https.request(request)
puts response.read_body

```

{% endtab %}

{% tab title="PYTHON" %}

```python
import requests

url = "https://api.serphouse.com/location/search?q=texas&type=google"

payload={}
headers = {
  'Authorization': 'Bearer <YOUR_API_KEY>'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="NODE.JS" %}

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

var config = {
  method: 'get',
  url: 'https://api.serphouse.com/location/search?q=texas&type=google',
  headers: { 
    'Authorization': 'Bearer <YOUR_API_KEY>'
  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$serphouse = new SERPHouse\SERPHouseClient('YOUR_API_KEY');
$res = $serphouse->location->search(['q' => 'texas', 'type' => 'google']);
echo $res->getResponse();

```

{% endtab %}

{% tab title="JAVA" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
  .url("https://api.serphouse.com/location/search?q=texas&type=google")
  .get()
  .addHeader("Authorization", "Bearer <YOUR_API_KEY>")
  .build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
```

{% endtab %}

{% tab title="JAVASCRIPT" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <YOUR_API_KEY>");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://api.serphouse.com/location/search?q=texas&type=google", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.serphouse.com/location/search?q=texas&type=google"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer <YOUR_API_KEY>")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="C#/.NET" %}

```csharp
var client = new RestClient("https://api.serphouse.com/location/search?q=texas&type=google");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <YOUR_API_KEY>");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
```

{% endtab %}
{% endtabs %}
