Skip to content

Releases: nylas/nylas-python

v5.12.0

Choose a tag to compare

@mrashed-dev mrashed-dev released this 16 Dec 17:31

This release of the Nylas Python SDK brings a single addition.

Release Notes

Added

  • Add support for sending raw MIME messages (#243)

Usage

Sending raw MIME messages

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

raw_mime = """MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Subject: With Love, From Nylas
From: You <example@gmail.com>
To: My Nylas Friend <recipient@gmail.com>

This email was sent via raw MIME using the Nylas email API. Visit https://nylas.com for details.
"""

draft = nylas.drafts.create()

# Send the raw MIME
msg = draft.send_raw(raw_mime)

v5.11.0

Choose a tag to compare

@mrashed-dev mrashed-dev released this 18 Nov 23:15

This release of the Nylas Python SDK brings a few additions.

Release Notes

Added

  • Add support for calendar colors (for Microsoft calendars) (#238)
  • Add support for rate limit errors (#239)
  • Add support for visibility field in Event (#240)

v5.10.2

Choose a tag to compare

@mrashed-dev mrashed-dev released this 11 Oct 21:26

This release of the Nylas Python SDK brings a singular change.

Release Notes

Changed

  • Update package setup to be compatible with PEP 517 (#235)

New Contributors 🎉

v5.10.1

Choose a tag to compare

@mrashed-dev mrashed-dev released this 22 Sep 19:33

This release of the Nylas Python SDK brings a singular fix.

Release Notes

Fixed

  • Fix authentication for integrations (#233)

v5.10.0

Choose a tag to compare

@mrashed-dev mrashed-dev released this 29 Jul 20:48

This release of the Nylas Python SDK brings a few additions.

Release Notes

Added

  • Add metadata field to JobStatus (#227)
  • Add missing hosted authentication parameters (#229)
  • Add support for calendar field in free-busy, availability, and consecutive availability queries (#228)

Using New Features

New calendars field in free-busy/availability queries

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

# Free busy with calendars
start_time = datetime.now()
end_time = datetime.now() + timedelta(hours = 24)
calendars = [{
  "account_id": "test_account_id",
  "calendar_ids": ["example_calendar_a", "example_calendar_b"]
}]

free_busy = nylas.free_busy("your_email@example.com", start_time, end_time, calendars)

# Availability with calendars
emails = ["one@example.com", "two@example.com", "three@example.com"]
start_time = datetime.now()
end_time = datetime.now() + timedelta(hours = 24)
duration = timedelta(minutes=30)
interval = timedelta(hours=1, minutes=30)
calendars = [{
  "account_id": "test_account_id",
  "calendar_ids": ["example_calendar_a", "example_calendar_b"]
}]

api_client.availability(emails, duration, interval, start_at, end_at, calendars=calendars)

# Consecutive availability with calendars
emails = [["one@example.com"], ["two@example.com", "three@example.com"]]
start_time = datetime.now()
end_time = datetime.now() + timedelta(hours = 24)
duration = timedelta(minutes=30)
interval = timedelta(hours=1, minutes=30)
calendars = [{
  "account_id": "test_account_id",
  "calendar_ids": ["example_calendar_a", "example_calendar_b"]
}]

api_client.consecutive_availability(emails, duration, interval, start_at, end_at, calendars=calendars)

New Contributors

v5.9.2

Choose a tag to compare

@mrashed-dev mrashed-dev released this 30 Jun 19:45

This release of the Nylas Python SDK brings a small change.

Release Notes

Changed

  • Add enforce_read_only parameter to overriding as_json functions (#225)

v5.9.1

Choose a tag to compare

@mrashed-dev mrashed-dev released this 21 Jun 15:30

This release of the Nylas Python SDK brings a few enhancements.

Release Notes

Added

  • Add option to include read only params in as_json (#222)

Changed

  • Change config file in hosted-oauth example to match new Flask rules (#221)

Fixed

  • Fix unauthorized error for revoke_token (#223)

New Contributors 🎉

v5.9.0

Choose a tag to compare

@mrashed-dev mrashed-dev released this 10 May 22:00

This new release of the Nylas Python SDK brings support for collective and group events.

Release Notes

Added

  • Support collective and group events

v5.8.0

Choose a tag to compare

@mrashed-dev mrashed-dev released this 14 Apr 21:39

This new release of the Nylas Python SDK brings a few changes.

Release Notes

Added

  • Add support for getting the number of queried objects (count view)

Changed

  • Improved usage of read only fields in models (fixes #212)

Fixed

  • Fix Calendar availability functions not using the correct authentication method

Using New Features

Getting the number of queried objects (count view)

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

total_contacts = nylas.contacts.count()

# We also support filtering in conjunction with count
emails_from_support = nylas.messages.where(from_="support@nylas.com").count()

v5.7.0

Choose a tag to compare

@mrashed-dev mrashed-dev released this 31 Mar 21:12

This new release of the Nylas Python SDK a couple of new features and enhancements.

Release Notes

Added

  • Add Outbox support
  • Add support for new (beta) Integrations authentication (Integrations API, Grants API, Hosted Authentication for Integrations)
  • Add support for limit and offset for message/thread search
  • Add authentication_type field to Account

Changed

  • Bump supported API version to v2.5

Fixed

  • Fix Draft not sending metadata (#205)

Using New Features

Outbox

To send a new message through the outbox:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

# Create a draft
draft = api_client.drafts.create()
draft.subject = "With Love, from Nylas"
draft.to = [{"email": "test@email.com", "name": "Me"}]
draft.body = "This email was sent using the Nylas email API. Visit https://nylas.com for details."

# Set the outbox-specific parameters
tomorrow = datetime.datetime.today() + datetime.timedelta(days=1)
day_after = tomorrow + datetime.timedelta(days=1)

# Send the outbox message
job_status = nylas.outbox.send(draft, tomorrow, retry_limit_datetime=day_after)

To update an outbox message after sending it

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

# Modify the message
draft = nylas.drafts.get('{id}')
draft.subject = "With Love, from Nylas"

# Set the outbox-specific parameters
tomorrow = datetime.datetime.today() + datetime.timedelta(days=1)
day_after = tomorrow + datetime.timedelta(days=1)

# Update the outbox message
job_status = nylas.outbox.update("job-status-id", draft=draft, send_at=tomorrow, retry_limit_datetime=day_after)

To delete an outbox job

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

nylas.outbox.delete("job-status-id")

We also support SendGrid operations. To get the authentication and verification status

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

verification = nylas.outbox.send_grid_verification_status()
verification.domain_verified
verification.sender_verified

To delete a SendGrid user:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

nylas.outbox.delete_send_grid_sub_user("test@email.com")

Integration Authentication (Beta)

Integrations API

To list all integrations:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

all_integrations = nylas.authentication.integrations.list()

To get an integration for a specific OAuth Provider:

from nylas import APIClient
from nylas.client.authentication_models import Authentication
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

integration = nylas.authentication.integrations.get(Authentication.Provider.ZOOM)

To create a new integration (we will use Zoom for example):

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

integration = nylas.authentication.integrations.create()
integration.name("My Zoom Intrgration")
integration.set_client_id("zoom.client.id")
integration.set_client_secret("zoom.client.secret")
integration.redirect_uris = ["https://www.nylas.com"]
integration.expires_in(1209600)
integration.save()

To update an existing integration:

from nylas import APIClient
from nylas.client.authentication_models import Authentication
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

zoom_integration = nylas.authentication.integrations.get(Authentication.Provider.ZOOM)
zoom_integration.name = "Updated name"
zoom_integration.save()

To delete an existing integration for a specific OAuth provider:

from nylas import APIClient
from nylas.client.authentication_models import Authentication
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

nylas.authentication.integrations.delete(Authentication.Provider.ZOOM);

Grants

To list all grants:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

all_grants = nylas.authentication.grants.list()

To get a specific grant:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

grant = nylas.authentication.grants.get("grant-id")

To create a new grant (we will use Zoom for example):

from nylas import APIClient
from nylas.client.authentication_models import Authentication
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

grant = nylas.authentication.grants.create()
grant.provider = Authentication.Provider.ZOOM
grant.settings = {"refresh_token": "zoom_refresh_token"}
grant.state = "test_state"
grant.scope = ["meeting:write"]
grant.metadata = {"sdk": "python sdk"}
grant.save()

To update an existing grant:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

grant = nylas.authentication.grants.get("grant-id")
grant.metadata = {"sdk": "python sdk"}
grant.save()

To delete an existing grant:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

nylas.authentication.grants.delete("grant_id");

To trigger a re-sync on a grant:

from nylas import APIClient
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

resyced_grant = nylas.authentication.grants.on-demand-sync("grant_id",  sync_from=60);

Hosted Authentication for Authentication

To begin the hosted authentication process and get a login url:

from nylas import APIClient
from nylas.client.authentication_models import Authentication
nylas = APIClient(
    CLIENT_ID,
    CLIENT_SECRET,
    ACCESS_TOKEN
)

login_info = nylas.authentication.hosted_authentication(
  provider=Authentication.Provider.ZOOM,
  redirect_uri="https://www.nylas.com",
  settings={"refresh_token": "zoom_refresh_token"},
  scope=["meeting:write"],
  metadata={"sdk": "python sdk"},
  login_hint="example@mail.com",
  state="my-state",
  expires_in=43200
)