Automation With Python

The Bet Angel API makes it easy for you to further enhance your betting and trading by integrating your own code into Bet Angel
Post Reply
Diginet
Posts: 122
Joined: Tue Jul 09, 2013 1:43 pm

Hi

Does anyone have a Python code to automatically add automation rules to Guardian ?

Thanks in advance
User avatar
Euler
Posts: 27002
Joined: Wed Nov 10, 2010 1:39 pm

Check out the Bet Angel API section of the forum.
sniffer66
Posts: 1886
Joined: Thu May 02, 2019 8:37 am

You want to add a new rule or apply an existing rule to a number of markets ?

If it's the latter, these 2 funcs will get you started.

Code: Select all

    def apply_rules(self, market_ids):
        url = f"{self.base_url}guardian/v1.0/applyRules"
        payload = {
            "rulesFileName": "Log Winner",
            "marketsFilter": {"filter": "SPECIFIED_IDS", "ids": market_ids},
            "guardianRulesColumn": 1
        }
        try:
            r = requests.post(url, headers=self.headers, json=payload)
            r.raise_for_status()
            logger.info(f"Rules applied: {r.json()}")
        except requests.RequestException as e:
            logger.error(f"Error applying rules: {e}")
-

    def get_markets(self, data_required: Optional[List[str]] = None) -> Dict[str, Any]:
        if data_required is None:
            data_required = [
                "ID","NAME","MARKET_START_TIME","EVENT_ID","EVENT_TYPE_ID", # Ensure EVENT_ID is requested
                "MARKET_TYPE","SELECTION_IDS","SELECTION_NAMES","SELECTIONS","START_TIME"
            ]
        url = f"{self.base_url}markets/v1.0/getMarkets"
        r = requests.post(url, headers=self.headers, json={"dataRequired": data_required}, timeout=20)
        r.raise_for_status()
        return r.json()
Diginet
Posts: 122
Joined: Tue Jul 09, 2013 1:43 pm

Hi

Thank you for all your help. I have the code to add markets to a Coupon then into Guardian. I was looking to then add my automation rules to those markets added

Cheers
sniffer66
Posts: 1886
Joined: Thu May 02, 2019 8:37 am

So use the apply_rules func I posted then :)
Diginet
Posts: 122
Joined: Tue Jul 09, 2013 1:43 pm

Perfect thank you
Post Reply

Return to “Bet Angel - API”