[New] Python client library

Summary

  • We recently released a new major version of the Python client library!
  • We adopted a new paradigm for our client libraries, automatically generating them from our OpenAPI spec
  • We chose this approach with the goals of more frequently adding new features and, eventually, supporting more languages
  • Node v3 was the first client library to follow this pattern
  • Python v5 is the next client library to be auto-generated from our OpenAPI spec

What’s new

More frequent updates
The new Python SDK benefits from automation that allows us to quickly roll out updates as the Asana API evolves. This means it will be updated with new endpoints and API features soon after their release. By generating libraries from our OpenAPI spec, it will also make it easier to offer more language options in the future.

Standard interface
The client is built using tools which are common in the industry. It may be similar to SDKs you’ve used with other services.

Timeline

  • Python v5.0.6 is available now

When to upgrade?

If you have an application which is working and rarely updated, it might not be worth the time and effort to update to the latest version. Here are some scenarios where it might make sense to update:

  • Regularly updated applications: If you add features to your application as new Asana capabilities become available, updating to the latest version is an up front investment that will give you access to new features in the future.

  • New development: If you are starting a new project that uses a template as a starting point, consider updating your template to use the latest SDK. This way, you’ll be ready to make use of new Asana features and SDK bug fixes once they’re available.

Usage & Examples

With Python v5, you set your API access token once and then create an instance for each resource you wish to access (tasks, projects, etc). For example, here’s how to instantiate a user API instance:

import asana_preview
from asana_preview.rest import ApiException
from pprint import pprint

configuration = asana_preview.Configuration()
configuration.access_token = '<YOUR_ACCESS_TOKEN>'
api_client = asana_preview.ApiClient(configuration)

# create an instance of the API class
users_api_instance = asana_preview.UsersApi(api_client)
user_gid = "me"
opts = {}

try:
    # Get a user
    user = users_api_instance.get_user(user_gid, opts)
    pprint(user)
except ApiException as e:
    print("Exception when calling UsersApi->get_user: %s\n" % e)

You can also see client library code examples (including Python v5) in the Asana API reference docs:

Questions and Feedback

Let us know if you have any questions or feedback. We understand and appreciate that it takes time to migrate to a new major version and that it’s not necessary for all apps to do so. If you do decide to migrate your apps, we thank you for your effort!

6 Likes

Exciting news! @Jeff_Schneider FYI I think you have an oopsie URL for the client methods.

1 Like

Thanks @Stephen_Li!