You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This example demonstrates the usage of the `select` query parameter across different Nylas resources. The `select` parameter allows you to specify which fields you want to receive in the API response, helping to optimize your API calls by reducing the amount of data transferred.
4
+
5
+
## Features Demonstrated
6
+
7
+
1.**Backwards Compatibility**: Shows that existing code that doesn't use the `select` parameter continues to work as expected, receiving all fields.
8
+
2.**Field Selection**: Demonstrates how to use the `select` parameter to request only specific fields for better performance.
9
+
3.**Multiple Resources**: Shows the `select` parameter working across different resources:
10
+
- Messages
11
+
- Calendars
12
+
- Events
13
+
- Drafts
14
+
- Contacts
15
+
16
+
## Setup
17
+
18
+
1. Create a `.env` file in the root directory with your Nylas API credentials:
19
+
```
20
+
NYLAS_API_KEY=your_api_key_here
21
+
```
22
+
23
+
2. Install the required dependencies:
24
+
```bash
25
+
pip install nylas python-dotenv
26
+
```
27
+
28
+
## Running the Example
29
+
30
+
Run the example script:
31
+
```bash
32
+
python select_param_example.py
33
+
```
34
+
35
+
The script will demonstrate both the traditional way of fetching all fields and the new selective field fetching for each resource type.
36
+
37
+
## Example Output
38
+
39
+
The script will show output similar to this for each resource:
40
+
```
41
+
=== Messages Resource ===
42
+
43
+
Fetching messages (all fields):
44
+
Full message - Subject: Example Subject, ID: abc123...
45
+
46
+
Fetching messages with select (only id and subject):
47
+
Minimal message - Subject: Example Subject, ID: abc123...
48
+
```
49
+
50
+
## Benefits of Using Select
51
+
52
+
1.**Reduced Data Transfer**: By selecting only the fields you need, you reduce the amount of data transferred over the network.
53
+
2.**Improved Performance**: Smaller payloads mean faster API responses and less processing time.
54
+
3.**Bandwidth Optimization**: Especially useful in mobile applications or when dealing with limited bandwidth.
55
+
56
+
## Available Fields
57
+
58
+
The fields available for selection vary by resource type. Refer to the [Nylas API documentation](https://developer.nylas.com/) for a complete list of available fields for each resource type.
0 commit comments