Skip to main content

netsuite-sdk-py

Netsuite-sdk-py is a Python SDK using the SOAP client library zeep(https://python-zeep.readthedocs.io/en/master/) for accessing NetSuite resources via the NetSuite SOAP web service SuiteTalk(http://www.netsuite.com/portal/platform/developer/suitetalk.shtml).

Installation

$ pip install netsuitesdk 

Remark: This python NetSuite SDK uses the SOAP/WSDL library Zeep which should automatically be installed when running above pip-command. Otherwise you can run $ pip install zeep first.

Get Started

There are the following options to access a NetSuite account via web services:

  • Either pass credentials (email, password, role and account Id) via login and start a request session
  • Pass credentials in the header of each request
  • Use token based authentication (within each request)

Login with credentials

The following code performs a login to a NetSuite account and starts a web service session.

from netsuitesdk import NetSuiteClient

# Initialize the NetSuite client instance by passing the application Id
# which will be passed to the request header in the login operation.
ns = NetSuiteClient(caching='sqlite', debug=True)

passport = ns.create_passport(email=NS_EMAIL,
                              password=NS_PASSWORD,
                              role=NS_ROLE,
                              account=NS_ACCOUNT)

# Authenticate the user and start a new webservice session in NetSuite
ns.login(app_id=NS_APPID, passport=passport)

# Make requests. All requests done in this session will be identified
# with the application Id passed to the login operation

ns.logout()

To avoid storing the credentials in the python source code file, one can use python-dotenv ($ pip install python-dotenv) to load authentication credentials from a .env-file as environment variables. The .env-file would look something like this:

NS_EMAIL = '*****@example.com'
NS_PASSWORD = '*******'
NS_ROLE = '1047'
NS_ACCOUNT = '*********'
NS_APPID = '********-****-****-****-************'

and the variables could be loaded as follows:

import os
from dotenv import load_dotenv

load_dotenv()
NS_EMAIL = os.getenv("NS_EMAIL")
NS_PASSWORD = os.getenv("NS_PASSWORD")
NS_ROLE = os.getenv("NS_ROLE")
NS_ACCOUNT = os.getenv("NS_ACCOUNT")
NS_APPID = os.getenv("NS_APPID")

Remarks and possible errors regarding authentication

Note: NetSuite requires two-factor authentication (2FA) for all Administrator and other highly privileged roles in all NetSuite accounts. Instead, you can login with a non-highly privileged role or use token based authentication (TBA) with your requests. For TBA, see below.

If login fails, a NetSuiteLoginError is thrown.

For more information about NetSuite authentication, see: (https://docs.oracle.com/cloud/latest/netsuitecs_gs/NSATH/NSATH.pdf)

Passing credentials with requests

tba

Token based authentication

tba

Get Request

A basic example (ns is a reference to a NetSuiteClient instance):

vendor = ns.get('vendor', internalId=ref.internalId)
ns.print_values(vendor)

Search

To perform a search request, use NetSuite.search. The SDK provides some utility functions/classes:

  • basic_stringfield_search: A basic example (ns is a reference to a NetSuiteClient instance):
records = ns.basic_stringfield_search(type_name='Vendor',
                                attribute='entityId',
                                value='Alexander Valley Vineyards',
                                operator='is')
print(records[0].internalId)
  • PaginatedSearch (in utils.py): Its usage can be seen inside the utility function NetSuiteClient.paginated_search

Upsert

Basic example(ns is a reference to a NetSuiteClient instance):

vendor = ns.Vendor()
vendor.externalId = 'test_vendor'
vendor.companyName = 'Another Test Inc.'
ref = ns.upsert(record=vendor)

UpsertList

Basic example(ns is a reference to a NetSuiteClient instance):

customer1 = ns.Customer(externalId='customer', email='test1@example.com')
customer2 = ns.Customer(externalId='another_customer', email='test2@example.com')
ns.upsertList(records=[customer1, customer2])

Documentation

Documentation can be found in the docs/_build/html folder (open index.html) and soon in readthedocs. For contributors: to build the documentation (cd to /docs and) run make buildapi as well as make html

Release files for netsuitesdk 0.3.1

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

Source distribution (sdist)

Source distribution for netsuitesdk 0.3.1
File Size Uploaded
netsuitesdk-0.3.1.tar.gz 14.1 kB Details

Built distribution (wheel)

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

Total release size: 28.9 kB

Release files / netsuitesdk-0.3.1.tar.gz

Download URL netsuitesdk-0.3.1.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4a3c71cc4508c91693f761df3d99c8abc66e6d31eab90ce28b059ea8cf0c0064
BLAKE2b-256 checksum
How to use checksums
dcd1e8728ce16210123999e4a088a455f4ce64eb53e0a776895389aa82041c4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release files / netsuitesdk-0.3.1-py3-none-any.whl

Download URL netsuitesdk-0.3.1-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97ddf0cd36b0faadb65fa2096cd05037e878a8e03deae80419a7cf8ad626b370
BLAKE2b-256 checksum
How to use checksums
662f66a5f98ebfe4e63ba994a9cef2c3791cefe9bedf4c6024468cb879d75136
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release history Release notifications | RSS feed

3.3.0

2 release files

3.2.0

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.23.1

2 release files

2.21.4

2 release files

2.21.3

2 release files

2.21.2

2 release files

2.21.1

2 release files

2.21.0

2 release files

2.20.0

2 release files

2.19.2

2 release files

2.19.1

2 release files

2.19.0

2 release files

2.18.1

2 release files

2.18.0

2 release files

2.17.1

2 release files

2.17.0

2 release files

2.16.6

2 release files

2.16.5

2 release files

2.16.3

2 release files

2.16.2

2 release files

2.16.1

2 release files

2.16.0

2 release files

2.15.0

2 release files

2.14.0

2 release files

2.12.1

2 release files

2.12.0

2 release files

2.11.0

2 release files

2.9.0

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.24.0

2 release files

1.22.0

2 release files

1.21.0

2 release files

1.20.0

2 release files

1.14.0

2 release files

1.12.0

2 release files

1.11.0

2 release files

1.10.0

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.2

2 release files

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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