Reference
Public API
Overpass.query — Functionquery(query_or_file::String; bbox::Bbox=nothing, center::Center=nothing)::StringSends a query to the Overpass API and retrieves the response as a string.
The query can be provided directly or by specifying the path to a .ql or .overpassql file. Supports replacement of shortcuts like {{bbox}} and {{center}}.
Arguments
query_or_file::String: The Overpass query string or path to a query file.bbox::Bbox: Optional bounding box(min_lat, min_lon, max_lat, max_lon)to replace{{bbox}}in the query.center::Center: Optional center point(lat, lon)to replace{{center}}in the query.
Returns
String: The response from the Overpass API.
Notes
- To change the Overpass API endpoint, use the
set_endpointfunction. - Throws a
DomainErrorif the query is invalid or the Overpass API returns an error.
Overpass.status — Functionstatus()::StatusFetches and parses the current status of the Overpass API.
Returns
Status: A struct containing the following fields:connection_id::String: The connection ID assigned by the server.server_time::DateTime: The current server time in UTC.endpoint::Union{Nothing, String}: The announced endpoint (if any).rate_limit::Int: The rate limit (requests per minute).avalible_slots::Union{Nothing, Int}: The number of available slots for requests, ornothingif unavailable.
Notes
- Use
set_endpointto modify the API endpoint before calling this function. - Throws an error if the API status response cannot be parsed.
Overpass.set_endpoint — Functionset_endpoint(endpoint::Union{Nothing, String}=nothing)::BoolSets or resets the Overpass API endpoint for all queries.
Arguments
endpoint::Union{Nothing, String}: The Overpass API endpoint URL. Must end with a trailing slash. If set tonothing, the default endpoint is restored.
Returns
Bool:trueif the endpoint is successfully set, otherwisefalse.
Notes
- If the endpoint does not have a trailing slash, the function issues a warning and does not set the endpoint.
Overpass.turbo_url — Functionturbo_url(query_or_file::String)::StringGenerates an Overpass Turbo URL for a given query.
This is useful for debugging queries visually in the Overpass Turbo interface.
Arguments
query_or_file::String: The Overpass query string or path to a query file.
Returns
String: The generated Overpass Turbo URL.
Example
julia> turbo_url("[out:json];node[amenity=school](50.6,7.0,50.8,7.3);out;")
"https://overpass-turbo.eu/?Q=[out:json];node[amenity=school](50.6,7.0,50.8,7.3);out;"Private API
Overpass.replace_shortcuts — Functionreplace_shortcuts(
query::AbstractString, bbox::Bbox, center::Center
)::AbstractStringReplaces predefined shortcuts (e.g., {{bbox}}, {{center}}, {{date}}) in the given Overpass query string with their corresponding values.
Arguments
query::AbstractString: The Overpass query string containing shortcuts.bbox::Bbox: A bounding box tuple(min_lat, min_lon, max_lat, max_lon)to replace{{bbox}}in the query. Passnothingto skip replacement.center::Center: A center point tuple(lat, lon)to replace{{center}}in the query. Passnothingto skip replacement.
Returns
AbstractString: The modified query string with all applicable shortcuts replaced.
Notes
- The function checks for any unreplaced shortcuts and throws an error if found.
Overpass.get_query — Functionget_query(query_or_file::String)::StringDetermines if the input is a direct query string or a file path, and returns the query content.
Arguments
query_or_file::String: The Overpass query string or file path.
Returns
String: The query content as a string.
Notes
- If the input ends with
.qlor.overpassql, it is treated as a file path and the file's content is returned. - If the input is not a file path, it is returned as-is.
Example
julia> get_query("[out:json];node[amenity=school](50.6,7.0,50.8,7.3);out;")
"[out:json];node[amenity=school](50.6,7.0,50.8,7.3);out;"
julia> get_query("query.ql")
"Contents of query.ql"Overpass.unescapehtml — Functionunescapehtml(i::AbstractString)::AbstractStringUnescapes special HTML characters (&, <, >, ", ') in a string.
Arguments
i::AbstractString: The input string with HTML entities.
Returns
AbstractString: A string with HTML entities replaced by their corresponding characters.
Example
julia> unescapehtml("Hello <World>!")
"Hello <World>!"