import json


def get_entry(file_contents):
    """Loads file from filename and returns the stache information as a tuple.

    Arguments:
        file_contents: File contents which stores X-STACHE-READ-KEY and
            endpoint as a JSON. The contents must be in the format:
        {
            "X-STACHE-READ-KEY": "stache_read_key",
            "endpoint": "stache_endpoint"
        }

    Returns:
        returns (key, url) of the api entry as a tuple.
    """
    creds = json.loads(file_contents)

    # Get key, check for old version of json's first.
    key = creds.get("X-STACHE-READ-KEY")
    if not key:
        key = creds["X-STACHE-KEY"]

    # Grab endpoint.    
    endpoint = creds["endpoint"]

    # Format for request.
    key = {"X-STACHE-KEY": key}
    url = f"https://stache.arizona.edu{endpoint}"
    return key, url