read.md•2.34 kB
### Search messages
`/messages/search` → [`GET /v3/grants/<NYLAS_GRANT_ID>/messages` request](https://developer.nylas.com/docs/api/v3/ecc/#get-/v3/grants/-grant_id-/messages)
```Node
import 'dotenv/config'
import Nylas from 'nylas'
const NylasConfig = {
apiKey: process.env.NYLAS_API_KEY,
apiUri: process.env.NYLAS_API_URI,
}
const nylas = new Nylas(NylasConfig)
async function searchInbox() {
try {
const result = await nylas.messages.list({
identifier: process.env.NYLAS_GRANT_ID,
queryParams: {
search_query_native: 'nylas',
limit: 5
}
})
console.log('search results:', result)
} catch (error) {
console.error('Error to complete search:', error)
}
}
searchInbox()
```
```Java
```
```Python
from dotenv import load_dotenv
load_dotenv()
import os
import sys
from nylas import Client
nylas = Client(
os.environ.get('NYLAS_API_KEY'),
os.environ.get('NYLAS_API_URI')
)
grant_id = os.environ.get("NYLAS_GRANT_ID")
messages = nylas.messages.list(
grant_id,
query_params={
"limit": 5,
"search_query_native": 'nylas'
}
)
print(messages)
```
```Ruby
```
```API
```
### Search threads
`/threads/search` → [`GET /v3/grants/<NYLAS_GRANT_ID>/threads` request](https://developer.nylas.com/docs/api/v3/ecc/#get-/v3/grants/-grant_id-/threads)
```Node
import 'dotenv/config'
import Nylas from 'nylas'
const NylasConfig = {
apiKey: process.env.NYLAS_API_KEY,
apiUri: process.env.NYLAS_API_URI,
}
const nylas = new Nylas(NylasConfig)
async function searchInbox() {
try {
const result = await nylas.threads.list({
identifier: process.env.NYLAS_GRANT_ID,
queryParams: {
search_query_native: 'nylas',
limit: 5
}
})
console.log('search results:', result)
} catch (error) {
console.error('Error to complete search:', error)
}
}
searchInbox()
```
```Java
```
```Python
from dotenv import load_dotenv
load_dotenv()
import os
import sys
from nylas import Client
nylas = Client(
os.environ.get('NYLAS_API_KEY'),
os.environ.get('NYLAS_API_URI')
)
grant_id = os.environ.get("NYLAS_GRANT_ID")
messages = nylas.threads.list(
grant_id,
query_params={
"limit": 5,
"search_query_native": 'nylas'
}
)
print(messages)
```
```Ruby
```
```API
```