Blog
Home/

Docusign Adds Python and Ruby to the Growing Family of SDKs

Author Majid Mallis
Majid MallisLead Software Engineer
    • Installing the Python SDK
    • Ready. Set. Code.
                • Python SDK Links
                  • Installing the Ruby SDK
                  • Ready. Set. Code.
                            • Ruby SDK Links

                              Table of contents

                              Docusign just released two new SDKs: Python and Ruby. Each enable you to seamlessly integrate with the Docusign eSignature API. With just a few lines of code you can automate workflows such as requesting signatures or signing documents directly inside your Python or Ruby apps.

                              Similar to our other SDKs, the new Python and Ruby SDKs were generated using Swagger Codegen. They provide complete access to all Docusign eSignature REST API endpoints. The SDKs do all the hard work - creating and sending HTTP requests and parsing the HTTP responses - so that you can focus on what matters the most to you: your business.

                              If you haven’t done it yet, sign up for a free developer sandbox account. Developer sandboxes are completely free – no credit card required – and they do not expire.

                              Next create an integrator key and generate an RSA key pair in your sandbox account. Save the private key to a local file. You will need it later to generate JWT tokens for either the Python or Ruby SDKs.

                              I’d like to thank one of my fellow Docusign engineers on the Developer Center team, Naveen Gopala, for helping me to create these SDKs.

                              Python SDK

                              The new Python SDK supports both Python 2 and Python 3 versions. Also, it can be used with both 2-legged and 3-legged authentication.

                              Installing the Python SDK

                              To install the SDK, you can either copy the source code to your project or install the PyPI package using the pip command: pip install docusign_esign. If you use PyPI, make sure to configure PYTHONPATH environment variable.

                              Ready. Set. Code.

                                • First import a few classes from the SDK:

                              from docusign_esign import ApiClient, AuthenticationApi, EnvelopesApi, configuration

                                • Then initialize the API Client:

                              api_client = ApiClient('https://demo.docusign.net/restapi')

                                • Pass the previously saved private key file to the API client to get an OAuth JWT token:

                              api_client.configure_jwt_authorization_flow('/PATH/TO/YOUR_PRIVA E_KEY', 'account-d.docusign.com', 'YOUR_INTEGRATOR_KEY', 'YOUR_USER_ID', 3600)

                                • Set that API client as the default client across the SDK:

                              configuration.api_client = api_client

                                • Docusign service categories are suffixed with 'Api'. Here is how to initialize the 'Authentication' service:

                              auth_api = AuthenticationApi()

                                • Finally, you can call any function from that service. For instance, this call will list the user accounts (for the user identified above with 'USER_ID'):

                              print(auth_api.login())

                              Ruby SDK

                              The Ruby SDK has been tested with version 2.3. It supports all three types of authentication including Service authentication.

                              Installing the Ruby SDK

                              To install the SDK, you can either copy the source code to your project or install the Ruby gem using the gem command: gem install docusign_esign.

                              Ready. Set. Code.

                                • First import the SDK:

                              require ‘docusign_esign’

                                • Then initialize the API Client:

                              host = 'https://demo.docusign.net/restapi' integrator_key = 'YOUR_INTEGRATOR_KEY' user_id = 'YOUR_USER_ID' expires_in_seconds = 3600 #1 hour auth_server = 'account-d.docusign.com' private_key_filename = '/PATH/TO/YOUR_PRIVATE_KEY' configuration = DocuSign_eSign::Configuration.new configuration.host = host api_client = DocuSign_eSign::ApiClient.new(configuration)

                                • Pass the previously saved private key file to the API client to get an OAuth JWT token:

                              api_client.configure_jwt_authorization_flow(private_key_filename, auth_server, integrator_key, user_id, expires_in_seconds)

                                • Docusign service categories are suffixed with 'Api'. Here is how to initialize the 'Authentication' service:

                              authentication_api = DocuSign_eSign::AuthenticationApi.new(api_client)

                                • Finally, you can call any function from that service. For instance, this call will list the user accounts (for the user identified above with 'USER_ID'):

                              login_options = DocuSign_eSign::LoginOptions.new login_information = authentication_api.login(login_options)

                              Additional Resources

                              Get more information about Docusign’s SDKs and stay up-to-date with Docusign developer news and information by visiting these additional resources:

                              We can’t wait to see what you will build with any of our SDKs.

                              Happy DocuSigning!

                              Author Majid Mallis
                              Majid MallisLead Software Engineer

                              Majid Mallis joined Docusign in 2016, as an early engineer on the Developer Center team. He now leads the team’s mission to make Docusign integration seamless and fun with a new incubation program. Previously Majid worked on many projects ranging from our site, to API Explorer, to SDKs. You can find him on Github, mostly contributing to SDKs or occasionally responding to dev community questions.

                              More posts from this author

                              Related posts

                              Discover what's new with Docusign IAM or start with eSignature for free

                              Explore Docusign IAMTry eSignature for Free
                              Person smiling while presenting