{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-products/nowinfinity/resources/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Querying with OData"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"querying-with-odata","__idx":0},"children":["Querying with OData"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Collection endpoints in the Partner API support ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.odata.org/getting-started/understand-odata-in-6-steps/"},"children":["OData"]}," query options. Rather than retrieving everything and filtering in your own code, you can ask the API for exactly the records and fields you want."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This matters for more than convenience: filtering server-side keeps responses small, reduces the number of calls you make, and avoids pulling data you have no use for."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"supported-query-options","__idx":1},"children":["Supported query options"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Option"},"children":["Option"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$filter"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Returns only records matching a condition."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$select"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Returns only the properties you name."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$orderby"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Sorts the results."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$top"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Returns only the first ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["n"]}," results."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$skip"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Skips the first ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["n"]}," results."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$count"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Includes a count of matching results in the response."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$expand"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Expands related entities inline."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Combine them with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["&"]},", as ordinary query string parameters."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"filtering","__idx":2},"children":["Filtering"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$filter"]}," takes a Boolean expression using these operators:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Operator"},"children":["Operator"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Meaning"},"children":["Meaning"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eq"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Equal"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ne"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Not equal"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["gt"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Greater than"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ge"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Greater than or equal"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["lt"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Less than"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["le"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Less than or equal"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["and"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Both conditions"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["or"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Either condition"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Documents created after 1 January 2023:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"GET /v1/documents?$filter=CreatedOn gt 2023-01-01T00:00:00.000Z\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Companies registered before a date:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"GET /v1/companies?$filter=DateRegistered le 2023-01-01T00:00:00.000Z\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Dates are UTC and use ISO 8601 format."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["?"]}," before the first query option is required. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/v1/documents$filter=..."]}," is not a valid URL and will not filter anything."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"paging","__idx":3},"children":["Paging"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$top"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$skip"]}," together to page through a large collection:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"GET /v1/documents?$top=50\nGET /v1/documents?$top=50&$skip=50\nGET /v1/documents?$top=50&$skip=100\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pair paging with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$orderby"]}," so the ordering is stable between requests. Without it, records can appear on two pages or none."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"GET /v1/documents?$orderby=CreatedOn&$top=50&$skip=50\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"sorting","__idx":4},"children":["Sorting"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"GET /v1/documents?$orderby=CreatedOn desc\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["asc"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["desc"]},"; ascending is the default."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"selecting-fields","__idx":5},"children":["Selecting fields"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Return only what you need:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"GET /v1/companies?$select=CompanyId,Name,ACN\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"combining-options","__idx":6},"children":["Combining options"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ten most recently created documents, newest first, with only a few fields:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"GET /v1/documents?$filter=CreatedOn gt 2024-01-01T00:00:00.000Z&$orderby=CreatedOn desc&$top=10&$select=DocumentId,DocumentName,CreatedOn\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"url-encoding","__idx":7},"children":["URL encoding"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Query values containing spaces, colons or other reserved characters must be percent-encoded. Most HTTP libraries do this for you if you pass query parameters as values rather than building the URL by hand — which is the safer approach with OData, since filter expressions contain spaces by design."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"practical-guidance","__idx":8},"children":["Practical guidance"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Filter by date on scheduled jobs."]}," If you poll for new records, filter on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CreatedOn"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["LastModifiedOn"]}," since your last run rather than retrieving everything and comparing locally."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Page rather than requesting everything."]}," Large unbounded collections are slow for you and expensive for us."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$select"]}," when you only need a few fields."]}," Some models are large."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"related","__idx":9},"children":["Related"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/nowinfinity/resources/api-structure"},"children":["API structure"]}," — endpoints and response formats."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/nowinfinity/resources/child-accounts"},"children":["Accessing child accounts"]}," — scoping queries to a child account."]}]}]},"headings":[{"value":"Querying with OData","id":"querying-with-odata","depth":1},{"value":"Supported query options","id":"supported-query-options","depth":2},{"value":"Filtering","id":"filtering","depth":2},{"value":"Paging","id":"paging","depth":2},{"value":"Sorting","id":"sorting","depth":2},{"value":"Selecting fields","id":"selecting-fields","depth":2},{"value":"Combining options","id":"combining-options","depth":2},{"value":"URL encoding","id":"url-encoding","depth":2},{"value":"Practical guidance","id":"practical-guidance","depth":2},{"value":"Related","id":"related","depth":2}],"frontmatter":{"title":"Querying with OData","description":"Filter, sort and page collection endpoints using OData query options.","seo":{"title":"Querying with OData"}},"lastModified":"2026-09-03T05:27:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/nowinfinity/resources/querying-with-odata","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}