GET $orderby
The $orderby system query option allows clients to request resources in a particular order.
GET http://host/odata/Positions?$orderby=Quantity asc, MarketValue desc
Related entities may be ordered by specifying $orderby within the $expand clause.
GET http://host/odata/Accounts?$expand=Positions($orderby=Quantity asc, MarketValue desc)
$count may be used within a $orderby expression to order the returned items according to the exact count of related entities or items within a collection-valued property.
GET http://host/service/Accounts?$orderby=Positions/$count
Example Code
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySW5mbyI6IntcIklkXCI6OTgxLFwiSWRlbnRpdHlJZFwiOlwiNjMyMzhhZTQtMzAyMC00NWI5LWEwODktOTE2ZTY4MDMyZTY3XCIsXCJVc2VyTmFtZVwiOlwiMF9URVNUX0NMSUVOVFwiLFwiRW1haWxcIjpcInRlc3RjbGllbnRAd2VhbHRodGVjaHMuY29tXCIsXCJGaXJzdE5hbWVcIjpcIlRlc3RcIixcIkxhc3ROYW1lXCI6XCJDbGllbnRcIixcIklzQ2xpZW50VXNlclwiOmZhbHNlfSIsIm5iZiI6MTY5NDcwMjU3OSwiZXhwIjoxOTI0OTIzNjAwLCJpc3MiOiJXZWFsdGhUZWNocyIsImF1ZCI6IkFQSVVzZXJzIn0.bNcP0ouNwtFoxrI7pYXw0WKiw0TN6w_R2-Ban5moo1A");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.wealthtechs.com/v2/odata/Accounts?$orderby=AccountType desc&$top=5", requestOptions)
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Example Response
{
"@odata.context": "https://api.wealthtechs.com/v2/odata/$metadata#Accounts",
"value": [
{
"Id": 12,
"CustodianId": 0,
"CustomerId": 0,
"Number": "X72843476R",
"Master": "123456789",
"Name": "Test Account Name",
"AccountStatus": "Test Account Status",
"AccountType": "Test Account Type",
"PrimaryContact": "Test Primary Contact",
"MailingAddress": "Test Mail Address",
"MailingCity": "Test Mail City",
"MailingState": "Test Mail State",
"MailingCountry": "Test Mail Country",
"MailingZipCode": "Test Mail Zip Code",
"Email": "email@email.com",
"Phone": "xxx-xxx-xxxx",
"BussinesPhone": "xxx-xxx-xxxx",
"DateOpened": "2023-01-01T00:00:00-05:00",
"CurrencyId": null
},
{
"Id": 13,
"CustodianId": 0,
"CustomerId": 0,
"Number": "Y41213443S",
"Master": "123456789",
"Name": "Test Account Name",
"AccountStatus": "Test Account Status",
"AccountType": "Test Account Type",
"PrimaryContact": null,
"MailingAddress": "Test Mail Address",
"MailingCity": "Test Mail City",
"MailingState": "Test Mail State",
"MailingCountry": "Test Mail Country",
"MailingZipCode": "Test Mail Zip Code",
"Email": null,
"Phone": "xxx-xxx-xxxx",
"BussinesPhone": "xxx-xxx-xxxx",
"DateOpened": "2023-01-01T00:00:00-05:00",
"CurrencyId": null
},
{
"Id": 14,
"CustodianId": 0,
"CustomerId": 0,
"Number": "Z68397130T",
"Master": "123456789",
"Name": "Test Account Name",
"AccountStatus": "Test Account Status",
"AccountType": "Test Account Type",
"PrimaryContact": "Test Primary Contact",
"MailingAddress": "Test Mail Address",
"MailingCity": "Test Mail City",
"MailingState": "Test Mail State",
"MailingCountry": "Test Mail Country",
"MailingZipCode": "Test Mail Zip Code",
"Email": "email@email.com",
"Phone": "xxx-xxx-xxxx",
"BussinesPhone": "xxx-xxx-xxxx",
"DateOpened": "2023-01-01T00:00:00-05:00",
"CurrencyId": null
}
]
}
Learn how to get access to our API V2.0 by clicking here.
You can copy and use our API v2.0 Example Token to get familiar with our API OData Resources.