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 (nsis a reference to aNetSuiteClientinstance):
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 functionNetSuiteClient.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
Metadata
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netsuitesdk-0.3.1.tar.gz | 14.1 kB | Without provenance | Details for netsuitesdk-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netsuitesdk-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for netsuitesdk-0.3.1-py3-none-any.whl |
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
|
Security for netsuitesdk 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.