GET $filter
The $filter system query option allows clients to filter a collection of resources that are addressed by a request URL. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Resources for which the expression evaluates to false or to null, or which reference properties that are unavailable due to permissions, are omitted from the response. You can find details on filter specification in the OData spec filter options section.
Examples:
- All accounts with a Name equal to ‘Geralt’:
http://host/odata/Accounts?$filter=Name eq 'Geralt'
- All accounts with a Name not equal to ‘Geralt’ :
http://host/odata/Accounts?$filter=Name ne 'Geralt'
- All accounts with a Name greater than ‘Geralt’:
http://host/odata/Accounts?$filter=Name gt 'Geralt'
- All accounts with a Name greater than or equal to ‘Geralt’:
http://host/odata/Accounts?$filter=Name ge 'Geralt'
- All products with a Name less than ‘Geralt’:
http://host/odata/Accounts?$filter=Name lt 'Geralt'
- All accounts with a Name less than or equal to ‘Geralt’:
http://host/odata/Accounts?$filter=Name le 'Geralt'
- All accounts with the Name ‘Geralt’ that also have a Price less than 2.55:
http://host/odata/Accounts?$filter=Name eq 'Geralt' and Price lt 2.55
- All accounts that either have the Name ‘Geralt’ or have a Price less than 2.55:
http://host/odata/Accounts?$filter=Name eq 'Geralt' or Price lt 2.55
- All prodaccounts ucts that do not have a Name that ends with ‘alt’:
http://host/odata/Accounts?$filter=not endswith(Name,'alt')
- All accounts whose style value includes Yellow:
http://host/service/Accounts?$filter=style has Sales.Pattern'Yellow'
- All accounts whose name value is βGeraltβ or βRiviaβ:
http://host/odata/Accounts?$filter=Name in ('Geralt', 'Rivia')
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?$filter=startswith(Number, 'Z')", 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": 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.