def history(self, query, date):
        """
        Method performs a lookup of the history for a given
        keyword.

        Note: the date should be either datetime.datetime
        instance or a string of format YYYYMM.
        """
        if isinstance(date, datetime):
            date = date.strftime("%Y%m")
        elif isinstance(date, basestring):
            try:
                # Validating date format
                datetime.strptime(date, "%Y%m")
            except ValueError:
                raise ApiError("Invalid date format")
        else:
            raise ApiError("Invalid date format")

        dom = parse(self._request("ApiHistory", {"ApiKey": self.apikey,
                                                 "Query": query,
                                                 "Date": date}))
        if self._validate(dom):
            # We have just one query, which doesn't change,
            # from item to item, so it's convinient to
            # wrap it in a partial.
            _HistoryKeyword = partial(HistoryKeyword, query)
            keywords = map(_HistoryKeyword(query),
                           dom.getElementsByTagName("data"))
            return keywords

        Method performs a lookup of the history for a given
        keyword.

        Note: the date should be either datetime.datetime
        instance or a string of format YYYYMM.
        
recipes/Python/577018_Wordzecom_API_bindings/recipe-577018.py