{"id":8347,"library":"netsuite","title":"NetSuite Python Client","description":"The `netsuite` Python library provides an asynchronous client for interacting with NetSuite's SuiteTalk SOAP/REST Web Services and Restlets. It simplifies making requests, handling authentication (including Token-Based Authentication), and parsing responses. Currently at version 0.12.0, the library has a moderately active release cadence, with several minor releases and occasional breaking changes.","status":"active","version":"0.12.0","language":"en","source_language":"en","source_url":"https://github.com/jacobsvante/netsuite","tags":["netsuite","erp","api","async","soap","rest","suiteql"],"install":[{"cmd":"pip install netsuite","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"NetSuite","correct":"from netsuite import NetSuite"}],"quickstart":{"code":"import asyncio\nimport os\nfrom netsuite import NetSuite\n\nasync def main():\n    # Ensure these environment variables are set:\n    # NETSUITE_ACCOUNT, NETSUITE_CONSUMER_KEY, NETSUITE_CONSUMER_SECRET,\n    # NETSUITE_TOKEN_ID, NETSUITE_TOKEN_SECRET\n    \n    # The NetSuite client automatically picks up credentials from environment variables.\n    # For explicit config, see documentation.\n    ns = NetSuite()\n\n    print(f\"NetSuite client initialized for account: {os.environ.get('NETSUITE_ACCOUNT', '[Not Set]')}\")\n\n    try:\n        # Example: Fetch a specific record using the REST API\n        # Replace 'customer' and '1234' with actual record type and ID in your NetSuite instance\n        customer_id = '1234'\n        customer_record = await ns.rest_api.get(\n            f\"record/v1/customer/{customer_id}\"\n        )\n        print(f\"Successfully fetched customer {customer_id}:\\n{customer_record}\")\n\n        # Example: Run a SuiteQL query\n        # This query selects the ID and company name of the first 5 customers\n        suiteql_result = await ns.suiteql.get(\n            \"SELECT id, companyname FROM customer ORDER BY id LIMIT 5\"\n        )\n        print(f\"\\nSuccessfully executed SuiteQL query (first 5 customers):\\n{suiteql_result}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    # Set dummy environment variables for demonstration if not set\n    os.environ.setdefault('NETSUITE_ACCOUNT', 'TEST_ACCOUNT_ID')\n    os.environ.setdefault('NETSUITE_CONSUMER_KEY', 'TEST_CONSUMER_KEY')\n    os.environ.setdefault('NETSUITE_CONSUMER_SECRET', 'TEST_CONSUMER_SECRET')\n    os.environ.setdefault('NETSUITE_TOKEN_ID', 'TEST_TOKEN_ID')\n    os.environ.setdefault('NETSUITE_TOKEN_SECRET', 'TEST_TOKEN_SECRET')\n\n    asyncio.run(main())\n","lang":"python","description":"This quickstart initializes the `NetSuite` client, which automatically picks up credentials from environment variables, and then demonstrates fetching a customer record using the REST API and executing a simple SuiteQL query. Replace placeholder IDs with your actual NetSuite data. Remember to set your NetSuite credentials as environment variables."},"warnings":[{"fix":"Review `CHANGELOG.md` for 0.10.0 and ensure your code is updated to align with the new library versions and any API changes. Test thoroughly after upgrading.","message":"Version 0.10.0 introduced 'large breaking changes' due to significant updates of underlying libraries (e.g., aiohttp, zeep, lxml). This may affect existing code relying on specific dependency versions or low-level interactions.","severity":"breaking","affected_versions":"0.10.0 and newer"},{"fix":"If upgrading from pre-0.7.0 versions, consult the `CHANGELOG.md` for version 0.7.0 to understand the necessary code adjustments.","message":"Version 0.7.0 was a 'beta' release that introduced 'a lot of things' that break previous functionality. The documentation explicitly advised reviewing the `CHANGELOG.md` carefully for migration.","severity":"breaking","affected_versions":"0.7.0 - 0.9.x"},{"fix":"Ensure all calls like `ns.rest_api.get()` or `ns.suiteql.get()` are prefixed with `await`. Run your main application logic using `asyncio.run(main_async_function())`.","message":"The `netsuite` library is built entirely on `asyncio`. All API calls and client methods that interact with NetSuite must be `await`ed within an `async` function or an `asyncio` event loop.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify all five required environment variables are correctly set and accessible by your application. Double-check for typos or incorrect values.","message":"Authentication primarily relies on Token-Based Authentication (TBA) credentials provided via environment variables (NETSUITE_ACCOUNT, NETSUITE_CONSUMER_KEY, NETSUITE_CONSUMER_SECRET, NETSUITE_TOKEN_ID, NETSUITE_TOKEN_SECRET). Missing or incorrect variables will lead to authentication failures.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Prepend `await` to the async call (e.g., `await ns.rest_api.get(...)`) and ensure your code is running within an `async` function or `asyncio.run()`.","cause":"Attempting to call an asynchronous method (e.g., `ns.rest_api.get()`) without `await` in an `async` context or outside an `asyncio` loop.","error":"TypeError: object asyncio.coroutines.CoroWrapper can't be used in 'await' expression"},{"fix":"Check that `NETSUITE_ACCOUNT`, `NETSUITE_CONSUMER_KEY`, `NETSUITE_CONSUMER_SECRET`, `NETSUITE_TOKEN_ID`, and `NETSUITE_TOKEN_SECRET` environment variables are correctly set and correspond to a valid NetSuite TBA setup.","cause":"Incorrect or missing NetSuite Token-Based Authentication (TBA) credentials (account ID, consumer key/secret, token ID/secret).","error":"netsuite.exceptions.NetSuiteAPIError: Authentication Failure"},{"fix":"Refer to the latest documentation and `CHANGELOG.md` for your installed version. Update your code to use the current API methods and object structures.","cause":"Attempting to use a method or attribute that has been removed or renamed in a newer version of the `netsuite` library, especially after a major upgrade like 0.10.0.","error":"AttributeError: 'NetSuite' object has no attribute 'some_old_method'"}]}