Free API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • betdynamics
    Junior Member
    • Sep 2010
    • 534

    #1

    Free API

    Under the old v6 API, there was the ability to log on to the API using any Betfair account as long as you were logging on to the free API (i.e. the product id was the free API product id).

    Is there an equivalent in the API-NG? (i.e. is there a standard AppKey that is used for the "free" API)

    I only ask as I have a friend who has asked me to knock up a quick utility for him. Does he have to register for an AppKey in order for his Betfair account to be able to use the API-NG ?
  • Guest

    #2
    Originally posted by betdynamics View Post
    Under the old v6 API, there was the ability to log on to the API using any Betfair account as long as you were logging on to the free API (i.e. the product id was the free API product id).

    Is there an equivalent in the API-NG? (i.e. is there a standard AppKey that is used for the "free" API)

    I only ask as I have a friend who has asked me to knock up a quick utility for him. Does he have to register for an AppKey in order for his Betfair account to be able to use the API-NG ?
    I believe the answer is yes, he will need his own AppKey for his Betfair account.

    As far as keys go, only the live and delay key available, however betfair have stated here somewhere that the API_NG will be free (however will restrict the number of times you can call the API per second.)

    Comment

    • davecon
      Junior Member
      • Dec 2010
      • 86

      #3
      Hi Betdynamics
      Its just the same as the old one as far as I can see (With Just one Set of AppKeys required by the compiler with this new one)
      I can log into all my sub accounts and also My Dads and my Friends accounts with just my own AppKeys (Both Live and Delay) using just their UserName and Password
      Get your mates password and have a go (He can change it first of course)
      Betfair will have to do it this way because how would they know (BF) which was a Sub Account or another Persons? Only other way would to Limit everybody to just one account but that would not be practical
      Hope this helps (I am talking about the UK though - Aus cant have sub accounts for instance so dont know about other countries)
      Dave

      Originally posted by betdynamics View Post
      Under the old v6 API, there was the ability to log on to the API using any Betfair account as long as you were logging on to the free API (i.e. the product id was the free API product id).

      Is there an equivalent in the API-NG? (i.e. is there a standard AppKey that is used for the "free" API)

      I only ask as I have a friend who has asked me to knock up a quick utility for him. Does he have to register for an AppKey in order for his Betfair account to be able to use the API-NG ?

      Comment

      • bnl
        Junior Member
        • Nov 2012
        • 108

        #4
        I run the same bot with two accounts.
        Me and a friend are developing the bot, and we have one account each.
        The bot uses the same AppKey, since it IS the same app.
        It does use different accounts and passwords though (using the interactive login)
        /Björn

        Comment

        • mizar1
          Junior Member
          • Dec 2009
          • 12

          #5
          I also have the same problem

          in the case that says BNL but 'the app the key you created for your account I do not think it is right to use it to distribute to various users

          you should create a appkey for each user

          Comment

          • bnl
            Junior Member
            • Nov 2012
            • 108

            #6
            Still, it's called 'AppKey', not 'AccountKey', nor 'UserKey'
            If Betfair wants a distinct key for all user and bot combinations, it should state that clearly.
            I interpret 'AppKey' as an id for an application, so it can be traced if misbehaved.
            At login, you give username and 'AppKey', so if I am not correct, the second user I log in with should be denied.
            But that is not happening -> it ok using same AppKey for the same bot with different logins.

            It would be extremely annoying if I made a iPhone/Android-app that was downloaded by the thousands,
            and I had to create a new 'AppKey' for every user.


            /Björn

            Comment

            • mizar1
              Junior Member
              • Dec 2009
              • 12

              #7
              ok thanks
              but 'I can only create a appkey, and if I wanted to do more applications?
              Use the same appkey for other applications?

              Comment

              • betdynamics
                Junior Member
                • Sep 2010
                • 534

                #8
                Originally posted by bnl View Post
                It would be extremely annoying if I made a iPhone/Android-app that was downloaded by the thousands,
                and I had to create a new 'AppKey' for every user.
                You don't!

                What you need to do is to get your App (and its associated AppKey) accredited by BDP. Once you have done that, your AppKey allows User Management, so you can control the people who have access to the app.

                People using the app still need to be "activated" which is done through the subscriber functions in the API.

                Comment

                • bnl
                  Junior Member
                  • Nov 2012
                  • 108

                  #9
                  Well, I guess that depends.
                  What is an application?
                  I have a _collection_ of programs/processes
                  that collaborate. There are at least 6 different
                  executables. I consider them together as one bot,
                  a bot system, hence they all share AppKey.

                  But if I would write something completely unrelated,
                  I'd probably would get another AppKey.

                  But I really think Betfair should clarify its intended use of
                  AppKeys

                  /Björn

                  Comment

                  • smilerdude
                    Junior Member
                    • Jun 2010
                    • 11

                    #10
                    This is my very simplistic understanding of App Keys from my developing of my bot and reading the documentation.

                    If you are developing own Bot.

                    1) For a bot to gain access to the API, it needs to be associated with a valid Betfair account, hence the App Key generation and the need to upload that App Key to Betfair.

                    2) The App Key is sent in every request to the API along with a current valid session token.

                    3) You can have many Bots as you want accessing a single Betfair account, as long as they pass the App Key with a valid session token.

                    Note about session tokens, some markets require session token to be updated every 15 minutes, e.g. Italian Football markets. At the moment for most markets, the session token only needs to be updated every 24 hours. This generic time period can be altered without warning in future.

                    Best practice is to run the Keep Alive call every 10-15 minutes to acquire a valid session token that can sent for any specific market calls.

                    4) If you have 2 Betfair accounts, you will need to generate a separate App Key for each account. Bots accessing each account will need to have the Session tokens to be associated correctly with the correct App Key.

                    I deal with this by creating a Shared Memory object which is populated at startup with data from a database. Each bot accesses the Shared Memory to update or get the requested session token and app key before each request to the API is sent


                    Pseudo Code

                    Code:
                    class Acnt_Details {
                        private int _default_int = -1;
                        private int _id = _default_int;
                        private string _username = "";
                        private string _app_key = "";
                        private string _delayed_app_key = "";
                        private string _session_token = "";
                    
                        setSessionToken(string token) { _session_token = token; }
                        
                        string getSessionToken() { return (!isEmpty(_session_token)) ? _session_token : ""; }
                        
                        string getAppKey() { return (!isEmpty(_app_key)) ? _app_key : ""; }
                    }
                    
                    class ShMem_Acnt_Details {
                        private int _default_int = -1;
                        private int _nbr_of_loaded_acnts = _default_int;
                        private List _acnts <int, Acnt_Details>;
                    
                        int addAcntToShMem(Acnt_Details acnt) {
                            int success = _default_int;
                            try {
                                ++_nbr_of_loaded_acnts;
                                _acnts.add(acnt);
                                success = 1;
                            }
                            catch exceptions {...}
                    
                            return success;
                        }
                    
                        int updateAcntSessionToken(string app_key, string token) {
                            int success = _default_int;
                    
                            try {
                                if ((_nbr_of_loaded_acnts > _default_int) &&
                                    (isString(app_key) && isString(token))) {
                                    
                                     foreach (acnt in _acnts) {
                                        if (acnt.getAppKey() == app_key) {
                                            acnt.setSessionToken(token);
                                            success = 1;
                                        }
                                    }
                                }
                            }
                            catch exceptions{...}
                    
                            return success;
                        }
                    }

                    If you are needing information about Subscriber App Key, this is very specific for those people who are intending to be a Vendor, i.e sell their bots.

                    If your are going down this route, then I can explain further.
                    Last edited by smilerdude; 28-05-2014, 12:12 AM.

                    Comment

                    • bnl
                      Junior Member
                      • Nov 2012
                      • 108

                      #11
                      4) If you have 2 Betfair accounts, you will need to generate a separate App Key for each account. Bots accessing each account will need to have the Session tokens to be associated correctly with the correct App Key.
                      Why? Where did you read this?
                      I'd say that the combination AppKey and Account is unique.
                      The token is generated by Betfair and surely they can
                      trace back the account a certain token was associated with.

                      But it would be nice with a Betfair comment on intended use
                      /Björn

                      Comment

                      • smilerdude
                        Junior Member
                        • Jun 2010
                        • 11

                        #12
                        You're correct that the App Key and Account is a unique combination.

                        On the API NG documentation page about Application Keys, the very first paragraph at the top of the page:

                        Application Keys

                        Added by Mark Levitt, last edited by Neil Thomas on May 13, 2014 (view change)
                        Go to start of metadata


                        In order to use the Betting API, you need to have an Application Key. The Application Key identifies your API client. Two App Keys are assigned to a single Betfair account, one live App Key and one delayed App Key.
                        This would mean if you have 2 Betfair accounts, e.g. Account A and Account B.

                        You would need to generate a live App Key/delayed App Key for account A and another separate live App Key/delayed App Key for account B.


                        I was also going into the realms of session/connection management which the Session Tokens form part of. Yes Betfair generate the session tokens, the bot uses that unique session token for 20 minutes, before your Bot needs to request another one via the KeepAlive method call.

                        From a security point of view, if your Bot is accessing 2 accounts, Betfair generates a session token for the connection/calls to Account A and generates another unique Session Token for the connection/calls to Account B. If Betfair isn't doing this, I would be very surprised. Hence my pseudo code for session/connection House Keeping when you're Bot connects to 2 accounts.

                        I don't have 2 betfair accounts, so I could be wrong if this case, my bad.

                        I'm just using my experience of developing Server/Client programs for the Banking/Electricity industries and having to read/understand detailed (sometimes vague) industry technical API documents for interfaces and message formats.
                        Last edited by smilerdude; 28-05-2014, 01:22 PM.

                        Comment

                        • betdynamics
                          Junior Member
                          • Sep 2010
                          • 534

                          #13
                          My understanding...

                          The AppKey relates to the application NOT the user.

                          There is no need to generate another AppKey for the software to be used by another user. If you have two Betfair accounts, then you should be able to use the app using the same AppKey.

                          If you have two Betair accounts, you can generate different AppKeys per account, but they should be used for different applications.

                          Comment

                          • bnl
                            Junior Member
                            • Nov 2012
                            • 108

                            #14
                            You would need to generate a live App Key/delayed App Key for account A and another separate live App Key/delayed App Key for account B.
                            No, I do not think so. Imagine the Betfair iPhone App.
                            Do you _really_ think there is one AppKey for each user that
                            downloaded the app? To what purpose?

                            From a security point of view, if your Bot is accessing 2 accounts,
                            Sorry, I was perhaps not clear enough. My bot(system) is running
                            in parallel. One instance is stuck to one account.

                            At no time is a single process connected to more that one account.

                            However, there are always 6-10 processes connected to
                            Betfair per account. They all log in, with the same AppKey,
                            and same account, and get a token each, which they use
                            and maintain via KeepAlive. But they are all part
                            of the same 'Application'
                            /Björn

                            Comment

                            • gus
                              Senior Member
                              • Jan 2009
                              • 134

                              #15
                              Nope, that's not how it works.

                              The developer appKey that you create via the visualiser IS linked to your Betfair account ... that's why you have to provide a Session Cookie (SSOID) when you are creating an appKey.

                              For example, If I'm helping another person to create an API-NG application, they obviously don't want me to have access to their account, so I would develop the application using my own developer appKey (the same kind that anyone can create using the Visualiser), hardcoded into the app, and then when the app is ready for them to use, they have to create their own developer appKey, with a unique appName, (again using the visualiser).

                              They then let me know their appKey, and I replace my appKey in the code with theirs, and then they can use the app on their account.

                              I can't use the version that has their appKey (bcause I don't know their Username/Password) and they couldn't use mine.

                              So you can create any number of apps, so long as they all use the same developer appKey that you created in the Visualiser, but they can only be used on the account that the appKey was created on, unless you change the appKey (in the code, as above).

                              I should emphasize that's the procedure for 'one-off' developer Apps. The procedure for Vendor apps is different and quite a bit more complicated!

                              Comment

                              Working...
                              X