import requests
import time


def elements_json_overpass(overpass_query):
    """
    This function gets the response of the Overpass
    API according to a query. It returns a json. It
    must be used when the overpy can not get specific
    elements from API response. Example: bound limits
    of a way from Open Street Map.

    :param overpass_query:      String

    :return:                    list
    """
    data = {}
    overpass_url = "http://overpass-api.de/api/interpreter"
    while True:
        try:
            response = requests.get(overpass_url, params={'data': overpass_query})
            data = response.json()
        except:
            time.sleep(30)
            continue
        break
    elements = data.get("elements")
    return elements