Open abdulbarik opened 8 years ago
This is a sample from my code which works. however why it isn't working could be more complex than this. ` private async Task LoadFullCatalogue() { var marketFilter = new MarketFilter();
ISet<string> ids = new HashSet<string>();
ids.Add(_marketId); // the market i want
marketFilter.MarketIds = ids;
ISet<MarketProjection> marketProjections = new HashSet<MarketProjection>();
marketProjections.Add(MarketProjection.RUNNER_METADATA);
marketProjections.Add(MarketProjection.EVENT);
marketProjections.Add(MarketProjection.MARKET_DESCRIPTION);
marketProjections.Add(MarketProjection.COMPETITION);
marketProjections.Add(MarketProjection.EVENT_TYPE);
const string MaxResults = "1";
const MarketSort MarketSort = MarketSort.FIRST_TO_START;
try
{
var marketCatalogues = await JsonRpcClient.Instance.ListMarketCatalogue(marketFilter, marketProjections, MarketSort, MaxResults);
// add marked id to each runner
if (marketCatalogues.Count > 0)
{
MarketCatalogue = marketCatalogues[0];
foreach (var runner in MarketCatalogue.Runners)
{
runner.MarketId = MarketCatalogue.MarketId;
runner.EventDescription = MarketCatalogue.FullDescription;
}
}
}
catch (Exception ex)
{
DialogHelpers.DisplayMessage(ex.Message);
}
}
`
Also the marketProjections specify what data you want. so what exactly do you want?
An example of listMarketBook
` // get the market book
var ids = new List
try
{
StatusMessage = $"Refreshing {MarketCatalogue?.FullDescription}...";
_cancellationTokenSource = new CancellationTokenSource();
var books = await JsonRpcClient.Instance.ListMarketBook(ids, priceProj, OrderProjection.EXECUTABLE, MatchProjection.ROLLED_UP_BY_AVG_PRICE, _cancellationTokenSource);
if (books.Count > 0)
{
MarketBook = books[0];
Runners = new ObservableCollection<Runner>(MarketBook.Runners);
`
I have all events of eventType "7" in my DB, I just want a cronJob in every 15 mins. to get market information of each event of "WIN" type. Here what I tried yet: URL: "https://api-au.betfair.com/exchange/betting/rest/v1.0/listMarketCatalogue/" JSON value: {"filter": { "eventIds": ["26420387"], "marketIds": ["WIN"] }, "sort": "FIRST_TO_START", "maxResults": "100" }
But I am getting empty array every time.
Maybe I am doing something wrong to get this stuff. Please suggest me what I should do to get my task.
Thanks,
"marketIds": ["WIN"] is not correct, it should contain the id of a market.
I think it should be
"marketTypeCodes": [ "WIN", "PLACE" ],
For example ` var marketFilter = new MarketFilter(); var time = new TimeRange(); time.From = DateTime.Now; time.To = DateTime.Now.AddDays(1);
ISet<string> eventypeIds = new HashSet<string>();
eventypeIds.Add(eventType.Id);
marketFilter.EventTypeIds = eventypeIds;
marketFilter.MarketStartTime = time;
//marketFilter.MarketCountries = new HashSet<string>
// {
// "UK"
// };
marketFilter.MarketTypeCodes = new HashSet<string>
{
"WIN"
};
var marketSort = MarketSort.FIRST_TO_START;
var maxResults = "550";
ISet<MarketProjection> marketProjections = new HashSet<MarketProjection>();
marketProjections.Add(MarketProjection.EVENT);
marketProjections.Add(MarketProjection.MARKET_DESCRIPTION);
marketProjections.Add(MarketProjection.MARKET_START_TIME);
try
{
StatusMessage = $"Getting events for {eventType.Name}...";
var marketCatalogues = await JsonRpcClient.Instance.ListMarketCatalogue(marketFilter, marketProjections, marketSort, maxResults);
`
@mgwalm I just updated "key" with "marketTypeCodes", but still getting blank array.
Am I doing anything wrong in my API call?
no, I said you should be using market type codes instead of marketids
what language/environment are you using.
try to mimic my code into whatever you are using.
I am integrating it with REST API. Thanks for your suggestion.
I am also getting a lot of empty lists. Using python's betfairlightweight.
time_ago = timezone.now() - datetime.timedelta(minutes=10)
time_fwd = timezone.now() + datetime.timedelta(minutes=30)
mfilter = market_filter(
event_type_ids=[ET_HORSE_RACING, ET_GREYHOUND_RACING],
market_start_time=time_range(
from_=time_ago.strftime('%Y-%m-%dT%H:%I:%S.000Z'),
to=time_fwd.strftime('%Y-%m-%dT%H:%I:%S.000Z')
)
)
for i in range(10):
res = trading.betting.list_market_catalogue(
mfilter,
market_projection=[
'EVENT',
'MARKET_START_TIME',
'MARKET_DESCRIPTION',
'RUNNER_METADATA',
],
sort='FIRST_TO_START',
max_results=1000,
lightweight=True)
The body is just empty the whole time 😞
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.