City Search
<h2>Overview</h2>
<p>This API endpoint offers a flexible way to retrieve information about cities by supporting search queries based on city names or UN/LOCODEs. It's designed to help users find detailed city data, including geographic coordinates and zip codes.</p>
<h2>Request</h2>
<ul>
<li>Method: <strong>GET</strong></li>
<li>URI: <code>/cities?query=xxx</code> or <code>/cities?unlocode=xxx</code></li>
</ul>
<p><strong>Warning:</strong> Either the 'query' or 'unlocode' parameter must be present. However, 'unlocode' should be the only active option when both 'query' and 'unlocode' parameters are present.</p>
<h2>Code Example</h2>
<pre><code>Request:
curl https://api.drayeasy.com/api/v2/cities?query=Ontario,CA \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer xxxxxxxxx'
Response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
&quot;data&quot;: [
{
&quot;id&quot;: 115,
&quot;country&quot;: &quot;USA&quot;,
&quot;full_name&quot;: &quot;Ontario, CA, USA&quot;,
&quot;full_name_zipcode&quot;: &quot;Ontario, CA, USA&quot;,
&quot;zipcodes&quot;: [
&quot;91761&quot;,
&quot;91762&quot;,
&quot;91764&quot;
],
&quot;name&quot;: &quot;Ontario&quot;,
&quot;state&quot;: &quot;CA&quot;,
&quot;alias&quot;: null,
&quot;latitude&quot;: 34.0631,
&quot;longitude&quot;: -117.6197
}
]
}</code></pre>
<h2>Respone Fields Description</h2>
<table>
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>Integer</td>
<td>A unique identifier for the city.</td>
</tr>
<tr>
<td>country</td>
<td>String</td>
<td>The country where the city is located.</td>
</tr>
<tr>
<td>full_name</td>
<td>String</td>
<td>The full name of the city, including state and country.</td>
</tr>
<tr>
<td>full_name_zipcode</td>
<td>String</td>
<td>The city's full name, potentially intended for future use to include zip code.</td>
</tr>
<tr>
<td>zipcodes</td>
<td>String[]</td>
<td>An array of zip codes associated with the city.</td>
</tr>
<tr>
<td>name</td>
<td>String</td>
<td>The name of the city.</td>
</tr>
<tr>
<td>state</td>
<td>String</td>
<td>The state or region where the city is located.</td>
</tr>
<tr>
<td>alias</td>
<td>String</td>
<td>An alternative name or alias for the city, if any.</td>
</tr>
<tr>
<td>latitude</td>
<td>Float</td>
<td>The city's geographic latitude.</td>
</tr>
<tr>
<td>longitude</td>
<td>Float</td>
<td>The city's geographic longitude.</td>
</tr>
</tbody>
</table>