def calculate_interval(start_time, end_time, deltas=None):
    """Calculates wanted data series interval according to start and end times

    Returns interval in seconds
    :param start_time: Start time in seconds from epoch
    :param end_time: End time in seconds from epoch
    :type start_time: int
    :type end_time: int
    :param deltas: Delta configuration to use. Defaults hardcoded if no
      configuration is provided
    :type deltas: dict(max time range of query in seconds: interval to use
      in seconds)

    :rtype: int - *Interval in seconds*
    """
    time_delta = end_time - start_time
    deltas = deltas if deltas else {(900): 10, (1800): 30, (259200): 60, (
        604800): 300, (1209600): 600, (2419200): 900, (4838400): 1800, (
        9676800): 3600, (31536000): 7200, (126144000): 43200}
    for delta in sorted(deltas.keys()):
        if time_delta <= delta:
            return deltas[delta]
    return 86400
