List locations - Hamlet API

List locations

cURL

curl --request GET \
  --url 'https://api.myhamlet.com/v1/locations?per_page=50' \
  --header 'Authorization: Bearer <token>'

Python

import requests

url = "https://api.myhamlet.com/v1/locations?per_page=50"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)

JavaScript

const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.myhamlet.com/v1/locations?per_page=50', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://api.myhamlet.com/v1/locations?per_page=50",\
  CURLOPT_RETURNTRANSFER => true,\
  CURLOPT_ENCODING => "",\
  CURLOPT_MAXREDIRS => 10,\
  CURLOPT_TIMEOUT => 30,\
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
  CURLOPT_CUSTOMREQUEST => "GET",\
  CURLOPT_HTTPHEADER => [\
    "Authorization: Bearer <token>"\
  ],\
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>

Go

package main

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

func main() {

url := "https://api.myhamlet.com/v1/locations?per_page=50"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Unirest (Java)

HttpResponse<String> response = Unirest.get("https://api.myhamlet.com/v1/locations?per_page=50")
  .header("Authorization", "Bearer <token>")
  .asString();

Ruby

require 'uri'
require 'net/http'

url = URI("https://api.myhamlet.com/v1/locations?per_page=50")

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

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

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

HTTP Status Codes

Example Response

{
  "data": [
    {
      "uuid": "5f2b0c3a-1d4e-4a8b-9f6d-2a1c3e4b5d6f",
      "type": "CITY",
      "name": "Palo Alto",
      "state_name": "California",
      "state_abbreviation": "CA",
      "county_names": [
        "Santa Clara"
      ],
      "created_at": "2025-01-10T00:00:00.000Z",
      "updated_at": "2026-05-01T18:22:10.000Z"
    }
  ],
  "next_cursor": "eyJ1IjoiMjAyNi0wNS0wMSAxODoyMjoxMCIsImkiOjQyfQ"
}

Error Response

{
  "error": {
    "code": "not_found",
    "message": "The requested resource was not found."
  }
}

Authorization

Query Parameters