Skip to main content

newmode-python

Introduction

This project contains the Python API wrapper for New/Mode API.

Versions

newmode-python uses Semantic Versioning for all changes.

Supported Python Versions

This library has been tested in Python version >= 3.7. Other Python 3.x could be supported.

Installation

Install from PyPi using pip, a package manager for Python.

pip install newmode

Don't have pip installed? Try installing it, by running this from the command line:

$ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python

Or, you can download the source code (ZIP) for twilio-python, and then run:

python setup.py install

You may need to run the above commands with sudo.

Getting Started

Getting started with the New/Mode API couldn't be easier. Create a Client and you're ready to go.

API Credentials

The Client needs your New/Mode credentials. You can either pass these directly to the constructor (see the code below) or via environment variables.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)

Alternately, a Client constructor without these parameters will look for NEWMODE_API_USER and NEWMODE_API_PASSWORD variables inside the current environment. API version has a default value of v1.0 so it's not required to pass this parameter.

We suggest storing your credentials as environment variables. Why? You'll never have to worry about committing your credentials and accidentally posting them somewhere public.

from Newmode import Client
client = Client()

Example usage

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)

response = client.getTools()
print(response)

API Functions

getTools

Return all existing tools.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)

response = client.getTools()
print(response)

getTool

Return specific tool.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
tool_id = "XX"

response = client.getTool(tool_id)
print(response)

lookupTargets

Lookup for targets for a given tool.

The search parameter could be:

Empty

For custom target tools, this will return all targets.

Postal Code

For postal code tools, this will return targets matching the postal code.

Custom

For csv tools, where search is a valid search term this will return matching targets.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
tool_id = "XX"
search = "XXX"

response = client.lookupTargets(tool_id, search)
print(response)

getAction

Return action information for given tool.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
tool_id = "XX"

response = client.getAction(tool_id)
print(response)

runAction

Run action for given tool.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
tool_id = "XX"

payload = {
	"first_name": "Mark",
	"last_name": "Styles",
	"email_address": "lambic@pm.me",
	"postal_code": "H4E 2Y7",
	"email_subject": "This is my subject",
	"your_letter": "This is my letter"
}

response = client.runAction(tool_id, payload)
print(response)

getTarget

Get specific target.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
target_id = "XXXXXX"

response = client.getTarget(target_id)
print(response)

getCampaigns

Get existing campaigns.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)

response = client.getCampaigns()
print(response)

getCampaign

Get specific campaign.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
campaign_id = "XX"

response = client.getCampaign(campaign_id)
print(response)

getOrganizations

Get existing organizations.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)

response = client.getOrganizations()
print(response)

getOrganization

Get specific organization.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
organization_id = "XX"

response = client.getOrganization(organization_id)
print(response)

getServices

Get existing services.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)

response = client.getServices()
print(response)

getService

Get specific service.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
service_id = "XX"

response = client.getService(service_id)
print(response)

getOutreaches

Get existing outreaches for given tool.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
tool_id = "XX"

response = client.getOutreaches(tool_id)
print(response)

getOutreach

Get specific outreach.

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
outreach_id = "XX"

response = client.getOutreach(outreach_id)
print(response)

Paging

In order to get results paginated, you need to send params like this:

from Newmode import Client

api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)

params = {
	'page[size]': 5,
	'page[number]': 2
}

response = client.getServices(params = params)
print(response)

Publishing new versions

In order to publish new versions to Pypi.org, you need to run:

python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*

Getting help

If you need help installing or using the library, please contact us.

Metadata

Release files for newmode 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for newmode 0.1.6
File Size Uploaded
newmode-0.1.6.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for newmode 0.1.6
File Interpreter ABI Platform
newmode-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / newmode-0.1.6.tar.gz

Download URL newmode-0.1.6.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e5dab1b7a34112c275263e04254def139ff22853aba3f080dac95ee36ed71c51
BLAKE2b-256 checksum
How to use checksums
7a71aa8719e8c0fd84a230d1186f79f33f3480766136c1bd06934408f23031a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release files / newmode-0.1.6-py3-none-any.whl

Download URL newmode-0.1.6-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
820fad657987e9d510386d32dc3c2012582ded962cac004f411db8458097fc6a
BLAKE2b-256 checksum
How to use checksums
ba9374e88bceebbde8beaf3be0d81b2f93faacdcdf8f9da982f9e19f1b33aa17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page