The official Python SDK for Nylas β the infrastructure that powers communications
π SDK Guide Β· π API Reference Β· π Sign up Β· π‘ Samples Β· π¬ Forum
The official Python SDK for Nylas β the infrastructure that powers communications. Integrate with Gmail, Microsoft, IMAP, Zoom, and 250+ email, calendar, and meeting providers in 5 minutes. Covers Email, Calendar, Contacts, Scheduler, Notetaker, and Agent Accounts.
This repository is for contributors and anyone installing the SDK from source. If you just want to use the SDK in your app, head straight to the Python SDK guide on developer.nylas.com.
- Sign up for a free Nylas account and grab your API key from the Nylas Dashboard.
- Read the Getting started guide for the core concepts (applications, grants, API keys).
- Install the SDK and make your first request β see below.
You can also bootstrap from the terminal:
brew install nylas/nylas-cli/nylas
nylas initMore options in the CLI getting-started guide.
Requirements: Python 3.8 or later.
pip install nylasTo install from source:
git clone https://github.com/nylas/nylas-python.git
cd nylas-python
pip install -e .Tested on CPython 3.8+. Runs on standard servers as well as serverless platforms like AWS Lambda, Google Cloud Functions, and Vercel β install nylas like any other dependency in your deployment package.
You access Nylas resources (messages, calendars, events, contacts, β¦) through an instance of Client. Initialize it with your API key β and optionally an api_uri matching your data residency.
import os
from nylas import Client
nylas = Client(
api_key=os.environ["NYLAS_API_KEY"],
api_uri=os.environ.get("NYLAS_API_URI", "https://api.us.nylas.com"),
timeout=30, # optional, in seconds
)Once initialized, use it to make requests against a grant (an authenticated end-user account):
calendars, request_id, next_cursor = nylas.calendars.list(
identifier=os.environ["NYLAS_GRANT_ID"],
)
print(calendars)Resources expose a consistent CRUD surface β create(), find(), list(), update(), destroy() β plus resource-specific methods (e.g. messages.send(), events.send_rsvp()). Request and response models are dataclasses-json dataclasses, so every payload is fully type-hinted and supports to_dict() / from_dict().
The SDK raises typed exceptions you can catch and inspect. Every API error carries a request_id and status_code β include both when filing a support ticket so we can trace the request end-to-end.
from nylas import Client
from nylas.models.errors import (
NylasApiError,
NylasOAuthError,
NylasSdkTimeoutError,
)
try:
nylas.calendars.list(identifier=grant_id)
except NylasApiError as err:
print(err.status_code, err.type, str(err), err.request_id)
except NylasOAuthError as err:
print(err.error, err.error_code, err.error_description)
except NylasSdkTimeoutError as err:
print("Timed out:", err.url, err.timeout)Step-by-step walkthroughs in the SDK guide:
- Send messages
- Read messages and threads
- Manage events on a calendar
- Manage contacts
- Manage folders and labels
To inspect the raw HTTP traffic the SDK sends, turn on requests-level logging:
import logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger("urllib3").setLevel(logging.DEBUG)Runnable examples live in examples/ β including send email, inline attachments, folders, import events, Notetaker API, Notetaker calendar, message fields, metadata fields, provider errors, response headers, select parameter, special characters, hidden folders, and plain text.
For full sample apps and product quickstarts, browse nylas-samples on GitHub β every official SDK has Email, Calendar, Contacts, Scheduler, and Webhooks quickstarts.
nylas/skills drops Nylas into Claude Code, Cursor, Codex, and other agents that support the skills format:
npx skills add nylas/skills
/plugin marketplace add nylas/skills # Claude CodeThe CLI also installs an MCP server for Claude Desktop, Claude Code, Cursor, Windsurf, or VS Code:
brew install nylas/nylas-cli/nylas
nylas mcp installWalkthrough: give AI agents email access via MCP.
- SDK guide: developer.nylas.com/docs/v3/sdks/python
- API reference: developer.nylas.com/docs/api/v3
- Python SDK reference: nylas-python-sdk-reference.pages.dev β generated method/class docs for this SDK
- Webhooks (notifications): developer.nylas.com/docs/v3/notifications
- Auth flows: developer.nylas.com/docs/v3/auth
- Dev guide & best practices: developer.nylas.com/docs/dev-guide
- Changelog: CHANGELOG.md
See CHANGELOG.md for per-release notes. Older upgrade guidance (v5.x β v6.x) lives in UPGRADE.md.
Issues, ideas, and pull requests welcome β see Contributing.md. Before opening a large change, please open an issue or post in the forum so we can sanity-check the direction.
Found a vulnerability? Please don't open a public issue. Report it through our Vulnerability Disclosure Policy.
- nylas-nodejs Β·
npm install nylas - nylas-ruby Β·
gem install nylas - nylas-java Β· Maven / Gradle (Kotlin too)
MIT β see LICENSE.