Location Autocomplete
curl --request GET \
--url https://scrapebadger.com/v1/gumtree/locations/autocomplete \
--header 'X-API-Key: <x-api-key>'import requests
url = "https://scrapebadger.com/v1/gumtree/locations/autocomplete"
headers = {"X-API-Key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<x-api-key>'}};
fetch('https://scrapebadger.com/v1/gumtree/locations/autocomplete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://scrapebadger.com/v1/gumtree/locations/autocomplete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://scrapebadger.com/v1/gumtree/locations/autocomplete"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://scrapebadger.com/v1/gumtree/locations/autocomplete")
.header("X-API-Key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://scrapebadger.com/v1/gumtree/locations/autocomplete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"query": "<string>",
"result_count": 123,
"locations": [
{
"id": 123,
"name": "<string>",
"type": "<string>",
"latitude": 123,
"longitude": 123
}
]
}Reference
Location Autocomplete
Resolve a UK town, area or postcode prefix to Gumtree locations with coordinates.
GET
/
v1
/
gumtree
/
locations
/
autocomplete
Location Autocomplete
curl --request GET \
--url https://scrapebadger.com/v1/gumtree/locations/autocomplete \
--header 'X-API-Key: <x-api-key>'import requests
url = "https://scrapebadger.com/v1/gumtree/locations/autocomplete"
headers = {"X-API-Key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<x-api-key>'}};
fetch('https://scrapebadger.com/v1/gumtree/locations/autocomplete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://scrapebadger.com/v1/gumtree/locations/autocomplete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://scrapebadger.com/v1/gumtree/locations/autocomplete"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://scrapebadger.com/v1/gumtree/locations/autocomplete")
.header("X-API-Key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://scrapebadger.com/v1/gumtree/locations/autocomplete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"query": "<string>",
"result_count": 123,
"locations": [
{
"id": 123,
"name": "<string>",
"type": "<string>",
"latitude": 123,
"longitude": 123
}
]
}Resolve a place name or postcode prefix to the locations Gumtree knows, each
with its coordinates. Pass a result’s
name (a town) or a postcode as
location to /search.
Credits: 1
Authorization
string
required
Your ScrapeBadger API key.
Query Parameters
string
required
Town, area or postcode prefix — at least 2 characters, e.g.
manch, leed
or SW1A.Response
string
Echo of the requested prefix.
integer
Number of locations.
LocationSuggestion[]
Example
curl "https://scrapebadger.com/v1/gumtree/locations/autocomplete?query=leed" \
-H "X-API-Key: YOUR_API_KEY"
const res = await fetch(
"https://scrapebadger.com/v1/gumtree/locations/autocomplete?" +
new URLSearchParams({ query: "leed" }),
{ headers: { "X-API-Key": process.env.SCRAPEBADGER_API_KEY } },
);
const { locations } = await res.json();
import requests
res = requests.get(
"https://scrapebadger.com/v1/gumtree/locations/autocomplete",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"query": "leed"},
)
locations = res.json()["locations"]
Response
{
"query": "leed",
"result_count": 2,
"locations": [
{
"id": 10000360,
"name": "Leeds",
"type": "location",
"latitude": 53.808019,
"longitude": -1.541784
},
{
"id": 52026,
"name": "Leeds City Centre, West Yorkshire",
"type": "location",
"latitude": 53.797899,
"longitude": -1.548119
}
]
}
/search also takes a full UK postcode directly as location
(location=SW1A 1AA&distance=2), so you only need this endpoint to resolve
partial input or to show the user a choice.Errors
| Status | Meaning |
|---|---|
422 | query is shorter than 2 characters, or Gumtree temporarily refused the request. Not billed — retry the latter shortly. |

