{"id":10242,"library":"softlayer","title":"SoftLayer Python Client","description":"The `softlayer-python` library provides both a Python API client and a command-line interface (CLI) for interacting with the IBM Cloud SoftLayer API. It abstracts the complexities of the SOAP/REST API, allowing developers to manage SoftLayer resources such as virtual servers, bare metal, storage, and networking. The current version is 6.2.9, and the project maintains an active release cadence with frequent minor updates and bug fixes.","status":"active","version":"6.2.9","language":"python","source_language":"en","source_url":"https://github.com/SoftLayer/softlayer-python","tags":["softlayer","ibm cloud","api client","infrastructure","cloud management"],"install":[{"cmd":"pip install softlayer","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for making HTTP requests to the SoftLayer API.","package":"requests","optional":false}],"imports":[{"wrong":"import SoftLayer","symbol":"Client","correct":"from SoftLayer import Client"},{"wrong":"import SoftLayer","symbol":"API","correct":"from SoftLayer import API"},{"wrong":"import SoftLayer","symbol":"CLI","correct":"from SoftLayer import CLI"}],"quickstart":{"code":"import SoftLayer\nimport os\n\n# SoftLayer API credentials can be set as environment variables (SL_USERNAME, SL_API_KEY)\n# or passed directly. Environment variables are recommended for security.\n# SL_ENDPOINT_URL is optional, defaults to 'api.softlayer.com/rest/v3.1'\nclient = SoftLayer.Client(\n    username=os.environ.get('SL_USERNAME', 'YOUR_USERNAME'),\n    api_key=os.environ.get('SL_API_KEY', 'YOUR_API_KEY'),\n    endpoint_url=os.environ.get('SL_ENDPOINT_URL')\n)\n\ntry:\n    # Example: Get the account details\n    account = client['Account'].getObject()\n    print(f\"Successfully connected to SoftLayer. Account ID: {account['id']}, Company: {account['companyName']}\")\n\n    # Example: List up to 5 virtual guests (VMs)\n    # Object masks are crucial for retrieving full data\n    mask = 'mask[id, hostname, domain, primaryIpAddress, primaryBackendIpAddress]'\n    vms = client['Account'].getVirtualGuests(mask=mask, limit=5)\n    if vms:\n        print(\"\\nVirtual Guests (first 5):\")\n        for vm in vms:\n            print(f\"- ID: {vm.get('id')}, Hostname: {vm.get('hostname')}, IP: {vm.get('primaryIpAddress')}\")\n    else:\n        print(\"\\nNo virtual guests found.\")\n\nexcept SoftLayer.exceptions.SoftLayerAPIError as e:\n    print(f\"Error connecting to SoftLayer API: {e}\")\n    print(\"Please ensure your SL_USERNAME and SL_API_KEY environment variables are correct.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the SoftLayer client using environment variables for authentication and retrieve basic account information. It also shows an example of fetching virtual guests, highlighting the use of 'object masks' which are fundamental for getting detailed API responses."},"warnings":[{"fix":"Migrate any CDN-related automation to use the newer IBM Cloud CDN services or direct API calls if available. The legacy CDN service is no longer supported through this library.","message":"CDN (Content Delivery Network) commands were removed from the `slcli` (SoftLayer CLI) and the underlying API methods were deprecated.","severity":"breaking","affected_versions":">=6.2.7"},{"fix":"If your code relies on `Vlan.primaryRouter` for datacenter information, review the official documentation or changelog for `softlayer-python` version 6.2.7 to understand the new recommended approach. Direct access to `primaryRouter` might lead to incorrect data or errors.","message":"The method for finding a VLAN's datacenter via `Vlan.primaryRouter` was migrated.","severity":"breaking","affected_versions":">=6.2.7"},{"fix":"Always include an `mask` parameter in your API calls (e.g., `client['Virtual_Guest'].getObject(id=123, mask='mask[primaryIpAddress, backendIpAddress]')`). Refer to the SoftLayer API documentation for available properties for each service.","message":"SoftLayer API calls often return only partial data for objects by default. To retrieve full details (e.g., IP addresses, hardware components for a server), you must specify an 'object mask'.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use the `iter_call` or `cf_call` methods provided by the library for iterating over large result sets, which handle pagination automatically. For manual pagination, use `limit` and `offset` parameters.","message":"When fetching large lists of objects (e.g., `getAllObjects`), the API often uses pagination. Incomplete results or unexpected behavior can occur if not handled correctly.","severity":"gotcha","affected_versions":"All versions, partially addressed in 6.2.9 for `cf_call`"},{"fix":"Understand the order of precedence: direct arguments > config file > environment variables. Ensure only one method is providing credentials to avoid conflicts or unexpected authentication failures. Using environment variables is often the most flexible for scripting.","message":"Authentication can be configured via `~/.softlayer` config file, environment variables (`SL_USERNAME`, `SL_API_KEY`, `SL_ENDPOINT_URL`), or direct arguments to `SoftLayer.Client`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'6.2.9':57 'abstract':31 'activ':63 'allow':38 'api':13,29,37,76 'bare':48 'bug':71 'cadenc':65 'cli':21 'client':3,14,77 'cloud':27,75,79 'command':18 'command-lin':17 'complex':33 'current':54 'develop':39 'fix':72 'frequent':67 'ibm':26,74 'infrastructur':78 'interact':23 'interfac':20 'librari':8 'line':19 'maintain':61 'manag':41,80 'metal':49 'minor':68 'network':52 'project':60 'provid':9 'python':2,7,12 'releas':64 'resourc':43 'server':47 'soap/rest':36 'softlay':1,6,28,42,73 'softlayer-python':5 'storag':50 'updat':69 'version':55 'virtual':46","created_at":"2026-04-17T01:23:07.243325+00:00","updated_at":"2026-04-17T01:23:07.243325+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"6.2.9","cli_name":"slcli","cli_version":"Current: slcli (SoftLayer Command-line) v6.2.9","type":"library","homepage":"https://softlayer.github.io/","github":"https://github.com/SoftLayer/softlayer-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/softlayer/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}