NAV Navbar
protocol python csharp
  • Private API Introduction
  • Private API Calls
  • Data Types
  • Public API Introduction
  • API Libraries & Source Code
  • Private API Introduction

    The Fairlay Private API allows you to POST requests (creating/changing markets and orders, transfering funds, etc.), costs 0.1mBTC per 100.000 requests, see below on how to create your developer API account.

    This is the low level documentation, if you need a working sample or are more comfortable reading code rather than specifications, head over to .NET API Library or Python API Library

    Requisites

    1. An account registered at fairlay
    2. A 2048 bits PEM RSA Key pair. There are multiple types of tools to generate it for you. Tools SSL Example
    3. Create an API account in profile page at https://fairlay.com/developer/api/new/. Will be requested to provide your public key on form.

    Requests

    This is a sample GETBALANCE Request using default ACCOUNT ID 1:

    uiskPc9GqWAdUt1hJ+4VeuxyCNtbs0iY3kSbGQZ7HvwHkCe5H2n9UcX5v1Gl7Mb99XnhBiVzkne5bdkgmLdnlzzEBPLYnt8zwWHcqxXvIYiDpLQhsVfdkvyYwH1zgrUwAZu08VmY0ax34zxjXJdK68TVs9Y1m7akXkw5/NvIwXk=|635972931146604657|100012|1022|<ENDOFDATA>
    

    The response is usually JSON-encoded:

    rfV2ylPLbDbBKEy0yi71xZS/fZbyozd7+smpit1cR8ZeB0qo+stRDttTkCxqF0towkS0bf3lkg4amSbvka6K//QX/F1BHdFNqpkFXQHB9jh2eyR2WgXblKeGRbgw+mma+1P/kKNBtf3qhOUiqOgzONwlTEusiLzqHil6HLTQTKY=|635972681796848020|1066|{"PrivReservedFunds":334.049,"MaxFunds":0.0,"PrivUsedFunds":207.12,"AvailableFunds":126.946}
    

    If there is an error, the server returns an error message starting with XError: for general errors or YError: if there was an error in a subtask of a bulk change order request.

    All requests should be made to this endpoint:

    31.172.83.53:18017

    You must sign messages with your RSA key and provide your signature with all requests:

    nonce|userID|requestID|requestData

    The signature shoud be digested RSA-SHA512 signature encoded in Base64.

    Requests must be send via TCP in the following format:

    signature|nonce|userid|requestID|requestData<ENDOFDATA>

    Every request must end with <ENDOFDATA>

    Remember to use (YOUR API ID*1000)+Request ID on requests. Example: If you create your API accont on Fairlay, site will set an ID to it, usually first API ID is 1. So a request to Get Orderbook with this account will be 1001.

    Private API Calls

    Get Server Time (2)

    Call: signature|nonce|userid|1002

     -
    

    Response: signature|nonce|ServerID|ServerTime

    636451764120705300
    

    Response: Returns the server's time in ticks.

    Note: the server time can also be interfered from the nonce in every response.

    Get Me (21)

    Call: signature|nonce|userid|1021

     -
    

    Response: signature|nonce|ServerID|MeObject

     {
        "LastConnected":"2018-09-14T20:49:08.6830697Z",
        "LastConnectedBal":"2018-09-14T20:49:08.6830697Z",
        "UsedWithdrawalAddress":null,
        "LMSRMarketMaker":null,
        "Disabled":false,
        "NoOnHold":false,
        "PrivRequests":99995,
        "PrivFundsDic":{    
            "0":{
                "PrivTotal":0.1,
                "PrivTransfered":0.1,
                "PrivExchanged":0.0,
                "PrivUsed":0.0
                }
        },
        "Email":blabla@gmail.com,
        "Miner":0,
        "SettleDel":null,
        "APIUsers":{
            "0":{
                "CanSettleMarkets":false,
                "CanChangeTime":false,
                "CanDoAdminStuff":false,
                "CanDoSpecialRequests":false,
                "PrivForceSignature":false,
                "PrivForceNonce":false,
                "PrivPublicKey":"<RSAKeyValue><Modulus>uiskPc9GqWAdUt1hJ+4VeuxyCNtbs0iY3kSbGQZ7HvwHkCe5H2n9UcX5v1Gl7Mb99XnhBiVzkne5bdkgmLdnlzzEBPLYnt8zwWHcqxXvIYiDpLQhsVfdkvyYwH1zgrUwAZu08VmY0ax34zxjXJdK68TVs9Y1m7akXkw5/NvIwXk=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>",
                "DailySpendingLimit":0.0,
                "DailySpent":0.0,
                "ReadOnly":false,
                "TransferOnly":false,
                "ID":0
            }
        },
        "PrivForceConfirmMatched":false,
        "PrivAbsenceCancelMS":2592000000,
        "PrivCBIP":null,
        "FailsCB":0,
        "Screenname":"blabla",
        "ID":100012
    }
    

    Returns: User info object with the following information:

    Get My Balance (22)

    Call: signature|nonce|userid|1022

     -
    

    Response: signature|nonce|ServerID|BalanceObject

    { 
        "PrivReservedFunds": 0.1,
        "MaxFunds": 0,
        "PrivUsedFunds": 0,
        "AvailableFunds": 0.1,
        "SettleUsed": 0,
        "CreatorUsed": 0,
        "OnHold": 0,
        "RemainingRequests": 99996 
    }
    

    Returns: JSON object containing account balance information:

    Set API Account to Readonly (49)

    Call: signature|nonce|userid|1049

     -
    

    Response: signature|nonce|ServerID|success

    "success"
    

    This will permanently set your API Account to Read Only. This cannot be undone.

    Returns: A string "success".

    Get Orderbook (1)

    Call: signature|nonce|userid|1001|marketID

     121046999588
    

    Response: signature|nonce|ServerID|OrderbookArray (example with 2 runners)

     [
         {
            "Bids": [ [3.954, 3.75] ],
            "Asks": [ [7.203, 2.06156] ],
            "S": 1 
        }, {
            "Bids": [ [5.627,2.63] ],
            "Asks": [],
            "S": 1
        }
    ]
    

    Get the orderbook of a given market with specific ID.

    Returns: An Orderbook. See Orderbook

    This is a return from a market with 2 runners.

    Get Orderbooks (4)

    Call: signature|nonce|userid|4|[marketID1, marketID2]

        [121046999588, 121046400020]
    

    Response: signature|nonce|ServerID|MarketIDOrderbookDictionary

    ["121046999588":{
        {    "Bids": [ [3.954, 3.75] ],
             "Asks": [ [7.203, 2.06156] ], 
             "S": 1 
        },{  "Bids": [ [5.627,2.63] ],
             "Asks": [],
             "S": 1
        }
     },
     "121046400020":{
        {   "Bids": [ [3.954, 3.75] ],
            "Asks": [ [7.203, 2.06156] ],
            "S": 1 
        },{ "Bids": [ [5.627,2.63] ],
            "Asks": [],
            "S": 1
        }
     }
    ]
    

    Get the orderbook of a many markets with specifics IDs contained in a array.

    Returns: A dictionary of market ids associated with its corresponding orderbook. See Orderbook data structure.

    Get Market (6)

    Call: signature|nonce|userid|1006|marketid

     109353571206
    

    Response: signature|nonce|ServerID|market

    {
        "Comp":"Politics",
        "Descr":"Donald Trump shall be president of the United States at 11:59:59 p.m.(ET) on December 31, 2019.",
        "Title":"Will Donald Trump be president at year-end 2019?",
        "CatID":15,
        "ClosD":"2019-12-30T23:00:00",
        "SettlD":"2019-12-31T01:00:00",
        "Status":0,
        "Ru":[
            {
                "Name":"Yes",
                "VisDelay":0,
                "RedA":0,
                "VolMatched":263.3703784185025
            },
            {
                "Name":"No",
                "VisDelay":0,
                "RedA":0,
                "VolMatched":0
            }
        ],
        "_Type":2,
        "_Period":1,
        "SettlT":0,
        "Comm":0.02,
        "Settler":{
           "1":true,
           "777889":true
        },
        "ComRecip":{
           "1":1
        },
        "MinVal":0,
        "MaxVal":0,
        "Cur":0,
        "CurB":0,
        "LastCh":"2018-09-17T20:00:48.1019114Z",
        "LastSoftCh":"2018-09-17T20:05:17.9277257Z",
        "LogBugs":"",
        "OrdBStr":"{\"Bids\":[],\"Asks\":[[1.365,49.2173949315],[1.597,19.94164]],\"S\":1}~"
        "Pop":0,
        "Margin":10000,
        "ID":109353571206
    }
    

    Returns: A market object. See Market data structure.

    Get Markets (7)

    Call: signature|nonce|userid|1007|marketFilters

    {
        "Cat":0,
        "RunnerAND":["Arsenal","Chelsea"],
        "TitleAND":null,
        "TitleNOT":["Corners","Throwin"],
        "Comp":"Premier Leag",
        "TypeOR":null,
        "PeriodOR":[1],
        "SettleOR":null,
        "ToSettle":false,
        "OnlyMyCreatedMarkets":false,
        "Descr":null,
        "ChangedAfter":"2016-01-01T22:01:01",
        "SoftChangedAfter":"0001-01-01T00:00:00",
        "OnlyActive":false,
        "MinPop":0.0,
        "MaxMargin":103.0,
        "NoZombie":false,
        "FromClosT":"2016-05-01T00:00:00",
        "ToClosT":"0001-01-01T00:00:00",
        "FromID":0,
        "ToID":100,
    "SortPopular":false
    }
    

    Response: signature|nonce|ServerID|markets

    [  
        {  
           "Comp":"England - Premier League",
           "Descr":"Match",
           "Title":"Cardiff City vs. Arsenal",
           "CatID":1,
           "ClosD":"2018-09-02T12:30:00Z",
           "SettlD":"2018-09-02T14:30:00Z",
           "Status":4,
           "Ru":[  
              {  
                 "Name":"Cardiff City",
                 "VisDelay":6000,
                 "RedA":0,
                 "VolMatched":64.27775
              },
              {  
                 "Name":"Arsenal",
                 "VisDelay":6000,
                 "RedA":0,
                 "VolMatched":0
              },
              {  
                 "Name":"Draw",
                 "VisDelay":6000,
                 "RedA":0,
                 "VolMatched":0
              }
           ],
           "_Type":0,
           "_Period":1,
           "SettlT":0,
           "Comm":0.0025,
           "Settler":{  
              "1":true,
              "777555":true,
              "777889":true
           },
           "ComRecip":{  
              "777555":0.5,
              "1011849":0.5
           },
           "MinVal":0,
           "MaxVal":0,
           "Cur":0,
           "CurB":0,
           "LastCh":"2018-09-02T14:39:08.8189277Z",
           "LastSoftCh":"2018-09-02T14:39:08.8189277Z",
           "LogBugs":"",
           "OrdBStr":"",
           "Pop":12,
           "Margin":10000,
           "ID":146318670899
        },
        {  
           "Comp":"England - Premier League",
           "Descr":"Match",
           "Title":"Newcastle United vs. Arsenal",
           "CatID":1,
           "ClosD":"2018-09-15T14:00:00Z",
           "SettlD":"2018-09-15T16:00:00Z",
           "Status":4,
           "Ru":[  
              {  
                 "Name":"Newcastle United",
                 "VisDelay":6000,
                 "RedA":0,
                 "VolMatched":214
              },
              {  
                 "Name":"Arsenal",
                 "VisDelay":6000,
                 "RedA":0,
                 "VolMatched":0
              },
              {  
                 "Name":"Draw",
                 "VisDelay":6000,
                 "RedA":0,
                 "VolMatched":0
              }
           ],
           "_Type":0,
           "_Period":1,
           "SettlT":0,
           "Comm":0.0025,
           "Settler":{  
              "1":true,
              "777555":true,
              "777889":true
           },
           "ComRecip":{  
              "777555":0.5,
              "1011849":0.5
           },
           "MinVal":0,
           "MaxVal":0,
           "Cur":0,
           "CurB":0,
           "LastCh":"2018-09-15T16:10:27.8171808Z",
           "LastSoftCh":"2018-09-15T16:10:27.8171808Z",
           "LogBugs":"",
           "OrdBStr":"",
           "Pop":12,
           "Margin":10000,
           "ID":146814296539
        }
     ]
    

    Get all markets that satisfies the following filters:

    Returns: An array of all market objects that apply to the given filter. See Market structure.

    Get Markets Orderbook (67)

    Call: signature|nonce|userid|1067|marketFilters

    {
        "Cat":0,
        "RunnerAND":["Arsenal","Chelsea"],
        "TitleAND":null,
        "TitleNOT":["Corners","Throwin"],
        "Comp":"Premier Leag",
        "TypeOR":null,
        "PeriodOR":[1],
        "SettleOR":null,
        "ToSettle":false,
        "OnlyMyCreatedMarkets":false,
        "Descr":null,
        "ChangedAfter":"2016-01-01T22:01:01",
        "SoftChangedAfter":"0001-01-01T00:00:00",
        "OnlyActive":false,
        "MinPop":0.0,
        "MaxMargin":103.0,
        "NoZombie":false,
        "FromClosT":"2016-05-01T00:00:00",
        "ToClosT":"0001-01-01T00:00:00",
        "FromID":0,
        "ToID":100,
        "SortPopular":false
    }
    

    Response: signature|nonce|ServerID|marketIDOrderbookDictionary

    ["121046999588":{
        {    "Bids": [ [3.954, 3.75] ],
             "Asks": [ [7.203, 2.06156] ], 
             "S": 1 
        },{  "Bids": [ [5.627,2.63] ],
             "Asks": [],
             "S": 1
        }
     },
     "121046400020":{
        {   "Bids": [ [3.954, 3.75] ],
            "Asks": [ [7.203, 2.06156] ],
            "S": 1 
        },{ "Bids": [ [5.627,2.63] ],
            "Asks": [],
            "S": 1
        }
     }
    ]
    

    Get all market orderbooks that satisfies your filters. Filters are the same as Get Market:

    Returns: A dictionary of market id associated with its corresponding orderbook. Same structure as Get Orderbooks

    Create Market (11)

    Call: signature|nonce|userid|1011|marketData

    {
        "Comp":"Politics",
        "Descr":"This market resolves to Yes, if the Senate confirms Merrick Garland’s Supreme Court nomination before President Obama leaves the office.",
        "CatID":15,
        "ClosD":"2016-11-01T00:00:00",
        "SettlD":"2017-01-20T00:00:00",
        "Ru":
        [
            {
                "Name":"Yes",
                "InvDelay":0,
                "VisDelay":6000
            },{
                "Name":"No",
                "InvDelay":0,
                "VisDelay":6000
            }
        ],
        "_Type":2,
        "_Period":1,
        "SettlT":0,
        "Comm":0.02,
        "PrivCreator":784741,
        "CreatorName":"USERNAME"
    }
    

    Response: signature|nonce|ServerID|marketid

    121046400020
    

    Create a market with the following data:

    Returns: The created market id.

    Create Order (62)

    Call: signature|nonce|userid|1062|marketid|runnerid| bidorask|price|amount|type|matchesubuser|pendingperiod

    71601335718|0|1|1.56|100.1|2|testorder|6000
    

    Response: signature|nonce|ServerID|UnmatchedOrderObject

    {
        "Price":1.04,
        "RemAmount":0.05,
        "State":0,
        "BidOrAsk":0,
        "PrivAmount":0.05,
        "PrivSubUser":"balanceorder",
        "PrivCancelAt":3155378975999999999,
        "makerCT":0,
        "_Type":0,
        "PrivID":633728772777882209,
        "PrivUserID":1132152
    }
    

    Create an order with the following information:

    Returns: A Unmatched Order Object. See Unmatched Order Object for details.

    Cancel Order (15)

    Call: signature|nonce|userid|1015|marketid|runnerid|orderid

    71601335718|0|636728772330883209
    

    Response: signature|nonce|ServerID|cancelledOrderList

     IN PROGRESS (call)
    

    Cancel orders that matches:

    Returns: a list of all corresponding matched order objects for the cancelled unmatched order.

    Cancel Market Orders (10)

    Call: signature|nonce|userid|1010|marketID

    71601335718
    

    Response: signature|nonce|ServerID|stringResponse

     '2 Orders were cancelled'
    

    Cancel all opened orders on specific market, with the market id equals to marketID.

    Returns: A string containing how many unmatched orders were cancelled.

    Cancel All Orders (16)

    Call: signature|nonce|userid|1016

     -
    

    Response: signature|nonce|ServerID|stringResponse

     '5 Orders were cancelled'
    

    Cancel all user orders.

    Returns: A string containing how many unmatched orders were cancelled.

    Change Order (17)

    Call: signature|nonce|userid|1017|marketid|runnerid|orderid|price|amount

    71601335718|0|636728772330883209|1.56|100.1
    

    Response: signature|nonce|ServerID|unmatchedOrder

    {
        "Price":1.07,
        "RemAmount":0.03,
        "State":0,
        "BidOrAsk":0,
        "PrivAmount":0.05,
        "PrivSubUser":"balanceorder",
        "PrivCancelAt":3155378975999999999,
        "makerCT":0,
        "_Type":0,
        "PrivID":633728772777882209,
        "PrivUserID":1132152
    } IN PROGRESS (call)
    

    Is a combination of "cancel order" and "create order"

    Returns: An Unmatched Order Object. See Unmatched Order Object for details.

    Bulk Change Order Maker (109)

    Call: signature|nonce|userid|1109|RequestChangeOrderArray

    [
        {
            "Am": "2.00",
            "Pri": "1.537",
            "Boa": 1,
            "Type": 2,
            "Mid": 149972421088,
            "Rid": 0,
            "LayAsL": false,
            "CAt": 0,
            "Mct": 0,
            "Oid": -1
        }
    ]
    

    Response: signature|nonce|ServerID|REQChangeOrderArray

    [
        {
            "Mid":149972421088,
            "Rid":0,
            "Oid":-1,
            "Am":2.00,
            "Pri":1.537,
            "Sub":null,
            "Type":2,
            "Boa":1,
            "Mct":0,
            "LayAsL":false,
            "CAt":0,
            "Res":"{\"Price\":1.537,\"RemAmount\":0.0,\"State\":1,\"BidOrAsk\":1,\"PrivAmount\":2.00,\"PrivSubUser\":null,\"PrivCancelAt\":3155378975999999999,\"makerCT\":0,\"_Type\":2,\"PrivID\":636741074031960092,\"PrivUserID\":1007510}"
        }
    ]
    

    Changes, cancels and creates many orders at once. Pass a Request Change Order Array with the following:

    Returns: An array of REQChangeOrder objects. Each array element contains the same structure of the call plus the attribute Res.

    Get New Orders (24)

    Call: signature|nonce|userid|1024|timeinticks

    636729639366023200
    

    Response: signature|nonce|ServerID|orders

    {
        "TimeStamp":636729639366023200,
        "UnMatched":
        [
            {
                "_UserOrder":
                {
                    "BidOrAsk":0,
                    "MarketID":148678516313,
                    "RunnerID":1,
                    "OrderID":636729633911939100,
                    "MatchedSubUser":null
                },
                "_UnmatchedOrder":
                {
                    "Price":1.04,
                    "RemAmount":0.02,
                    "State":0,
                    "BidOrAsk":0,
                    "PrivAmount":0.02,
                    "PrivSubUser":"balanceorder",
                    "PrivCancelAt":3155378976000000000,
                    "makerCT":0,
                    "_Type":0,
                    "PrivID":636729633911939100,
                    "PrivUserID":1032152
                }
            }
        ],
        "Matched":
        [
            {
                "_UserOrder":
                {   
                    "BidOrAsk":0,
                    "MarketID":148678516313,
                    "RunnerID":1,
                    "OrderID":"636729682302455151",
                    "MatchedSubUser":"balanceorder"
                },
                "_MatchedOrder":
                {
                    "Price":1.04,
                    "Amount":0.02,
                    "Red":0,
                    "DecResult":0,
                    "R":0,
                    "ID":"636729682302455151",
                    "State":0,
                    "MakerCancelTime":0
                },
                "_UserUMOrderID":"636729633911939057"
            }
        ]
    }
    
    

    Get all orders after timeinticks.

    Returns: All user unmatched orders and matched orders that were created, cancelled or changed after the given time, with the following structure:

    Get Unmatched Orders (25)

    Call: signature|nonce|userid|1025|timeinticks

    636451764120705300
    

    Response: signature|nonce|ServerID|orders

    [
        {
            "_UserOrder":
            {
                "BidOrAsk":0,
                "MarketID":148678778313,
                "RunnerID":1,
                "OrderID":"636728772330883209",
                "MatchedSubUser":null
            },
            "_UnmatchedOrder":
            {
                "Price":1.04,
                "RemAmount":0.05,
                "State":0,
                "BidOrAsk":0,
                "PrivAmount":0.05,
                "PrivSubUser":"balanceorder",
                "PrivCancelAt":"3155378975999999999",
                "makerCT":0,
                "_Type":0,
                "PrivID":"636728772330883209",
                "PrivUserID":1043252
            }
        }
    ]
    

    Get all user unmatched orders after timeinticks.

    Returns: An array containing all user unmatched orders that were created, cancelled or changed after the given time. Each array element is made of an UserOrderObject and a UnmatchedOrderObject.

    Get Matched Orders (27)

    Call: signature|nonce|userid|1025|timeinticks

    636451764120705300
    

    Response: signature|nonce|ServerID|orders

    [
        {
            "_UserOrder":
            {   
                "BidOrAsk":0,
                "MarketID":148678516313,
                "RunnerID":1,
                "OrderID":"636729682302455151",
                "MatchedSubUser":"balanceorder"
            },
            "_MatchedOrder":
            {
                "Price":1.04,
                "Amount":0.02,
                "Red":0,
                "DecResult":0,
                "R":0,
                "ID":"636729682302455151",
                "State":0,
                "MakerCancelTime":0
            },
            "_UserUMOrderID":"636729633911939057"
        }
    ]
    
    

    Get all user matched orders after timeinticks.

    Returns: An array containing all user matched orders that were created, cancelled or changed after the given time. Each array element is made of:

    Transfer Founds/Withdraw (81)

    Call: signature|nonce|userid|1081|transferobject

    {
        "FromU": 1002307,
        "ToU": 111111,
        "Cur": 0,
        "Descr": "1QDr7soMdj4SEiD8aCpbDTHAqV23VcGyZA;0.4",
        "TType": 2,
        "Amount": 3000.4
    }
    

    Response: signature|nonce|ServerID|transferedObject

    {
        "Cur":0,
        "ID2":118437536700,
        "FromU":1002307,
        "ToU":111111,
        "Descr":"1QDr7soMdj4SEiD8aCpbDTHAqV23VcGyZA;0.4",
        "TType":2,
        "Amount":3000.4
    }
    

    Returns: If successful, returns the same object sent plus an atribute ID2:

    Get User Transaction (82)

    Call: signature|nonce|userid|1082|timeinticks

    636451764120705300
    

    Response: signature|nonce|ServerID|transactionArray

    [
        {
            "Cur":0,
            "ID2":116885599551,
            "FromU":1006092,
            "ToU":1012052,
            "Descr":"API test",
            "TType":3,
            "Amount":0.1
        }
    ]
    

    Get all user transactions since given timeinticks.

    Returns: An array of transactions with the following structure:

    Set Market Maker (73)

    Call: signature|nonce|userid|1073|lmsrmarketmakerobject

    {
        "UserID":777888,
        "MarketID":76650963889
        "Runner":5,
        "Enabled":true,
        "InitShareLimit":350.0,
        "B":1300.0,
        "CancelAll":"2016-06-05T13:34:56", 
        "ShareStop":1400.0,
        "InitProb":[0.3,0.1,0.2,0.2,0.2],
        "DiminishBack":[0.01,0.01,0.01,0.0,0.02],
        "DiminishLay":[0.0,0.0,0.0,0.01,0.01],
        "coolOffSeconds":36000.0,
        "coolOffFactor":4.0
    }
    

    Response: signature|nonce|ServerID

     IN PROGRESS (result)
    

    This sets up an fully automated LMSR market maker. Google the term to get familiar with the usage.

    Cool off adds temporary additional margin to markets with increased activity and should be applied to markets that can have exogenous shocks or where real probabilities can deviate from the initial probability distribution.

    Disable a MM by setting Enabled = false and other variables to a valid value.

    Get Market Maker (70)

    Call: signature|nonce|userid|1070|marketid

    61659266392
    

    Response: signature|nonce|ServerID|lmsrmarketmakerobject

    {
        "UserID":777888,
        "MarketID":61659266392,
        "Runner":5,
        "Enabled":true,
        "InitShareLimit":350.0,
        "B":1300.0,
        "CancelAll":"2016-06-05T13:34:56",
        "ShareStop":1400.0,
        "InitProb":[0.3,0.1,0.2,0.2,0.2],
        "DiminishBack":[0.01,0.01,0.01,0.0,0.02],
        "DiminishLay":[0.0,0.0,0.0,0.01,0.01],
        "coolOffSeconds":36000.0,
        "coolOffFactor":4.0
    }
    

    Gets the current LMSR MM from the user for a given market with market id equals to marketid.

    Returns: An lmsr market maker object with the following data:

    Change Market Closing Time (84)

    Changes Closing and Settlement Date

    Call: signature|nonce|userid|1084|ChangeTimeObject

    {
        "MID":76650963889,
        "ClosD":"2016-06-11T01:00:00Z",
        "SetlD":"2016-06-11T03:00:00Z"
    }
    

    Response: signature|nonce|ServerID|marketTimeChanged

    IN PROGRESS (precondition)
    

    Change the market closing time.

    Returns: MarketTime changed.

    Get Statements (85)

    Call: signature|nonce|userid|1085|timeinticks

    636451764120705300
    

    Response: signature|nonce|ServerID|statement

    [
        {
            "ID":85349599553,
            "Descr":"API test",
            "T":3,
            "Am":0.1,
            "Bank":0.1,
            "Cur":0
        }
    ]
    

    Gets all bankroll adjustments after a given time.

    Returns: An array of statement Object:

    Settle Market (86)

    Call: signature|nonce|userid|1086|SettleRequestObject

    {
        "Mid":77588905280,
        "Runner":0,
        "Win":1,
        "Half":false,
        "Dec":0.0,
        "ORed":0.0
    }
    

    Response: signature|nonce|ServerID|stringResponse

    "Market settled"
    

    Settles a given market. Note that the total betting volume of the market will be deducted from the available balance for 2 to 3 days. Unless the user has special rights, a user can only settle markets he created.

    Returns: A string "Market settled" in case of confirmation or an type of "XError", otherwise.

    Data Types

    Market

    {
        "Comp":"Politics",
        "Descr":"Donald Trump shall be president of the United States at 11:59:59 p.m.(ET) on December 31, 2019.",
        "Title":"Will Donald Trump be president at year-end 2019?",
        "CatID":15,
        "ClosD":"2019-12-30T23:00:00",
        "SettlD":"2019-12-31T01:00:00",
        "Status":0,
        "Ru":[
            {
                "Name":"Yes",
                "VisDelay":0,
                "RedA":0,
                "VolMatched":263.3703784185025
            },
            {
                "Name":"No",
                "VisDelay":0,
                "RedA":0,
                "VolMatched":0
            }
        ],
        "_Type":2,
        "_Period":1,
        "SettlT":0,
        "Comm":0.02,
        "Settler":{
           "1":true,
           "777889":true
        },
        "ComRecip":{
           "1":1
        },
        "MinVal":0,
        "MaxVal":0,
        "Cur":0,
        "CurB":0,
        "LastCh":"2018-09-17T20:00:48.1019114Z",
        "LastSoftCh":"2018-09-17T20:05:17.9277257Z",
        "LogBugs":"",
        "OrdBStr":"{\"Bids\":[],\"Asks\":[[1.365,49.2173949315],[1.597,19.94164]],\"S\":1}~"
        "Pop":0,
        "Margin":10000,
        "ID":109353571206
    }
    

    Object that hold a market data structure:

    Orderbook

    [
        { 
            "Bids": [ [3.954, 3.75] ],
            "Asks": [ [7.203, 2.06156] ],
            "S": 1 
        }, {
            "Bids": [ [5.627,2.63] ],
            "Asks": [],
            "S": 1
        }
    ]
    

    An array of objects that hold orders for each runner in market with the following structure:

    Market Category

        MARKET_CATEGORY = {
            1: 'Soccer',
            2: 'Tenis',
            3: 'Golf',
            4: 'Cricket',
            5: 'RugbyUnion',
            6: 'Boxing',
            7: 'Horse Racing',
            8: 'Motorsport',
            10: 'Special',
            11: 'Rugby League',
            12: 'Bascketball',
            13: 'American Football',
            14: 'Baseball',
            15: 'Politics',
            16: 'Financial',
            17: 'Greyhound',
            18: 'Volleyball',
            19: 'Handball',
            20: 'Darts',
            21: 'Bandy',
            22: 'Winter Sports',
            24: 'Bowls',
            25: 'Pool',
            26: 'Snooker',
            27: 'Table tennis',
            28: 'Chess',
            30: 'Hockey',
            31: 'Fun',
            32: 'eSports',
            33: 'Inplay',
            34: 'reserved4',
            35: 'Mixed Martial Arts',
            36: 'reserved6',
            37: 'reserved',
            38: 'Cycling',
            39: 'reserved9',
            40: 'Bitcoin',
            42: 'Badminton'
        }
    

    The main categories for diverse market options, use their IDs to filter market by category:

    There's no need to special explanation of each type.

    Types with keyword reserved don't represent real categories for now, but can in the future.

    Market Status

        MARKET_STATUS = {
            0: "ACTIVE",
            1: "INPLAY",
            2: "SUSPENDED",
            3: "CLOSED",
            4: "SETTLED",
            5: "CANCELLED"
        }
    

    Different market status:

    Market Type

        MARKET_TYPE = {
            0: 'MONEYLINE',
            1: 'OVER_UNDER',
            2: 'OUTRIGHT',
            3: 'GAMESPREAD',
            4: 'SETSPREAD',
            5: 'CORRECT_SCORE',
            6: 'FUTURE',
            7: 'BASICPREDICTION',
            8: 'RESERVED2',
            9: 'RESERVED3',
            10: 'RESERVED4',
            11: 'RESERVED5',
            12: 'RESERVED6'
    
        }
    

    Different types of market rules settlement:

    Types with keyword reserved don't represent real types for now, but can in the future.

    Market Periods

        MARKET_PERIOD = {
            0: 'UNDEFINED',
            1: 'FT',
            2: 'FIRST_SET',
            3: 'SECOND_SET',
            4: 'THIRD_SET',
            5: 'FOURTH_SET',
            6: 'FIFTH_SET',
            7: 'FIRST_HALF',
            8: 'SECOND_HALF',
            9: 'FIRST_QUARTER',
            10: 'SECOND_QUARTER',
            11: 'THIRD_QUARTER',
            12: 'FOURTH_QUARTER',
            13: 'FIRST_PERIOD',
            14: 'SECOND_PERIOD',
            15: 'THIRD_PERIOD',
        }
    

    Mostly used by sports markets, define if the market is related to a specific fraction of the match:

    Market Settlements

        MARKET_SETTLEMENT = {
            0: 'BINARY',
            1: 'CFD',
            2: 'CFDI',
            3: 'EXCHANGE'
        }
    

    Different types of markets settlement:

    Currency Types

        CURRENCY_TYPE = {
            0: 'mBTC',
            1: 'mETH',
            2: 'mLTC',
            3: 'mDash',
            4: 'mBCH'
        }
    

    Different types of currencies accepted:

    Matched order state

        MATCHED_ORDER_STATE = {
            0: 'MATCHED',
            1: 'RUNNER_WON',
            2: 'RUNNER_HALFWON',
            3: 'RUNNER_LOST',
            4: 'RUNNER_HALFLOST',
            5: 'MAKERVOIDED',
            6: 'VOIDED',
            7: 'PENDING',
            8: 'DECIMAL_RESULT'
        }
    

    States of an order could have during its lifetime:

    Unmatched Order Object

    {
        "Price":1.04,
        "RemAmount":0.05,
        "State":0,
        "BidOrAsk":0,
        "PrivAmount":0.05,
        "PrivSubUser":"balanceorder",
        "PrivCancelAt":3155378975999999999,
        "makerCT":0,
        "_Type":0,
        "PrivID":633728772777882209,
        "PrivUserID":1132152
    }    
    

    A object that represent a unmatched order:

    Matched Order Object

    {
        "Price":1.04,
        "Amount":0.02,
        "Red":0,
        "DecResult":0,
        "R":0,
        "ID":"636729682302455151",
        "State":0,
        "MakerCancelTime":0
    } 
    

    An object representing matching data, with the following structure:

    Unmatched Order State

        UNMATCHED_ORDER_STATE = {
            0: 'ACTIVE',
            1: 'CANCELLED',
            2: 'MATCHED',
            3: 'MATCHEDANDCANCELLED'
        }
    

    States of unmatched order could have during its lifetime:

    User Order Object

    {
        "BidOrAsk":0,
        "MarketID":148678778313,
        "RunnerID":1,
        "OrderID":"636728772330883209",
        "MatchedSubUser":null
    }
    

    Is an object with:

    Order type

        ORDER_TYPE = {
            0: 'MAKERTAKER',
            1: 'MAKER',
            2: 'TAKER'
        }
    

    Different types of order that is created:

    Public API Introduction

    This is a free service to scrape all markets on Fairlay. For all POST requests (creating/changing markets and orders) use the paid Private API.

    For more examples how this API should be used together with our paid API, please take a look at our sample clients in C# and Python.

    Please feel free to comment and make suggestions.

    Free Servers

    http://31.172.83.181:8080

    used by default for all Public API calls

    http://31.172.83.53:8080

    (is an alternate server with the same functionality, also used for all Private API calls)

    For examples on how to use each of the API calls presented here, see the C# Unit Tests.

    In all of the examples below you can call /free/(method) calls with /free0/ up to /free9/ to increase the given limits above, a simple way is to either rotate from 1 to 9 or just randomize the free call from 1 to 9.

    Server Time

    Call:

    http://31.172.83.181:8080/free/time
    

    Response:

    636728043453486318
    

    Returns the server time in ticks.

    Note: You can do the same in the Private API via getservertime

    Markets

    Returns JSON encoded list of markets that apply to the given filter.

    Call:

    http://31.172.83.181:8080/free/markets/JSON-ENCODED-MARKETFILTER
    

    Examples:

    Returns the first 100 non-empty soccer markets, where one of the runners is Portugal, the Title does not contain the words "Corners" or "Throwin" and the period of the match is full-time.

    http://31.172.83.181:8080/free/markets/{"Cat":1,"NoZombie":true,"RunnerAND":["Portugal"], "TitleNOT":["Corners","Throwin"], "PeriodOR":[1],"FromID":0,"ToID":100}
    

    Returns all active tennis matches of the type Over/Under or Outright where the odds or market data have changed after June 1st 12:01:30pm.

    http://31.172.83.181:8080/free/markets/{"Cat":2,"TypeOr":[1,2],"SoftChangedAfter":"2016-06-01T12:01:30","OnlyActive":true,"ToID":10000}
    

    Returns all active non-empty markets.

    http://31.172.83.181:8080/free/markets/{"OnlyActive":true,"NoZombie":true,"ToID":100000}
    

    Competitions

    Call: http://31.172.83.181:8080/free/comps/CATEGORYID Example for all soccer competitions:

    http://31.172.83.181:8080/free/comps/1
    

    Returns all competitions in the selected category. See Categories

    API Libraries & Source Code