Skip to content

kslater3/suitepy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Suitepy


Python Library for the Netsuite REST API


will update this README later into a cleaner version with better examples, just getting a starting point established for now


Installation

Currently not in PIP repositories. Will make into a Package Later
pip install suitepy


Usage

Setup

netsuite integration and access tokens . . .
production and sandbox account id in url . . .

Credentials should be a JSON Object with the following parameters NOTE: These are fake example Tokens

{
    "account_id": "1234567",

    "token_id": "12345abcde678910fghij123asdf234asdfwr5sdaf2354sadg234sadf234dsaf",
	
    "token_secret": "saf8u9as79823623h4nfy7324uihfe78428h78nhew789823fm782387n8372h72",
	
	"consumer_key": "askjdhfuiy3278950234875hfjhsdkf3287942346shf349875hsdf8734hdfsi7",
	
	"consumer_secret": "sdaf6987sf6873hi5h34k57fd78sd623h4n3k8d9fg7sdf98g7kj5n3k4j5nd897"
}

Import Suitepy

import suitepy as sp

I recommend storing credentials in an external json file. Then you can call read_credentials with the path to that file and it will make the json that you pass to RESTMaster for you.
read_credentials

credentials = sp.read_credentials('netsuite-credentials.json')

Create an instance of RESTMaster

meister = sp.RESTMaster(credentials)

Query

only select . . .
see suiteql documentation and sql-92 stuff . . .
Query All

records = meister.query_all("SELECT companyName FROM Customer")

# Convert to a pandas dataframe
import pandas as pd
df = pd.DataFrame(records)

CRUD opreations return empty HTTP 204 No Content responses on success

  • So you can check response.ok to determine if successful
  • Also, it only lets you do things 1 record at a time, but I will make a bulk_create and bulk_update method later

Create

empty response on success, check ok and status code . . .
Use the header link that is returned to determine the id of the newly created record, if needed.
create bulk . . .
. . .
Create

response = meister.create('customer', '{"entityid": "RESTTEST_1", "companyname": "REST Customer 1", "subsidiary": {"id": "7"}}')

# Check Results
print(response.ok)
print(response.status_code)

Update

. . .
Update

# Need the Internal Id of the record, in this case 124529, later I will work on external id
response = meister.update('customer', 124529, '{"externalId": "REST_Customer_3"}')

Delete

. . .
Delete

# Need the Internal Id of the record, in this case 124530, later I will work on external id
response = meister.delete('customer', 124530)

Errors

Exceptions . . .
error messages . . .
. . .


etc.

<br / >

. . .

Releases

No releases published

Packages

No packages published

Languages