Git Product home page Git Product logo

api-ng-sample-code's Introduction

Betfair API-NG Code Samples

This github respository contains sample code in various languages to help customers get started with writing betfair API-NG clients. For more information about API-NG please see Getting started with API-NG documentation and developer.betfair.com.

Please note, these are not intended to be fully fledged clients and all follow an identical set of scenarios. As a result, we do not wish to extend the samples with pull requests that extend only a single language sample or add functionality not in the below scenarios.

Each of the basic language samples demonstrates a basic use case of placing a bet on the next GB Horse Racing market:

  • Find the next UK Horse Racing Win market
  • Get prices for the market
  • Place a bet on the market
  • Handle the error returned by the API when the bet fails as it is below the minimum stake size.

For the sake of simplictity and ease of understanding, these samples are not intended to show best practice for optimisations for speed or throughput.

A comprehensive description of the samples can be found in the developer samples documentation.

There is also a limited sample of login examples within the loginCode subdirectory and an Android sample app in the android subdirectory.

The sample code is not intended to be used as-is in a production environment and carries no assurances or guarantees.

api-ng-sample-code's People

Contributors

aquenneville avatar bfapi avatar dimitrisli avatar doowad avatar efcdom avatar hkraskian avatar jamiei avatar keithmg avatar mdoulaty avatar ntziolis avatar pacher avatar rdancer avatar stottpaul avatar tombart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-ng-sample-code's Issues

Runner.getEX() returns null

-----------------With these Projections --------------------------
OrderProjection orderProjection = null;
MatchProjection matchProjection = null;
String currencyCode = null;

PriceProjection priceProjection = new PriceProjection();
Set priceData = new HashSet();
priceData.add(PriceData.EX_BEST_OFFERS);
priceProjection.setPriceData(priceData);
priceProjection.setVirtualise(true);

ExBestOfferOverRides exbest = new ExBestOfferOverRides() ;
exbest.setBestPricesDepth(1) ;
exbest.setRollupModel(RollupModel.STAKE);
priceProjection.setExBestOfferOverRides(exbest);


1- Get a list of MarketBooks
List marketBookReturn = jsonOperations.listMarketBook(marketIds, priceProjection,orderProjection, matchProjection, currencyCode,applicationKey, sessionToken);

2- Get a specific market book from list
MarketBook mb = marketBookReturn.get(0);

3- Get runners of marketBook
List runners = mb.getRunners();

4- for each runner get some information
for (Runner runner : runners) {
System.out.println(runner.getSelectionId()) ; //gives correct answer
System.out.println("Last price traded: " + runner.getLastPriceTraded()) ; // this is also ok

System.out.println("Ex. price: " + runner.getEx()) ; //but this one returns null}

Can't login with SampleAPI

I can't seem to login with SampleAPI-app.

My APPKEY seems to be working as I can paste it into ordinary browser and login and then I get logged in and redirected to ordinary betfair-site.

But when I do the same in SampleAPI it just freezes no matter how long I let it run.

What could be wrong?

Noninteractive login sample not work

Hi
I have been struggling to achieve Noninteractive login to Betfair.
I'm using C# and on Windows 10.

So I think everything is done in right order but it keeps saying internal error.
2018-12-03_04h05_33

Could anyone help me?

How to get odds for a particular 'marketId ' ? I do not find any documentation for this

I am using this code snippet to get details about a markerId , but how do i get odds?
I did not find any example code or documentation showing how t achieve this ?

$params = '{"filter": { "MarketBettingType" : "FIXED_ODDS" },
"marketIds" : ["1.112791434" , "1.112791488"],
"priceProjection":{"priceData": ["EX_BEST_OFFERS"]}}';

    $operation = 'listMarketBook';

    $jsonResponse = $this->sportsApingRequest($appKey, $sessionToken, $operation, $params); 

Not able to login

I'm not able to type my id and password webview not getting my touch

getMarketBookBestOffers() returns empty results

I am trying to gather data from the spanish exchange. I am following the documentation regarding the spanish exchange http://docs.developer.betfair.com/docs/display/1smk3cen4v3lu3yomq5qye0ni/Betting+on+Spanish+Exchange

Using your python3 library I get the following results:

getEventTypes() -> [{'eventType': {'id': '1', 'name': 'Soccer'}, 'marketCount': 488}, {'eventType': {'id': '2', 'name': 'Tennis'}, 'marketCount': 96}, {'eventType': {'id': '7522', 'name': 'Basketball'}, 'marketCount': 7}]

However when calling getMarketBookBestOffers() I get empty results for any of the availible IDs, for example I get:

getMarketBookBestOffers('1') -> []

I would like to know if these results are normal (both for the getEventTypes() and getMarketBookBestOffers(id) because of jurisdiction limitations (spanish) of if there is something else to it. Thanks.

MarketOnCloseOrder place bet exception

Api_ng_sample_code.TO.MarketOnCloseOrder.Size should be updated as
Api_ng_sample_code.TO.MarketOnCloseOrder.Liability. Otherwise bet can't be placed and no valid error msg as well. I figured out this by comparing properties with betfair documentation.

All responses are null

Have anything changed during the summer?
None of my projects from jun are getting any data back from the service. (Response come back null)

I even tested with the sample code without any modifications and still get stuck at "listEventTypes".

Exception: Object reference not set to an instance of an object.

(I have changed my sessionsToken ofc, tested with both delayed and normal)

System.Net.ProtocolViolationException

This app was working fine for me until a few weeks (?) ago it stopped working. Happens in networkClient.Invoke method called in ListMarketCatalogue(). I have tried to step through but cant suss it out. I havent changed any code, I dont understand why it stopped working.

System.Net.ProtocolViolationException: You must write ContentLength bytes to the request stream before calling [Begin]GetResponse.
at System.Net.HttpWebRequest.BeginGetResponse(AsyncCallback callback, Object state)
at System.Threading.Tasks.TaskFactory1.FromAsyncImpl(Func3 beginMethod, Func2 endFunction, Action1 endAction, Object state, TaskCreationOptions creationOptions)
at BetfairNG.Network.<>c__DisplayClass8.b__5(Task1 stream) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result()
at BetfairNG.Network.<>c__DisplayClass21.<Invoke>b__1(Task1 c)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.Tasks.Task.Execute() ---> (Inner Exception #0) System.Net.ProtocolViolationException: You must write ContentLength bytes to the request stream before calling [Begin]GetResponse. at System.Net.HttpWebRequest.BeginGetResponse(AsyncCallback callback, Object state) at System.Threading.Tasks.TaskFactory1.FromAsyncImpl(Func3 beginMethod, Func2 endFunction, Action1 endAction, Object state, TaskCreationOptions creationOptions) at BetfairNG.Network.<>c__DisplayClass8.<Request>b__5(Task1 stream)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()<---

Unable to get Market Information of each Race.

I am using REST API to get market info of each Race.
I have "marketID" "WIN" also have all the details of each race, I didn't get any proper call to get market info of each race.
I have tried with end point "listMarketCatalogue" and "listMarketBook" but didn't get any luck.

download

There is no download button on this GitHub project?

Empty Result

I'm having problems using the betfair api. Inspired by the JSONRPC Python examples, I always get empty results. Are those examples still valid?

Requesting a login using the documentation guides:

  • Calling login, result:
    {u'status': u'SUCCESS', u'token': u'', u'product': u'<app_key>', u'error': u''}

Using the retrieved token from the successful login, within the header:

  • Calling listEventTypes, result:
    {u'jsonrpc': u'2.0', u'result': [], u'id': 1}

Decimal point in odds

Hello,

I've tested the code and I keep getting odds in row 14 "prices" in the format that excludes the decimal point from the odds, ie odds 2.22 are shown as 222, and 2.20 are shown as 22. What is wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.