이 고급 문법을 사용하면 검색어를 사용하여 발신자, 날짜, 라벨과 같은 속성별로 메일을 필터링할 수 있습니다. 예를 들어 다음 쿼리는 2014년 1월에 사용자가 보낸 모든 메시지를 검색합니다.
GET https://www.googleapis.com/gmail/v1/users/me/messages?q=in:sent after:2014/01/01 before:2014/02/01
검색어 외에도 labelIds 매개변수를 사용하여 라벨로 메시지와 대화목록을 필터링할 수도 있습니다. 이렇게 하면 지정된 시스템 또는 사용자 라벨이 적용된 메시지와 대화목록을 검색할 수 있습니다. 자세한 내용은 messages.list 또는 threads.list 메서드 참조를 참고하세요.
검색 및 필터링 차이: Gmail UI와 Gmail API
Gmail UI는 Google Workspace 계정에서 계정 별칭을 추론할 수 있는 별칭 확장을 실행합니다. 예를 들어 myprimary@mycompany.net 계정이 있고 관리자가 이 계정의 별칭을 myalias@mycompany.net로 설정했다고 가정해 보겠습니다. myalias@mycompany.net에서 이메일을 보내지만 'from: myprimary@mycompany.net)'를 검색하면 myalias@mycompany.net에서 보낸 이메일이 Gmail UI의 검색 결과로 표시되지만 API 응답에는 표시되지 않습니다.
Gmail UI에서는 사용자가 대화목록 전체 검색을 실행할 수 있지만 API는 이를 지원하지 않습니다.
[null,null,["최종 업데이트: 2024-11-23(UTC)"],[[["The Gmail API provides methods (`messages.list` and `threads.list`) to search and filter emails using the `q` parameter, supporting advanced search syntax similar to the Gmail web interface."],["You can construct search queries to filter emails by attributes like sender, date, or label, with a caveat that dates are interpreted as PST midnight unless specified in seconds."],["Filtering can also be done by label using the `labelIds` parameter, allowing searches for messages with specific system or user labels."],["While the Gmail UI automatically expands aliases in searches, the API does not, meaning searches must use the exact email address."],["Thread-wide searches are supported in the Gmail UI but are not available through the API."]]],[]]