Skip to content

doverhq/nylas-python

 
 

Repository files navigation

Dover Fork

We forked this sdk so we can host our own dover-nylas sdk so we can have multiple versions of the same sdk installed To publish a dover-nylas version of an existing version of the nylas sdk, we need to do the following:

  • git checkout tag-name-of-the-version ex: git checkout v6.0.0
  • override the package name and add some helpers. You can do that by cherry picking a commit with the helpers onto the checkout tag using git cherry-pick df4f62b3884bce622b6938613d5299367b149e79
  • resolve conflicts if any and complete the cherry-pick with git cherry-pick --continue
  • create a new branch with the name of the version prefixed with dover ex: git checkout -b dover-v6.0.0
  • push up the new branch
  • create a new tag with the name of the version prefixed with dover ex: git tag dover-v6.0.0
  • push up the new tag with git push origin tag dover-v6.0.0
  • install requirements locally with make sync-dev-deps or pip install -e ".[release,test,docs]"
  • publish the version to our pypi with PACKAGR_TOKEN=<token from 1p> make publish-package which is in the makefile in the cherrypicked commit. OR PACKAGR_TOKEN=<token from 1p> rm -rf dist *.egg-info && python setup.py sdist && twine upload dist/* --repository-url https://api.packagr.app/88ncBXhza/ -u '' -p ${PACKAGR_TOKEN}

Nylas Python SDK

PyPI - Version codecov

This is the GitHub repository for the Nylas Python SDK. The repo is primarily for anyone who wants to install the SDK from source or make contributions to it.

If you're looking to use Python to access the Nylas Email, Calendar, or Contacts APIs, see our Python SDK Quickstart guide.

The Nylas platform provides REST APIs for Email, Calendar, and Contacts, and the Python SDK is the quickest way to build your integration using Python.

Here are some resources to help you get started:

If you have any questions about the Nylas platform, please reach out to support@nylas.com.

⚙️ Install

The Nylas Python SDK is available via pip:

pip install nylas --pre

To install the SDK from source, clone this repo and run the install script:

git clone https://github.com/nylas/nylas-python.git && cd nylas-python
python setup.py install

⚡️ Usage

Before you use the Nylas Python SDK, you must first create a Nylas account. Then, follow our API v3 Quickstart guide to set up your first app and get your API keys.

For code samples and example applications, take a look at our Python repos in the Nylas Samples collection.

🚀 Make your first request

After you've installed and set up the Nylas Python SDK, you can make your first API request. To do so, use the Client class from the nylas package.

The SDK is organized into different resources, each of which has methods to make requests to the Nylas API. Each resource is available through the Client object that you configured with your API key. For example, you can use this code to get a list of Calendars:

from nylas import Client

nylas = Client(
    api_key="API_KEY",
)

calendars, request_id, next_cursor = nylas.calendars.list("GRANT_ID")

event, request_id = nylas.events.create(
    identifier="GRANT_ID",
    request_body={
        "title": "test title",
        "description": "test description",
        "when": {
            "start_time": start_unix_timestamp,
            "end_time": end_unix_timestamp,
        }
    },
    query_params={"calendar_id": "primary", "notify_participants": True},
    )
)

event, request_id = nylas.events.find(
    identifier="GRANT_ID",
    event_id=event.id,
    query_params={
        "calendar_id": "primary",
    },
)

nylas.events.destroy("GRANT_ID", event.id, {"calendar_id": "primary"})

📚 Documentation

This SDK makes heavy use of Python 3 dataclasses to define the REST resources and request/response schemas of the Nylas APIs. The Client object is a wrapper around all of these resources and is used to interact with the corresponding APIs. Basic CRUD operations are handled by the create(), find(), list(), update(), and destroy() methods on each resource. Resources may also have other methods which are all detailed in the reference guide for the Python SDK. In the code reference, start at client, and then resources will give more info on available API call methods. models is the place to find schemas for requests, responses, and all Nylas object types.

While most resources are accessed via the top-level Client object, note that auth contains the sub-resource grants as well as a collection of other auth-related API calls.

You'll want to catch nylas.models.errors.NylasAPIError to handle errors.

Have fun!!

✨ Upgrade from v5.x

See UPGRADE.md for instructions on upgrading from v5.x to v6.x.

💙 Contribute

Please refer to Contributing for information about how to make contributions to this project. We welcome questions, bug reports, and pull requests.

🛠️ Debugging

It can sometimes be helpful to turn on request logging during development. Adding the following snippet to your code that calls the SDK should get you sorted:

import logging
import requests

# Set up logging to print out HTTP request information
logging.basicConfig(level=logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

📝 License

This project is licensed under the terms of the MIT license. Please refer to LICENSE for the full terms.

About

Fork of the nylas repo to allow access to an older version

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.9%
  • Makefile 0.1%