Quotes order

When i use
response=requests.get(“https://api.smarkets.com/v3/markets/"+list+"/quotes/”,headers=headers)
where list is a list of marketids the results come out in a different order to the numbers in the “list”
Is there a way of controlling the order the results come in?
Am I correct in assuming this list in the same order as the actual values of the marketids?

Thanks

Hey Michael,

Am I correct in assuming this list in the same order as the actual values of the marketids?

That’s right

Thanks, though I am now unsure that is correct - it seems to actually be returned in the same order as the selection ids
For example
https://api.smarkets.com/v3/markets/9629079/quotes/
returns
{
“33571931”: {
“bids”: [
{
“price”: 4386,
“quantity”: 862577
},
{
“price”: 4348,
“quantity”: 642344
},
{
“price”: 4310,
“quantity”: 870049
},
{
“price”: 4274,
“quantity”: 2248252
},
{
“price”: 4237,
“quantity”: 2242493
}
],
“offers”: [
{
“price”: 4464,
“quantity”: 689919
},
{
“price”: 4505,
“quantity”: 1079961
},
{
“price”: 4545,
“quantity”: 47280
},
{
“price”: 4587,
“quantity”: 47031
},
{
“price”: 4854,
“quantity”: 945219
}
]
},
“33571933”: {
“bids”: [
{
“price”: 2667,
“quantity”: 270006
},
{
“price”: 2632,
“quantity”: 1501839
},
{
“price”: 2597,
“quantity”: 1163109
},
{
“price”: 2564,
“quantity”: 180017
},
{
“price”: 2532,
“quantity”: 178985
}
],
“offers”: [
{
“price”: 2703,
“quantity”: 6999260
},
{
“price”: 2740,
“quantity”: 2968089
},
{
“price”: 2778,
“quantity”: 1206776
},
{
“price”: 2817,
“quantity”: 321168
},
{
“price”: 2857,
“quantity”: 320769
}
]
},
“33571935”: {
“bids”: [
{
“price”: 2899,
“quantity”: 73140
},
{
“price”: 2857,
“quantity”: 989329
},
{
“price”: 2817,
“quantity”: 201546
},
{
“price”: 2778,
“quantity”: 1219358
},
{
“price”: 2740,
“quantity”: 203544
}
],
“offers”: [
{
“price”: 2985,
“quantity”: 2398140
},
{
“price”: 3030,
“quantity”: 2470821
},
{
“price”: 3077,
“quantity”: 1811714
},
{
“price”: 3279,
“quantity”: 1016231
}
]
}
}

But when I call it with a list of other market ids, I get 33571932 data between 33571931 and 33571933 because the selections in this market have gaps.
I don’t know how to get around this problem unless I call each market individually which takes too long.

Any suggestions?

Sorry for the confusion. It should be actually be sorted by contract_id . What you can do is sort it by fetching contract ids per market id in the client-side:

https://docs.smarkets.com/#/contracts/get_contracts_by_market_ids

We’ll get a sort_by param added in the future. It should make things a lot easier.