Python SDK for Netsuite API with Django Integration
Project description
README
This library makes it easy to set up a Netsuite authorization without needing a frontend client using CLI utilities.
Docs
What do I need to get set up?
-
Run
pip install netsuite-python -
Activate your python VENV
-
If using virtual environment
- Activate your virtual environment
netsuite = python venv/bin/keap
-
Notes
- Requirements
- Sandbox requires the same setup as Prod, it DOES NOT copy over
- An administrator for the Netsuite app to follow the steps here
- A user with the correct role
- A role with the correct permissions
- An Integration Record with the correct permissions (ensure default form is set correctly)
- Client ID and Secret comes from this step, ensure they provide these
- Certificate ID
- A Certificate can be generated once you register the package with CLI with 'netsuite generate-certificate'
- Cert ID is available under Setup -> Integration -> OAuth 2.0 Client Credentials once the certificate is uploaded.
- Requirements
Generating x509 certificate for Netsuite
-
Run
netsuite generate-certificate- Domain: theapiguys.com
- Organization: TAG
- Department: DEV
- City: BOSTON
- State: MA
- Country: US
- Email: will@theapiguys.com
-
It will ask for the file name that you wish to save the key to. This will be used when entering the creds.
Uploading x509 certificate to Netsuite
- On Client's Netsuite top ribbon go to
Setup -> Integration -> OAuth 2.0 Client Credentials - Click
Create-Newbutton- Entity: The User created for TAG
- ROLE: Role created for this integration
- Application: Application Created for this integration
- Certificate: Click "Choose A File" and upload the PUBLIC Cert (NOT PRIVATE KEY)
- Copy the Certificate ID
Generate Netsuite Client
- Run command to generate sdk using openapi 3.0
- method is generate_swagger_client
- visit link returned from method and download result
- unzip the file and copy the "netsuite_client" folder from the directory into the projects root folder
Setting up Netsuite SDK in a project
- Run
netsuite generate-client-config-
It will ask you for information obtained above: You can use all the defaults
- Client ID
- Netsuite Certificate ID
- Netsuite Key File
- Netsuite Application Name
- Allow None
- Use Datetime
- Storage Class
-
If you want to save to file
- Provide a valid path for netsuite-credentials.json
- else the credentials will be echoed out
-
To confirm, check the netsuite credentials path you entered, or the default, and there should be a json file with all the info you entered. Verify the details.
-
Getting The Access Token
- Run
$netsuite get-access-token- Use the defaults or repeat the info used above for
- Path to Netsuite Credentials
- Confirm the app name to be refreshed, if single app, just use default
- Use the defaults or repeat the info used above for
- That's it! You should now have a valid token to use with the Netsuite API.
Usage
It is pretty simple to get started using the SDK once you have a valid token.
Setup Netsuite
from netsuite import Netsuite
import netsuite_client
from netsuite_client.api.customer_api import CustomerApi
netsuite = Netsuite(config_file=settings.NS_CREDENTIALS_PATH)
customer_api = CustomerApi(netsuite.REST_CLIENT)
print(customer_api.customer_id_get(id=1617260))
Example Usage
print(ns_contact_api.contact_id_get(id=1413220))
Documentation for API Endpoints
All URIs are relative to https://{App_Name}.suitetalk.api.netsuite.com/services/rest/record/v1
| Class | Method | HTTP request | Description |
|---|---|---|---|
| ContactApi | contact_get | GET /contact | Get list of records. |
| ContactApi | contact_id_delete | DELETE /contact/{id} | Remove record. |
| ContactApi | contact_id_get | GET /contact/{id} | Get record. |
| ContactApi | contact_id_patch | PATCH /contact/{id} | Update record. |
| ContactApi | contact_id_put | PUT /contact/{id} | Insert or update record. |
| ContactApi | contact_post | POST /contact | Insert record. |
| CustomerApi | customer_get | GET /customer | Get list of records. |
| CustomerApi | customer_id_delete | DELETE /customer/{id} | Remove record. |
| CustomerApi | customer_id_get | GET /customer/{id} | Get record. |
| CustomerApi | customer_id_patch | PATCH /customer/{id} | Update record. |
| CustomerApi | customer_id_put | PUT /customer/{id} | Insert or update record. |
| CustomerApi | customer_idtransform_cash_sale_post | POST /customer/{id}/!transform/cashSale | Transform to cashSale. |
| CustomerApi | customer_idtransform_invoice_post | POST /customer/{id}/!transform/invoice | Transform to invoice. |
| CustomerApi | customer_idtransform_sales_order_post | POST /customer/{id}/!transform/salesOrder | Transform to salesOrder. |
| CustomerApi | customer_idtransform_vendor_post | POST /customer/{id}/!transform/vendor | Transform to vendor. |
| CustomerApi | customer_post | POST /customer | Insert record. |
Documentation For Models
- Contact
- ContactCollection
- ContactCustomForm
- Customer
- CustomerAddressBookAddressBookAddress
- CustomerAddressBookCollection
- CustomerAddressBookElement
- CustomerAlcoholRecipientType
- CustomerCampaignsCollection
- CustomerCampaignsElement
- CustomerCollection
- CustomerContactRolesCollection
- CustomerContactRolesElement
- CustomerCustomForm
- CustomerEmailPreference
- CustomerGlobalSubscriptionStatus
- CustomerGroupPricingCollection
- CustomerGroupPricingElement
- CustomerItemPricingCollection
- CustomerItemPricingElement
- CustomerLanguage
- CustomerNegativeNumberFormat
- CustomerNumberFormat
- CustomerShippingCarrier
- CustomerSymbolPlacement
- CustomerThirdPartyCarrier
- CustomeraddressBookaddressBookAddressCountry
- NsError
- NsErrorOerrorDetails
- NsLink
- NsResource
- NsResourceCollection
- OneOfcontactCompany
- OneOfcontactCustentityCourseAttended
- OneOfcontactCustentityEnergyEffAttended
- OneOfcontactCustentityHitachiCourseAttended
- OneOfcontactCustentityHpCourseAttended
- OneOfcontactCustentityPvCourseAtteneded
- OneOfcontactCustentitySolCourseAttended
- OneOfcontactCustentityUnventHotWaterG3
- OneOfcontactCustentityWaterRegulations1999
- OneOfcustomerCustentityCourseAttended
- OneOfcustomerCustentityEnergyEffAttended
- OneOfcustomerCustentityHitachiCourseAttended
- OneOfcustomerCustentityHpCourseAttended
- OneOfcustomerCustentityPvCourseAtteneded
- OneOfcustomerCustentitySolCourseAttended
- OneOfcustomerCustentityUnventHotWaterG3
- OneOfcustomerCustentityWaterRegulations1999
- OneOfcustomerItemPricingElementItem
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file netsuite_python-1.3.3.tar.gz.
File metadata
- Download URL: netsuite_python-1.3.3.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
981eaacd1ad048b638702511a903c3b8895c12462890358a576da783bb1b2068
|
|
| MD5 |
9142969b93df59b73837b51fb07a0b65
|
|
| BLAKE2b-256 |
d170a12de0193971afbaf97eea470b8f218ca326876b2fe4f87692bac50cfde8
|