diff --git a/twarc/expansions.py b/twarc/expansions.py index 4e4c05b7..b628cd20 100644 --- a/twarc/expansions.py +++ b/twarc/expansions.py @@ -208,10 +208,13 @@ def expand_payload(payload): elif isinstance(data, dict): tweets = [expand_payload(response["data"])] - # Add the __twarc metadata to each tweet if it's a result set + # Add the __twarc metadata and matching rules to each tweet if it's a result set if "__twarc" in response: for tweet in tweets: tweet["__twarc"] = response["__twarc"] + if "matching_rules" in response: + for tweet in tweets: + tweet["matching_rules"] = response["matching_rules"] else: raise ValueError(f"missing data stanza in response: {response}")