Reference

Public API

Overpass.queryFunction
query(query_or_file::String; bbox::Bbox=nothing, center::Center=nothing)::String

Sends 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_endpoint function.
  • Throws a DomainError if the query is invalid or the Overpass API returns an error.
source
Overpass.statusFunction
status()::Status

Fetches 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, or nothing if unavailable.

Notes

  • Use set_endpoint to modify the API endpoint before calling this function.
  • Throws an error if the API status response cannot be parsed.
source
Overpass.set_endpointFunction
set_endpoint(endpoint::Union{Nothing, String}=nothing)::Bool

Sets 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 to nothing, the default endpoint is restored.

Returns

  • Bool: true if the endpoint is successfully set, otherwise false.

Notes

  • If the endpoint does not have a trailing slash, the function issues a warning and does not set the endpoint.
source
Overpass.turbo_urlFunction
turbo_url(query_or_file::String)::String

Generates 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;"
source

Private API

Overpass.replace_shortcutsFunction
replace_shortcuts(
	query::AbstractString, bbox::Bbox, center::Center
)::AbstractString

Replaces 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. Pass nothing to skip replacement.
  • center::Center: A center point tuple (lat, lon) to replace {{center}} in the query. Pass nothing to 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.
source
Overpass.get_queryFunction
get_query(query_or_file::String)::String

Determines 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 .ql or .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"
source
Overpass.unescapehtmlFunction
unescapehtml(i::AbstractString)::AbstractString

Unescapes 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 &lt;World&gt;!")
"Hello <World>!"
source