import requests
import json


def get_pushshift_submissions(query, sub):
    """
    Retrieves Reddit submissions matching query term over a given interval
    Parameters
    ----------
    query : str
    Query term to match in the reddit submissions
    sub : str
    Submission match query

    Returns
    -------
    Dictionary with submissions data
    """
    url = 'https://api.pushshift.io/reddit/search/submission/?q='+str(query)+'&size=1000'+'&subreddit='+str(sub)
    print(url)
    r = requests.get(url)
    data = json.loads(r.text)
    return data['data']