Christopher Gallo, Senior API Developer
The SoftLayer API has two main urls to send requests to.
Only big difference is the SoftLayer_Resource_Metadata service only exists on the private network API.
Specify the endpoint type and version
API is broken down into "Services", which contain a collection of methods that perform some action.
Data returned by the API is broken down into "Datatypes". Services usually have a matching datatype, but not all datatypes have a matching service.
Methods tell the API which action to actually run in a class/service.
$ curl -s -u $SL_USER:$SL_APIKEY \'https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getObject.json'{"accountManagedResourcesFlag":false,"accountStatusId":1001,"address1":"4849 Alpha Rd","allowedPptpVpnQuantity":0,"brandId":2,"city":"Dallas", LOTS OF DATA}
For XML and SOAP requests, the method, and all other parameters will go into the request payload envelope.
Some methods require an InitParamter, listed in the documentation. For REST calls, this goes between the Service and Method. For SOAP/XML requests, this is set in the header.
$ curl -s -u $SL_USER:$SL_APIKEY \'https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/100317048/getObject'{"accountId":307608,"createDate":"2020-04-07T04:01:49-06:00","dedicatedAccountHostOnlyFlag":false,"domain":"chechu.com", OTHER DATA}
The documentation for this API method says it requires a SoftLayer_Virtual_GuestInitParameters
header, which means we need to send in a Virtual Guest id as the init parameter. If you get a 404 error on these sort of API calls, check your user has access to the resource, and the resource is active. Cancelled resources are usually not available from the API.
curl -u $SL_USER:$SL_APIKEY -X POST \ -d '{"parameters": [{"hostname": "testingEdit"}]}' 'https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/999999999/editObject.json'
You can control the format of the returned data by adding .FORMAT to the end of the URI for REST requests. XML requests will return XML data, SOAP requests will return SOAP data.
Read Authenticating to the SoftLayer API for full details.
getUserMetadata()
getTags()
getHostname()
getDatacenter
$ curl -d @SoftLayer_Account-getObject.xml https://api.softlayer.com/xmlrpc/v3.1/SoftLayer_Account
SoftLayer_Account-getObject.xml<?xml version='1.0' encoding='iso-8859-1'?><methodCall><methodName>getObject</methodName> <params> <param><value><struct><member> <name>headers</name> <value><struct><member> <name>authenticate</name> <value> <struct> <member><name>username</name><value><string>SL123456</string></value></member> <member><name>apiKey</name><value><string>APIKEYGOESHERE</string></value></member> </struct> </value> </member> <member> <name>SoftLayer_ObjectMask</name> <value><struct> <member><name>mask</name><value><string>mask[id,companyName]</string></value></member> </struct></value> </member></struct></value> </member></struct></value></param> </params></methodCall>
<?xml version="1.0" encoding="utf-8"?><params><param> <value> <struct> <member> <name>companyName</name> <value><string>SoftLayer Internal - Development Community</string></value> </member> <member> <name>id</name><value><int>307608</int></value> </member> </struct> </value></param></params>
curl -d @soapAccountGetObject.soap https://api.softlayer.com/soap/v3.1/SoftLayer_Account
soapAccountGetObject.soap<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.service.softlayer.com/soap/v3.1/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Header> <ns1:authenticate xmlns:ns1="http://api.service.softlayer.com/soap/v3.1/"> <ns1:username>SL123456</ns1:username> <ns1:apiKey>APIKEYGOESHERE</ns1:apiKey> </ns1:authenticate> <ns1:SoftLayer_ObjectMask> <mask>mask[id,companyName]</mask> </ns1:SoftLayer_ObjectMask> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns1:getObject/> </SOAP-ENV:Body></SOAP-ENV:Envelope>
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.service.softlayer.com/soap/v3.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getObjectResponse><getObjectReturn xsi:type="ns1:SoftLayer_Account"><companyName xsi:type="xsd:string">SoftLayer Internal - Development Community</companyName><id xsi:type="xsd:int">307608</id></getObjectReturn></ns1:getObjectResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
$> curl -u [username]:[apiKey] \ -d '{"parameters": ["first", "second"]}' \ https://api.[service.]softlayer.com/rest/v3.1/[serviceName]/[initializationParameter]/[methodName]? objectMask=mask[]& objectFilter={} &resultLimit=[offsetValue],[limitValue]
$> curl -u $SL_USER:$SL_APIKEY 'https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getObject.json? objectMask=mask%5Bid%2CcompanyName%5D'{"companyName":"SoftLayer Internal - Development Community","id":307608}
line breaks added for readability only
https://github.com/softlayer/softlayer-python
$ slcli call-api --helpUsage: slcli call-api [OPTIONS] SERVICE METHOD [PARAMETERS]...$ slcli call-api SoftLayer_Account getObject --mask="mask[id,companyName]":.............:............................................:: name : value ::.............:............................................:: companyName : SoftLayer Internal - Development Community :: id : 307608 ::.............:............................................:
$ ibmcloud.exe sl call-api --helpUSAGE: ibmcloud.exe sl call-api SERVICE METHOD [OPTIONS]$ ibmcloud.exe sl call-api SoftLayer_Account getObject --mask="mask[id,companyName]"{ "companyName": "SoftLayer Internal - Development Community", "id": 307608}
{"parameters": ["first", {"second_is_object":{"id":1234}}]}
The SoftLayer API has two main urls to send requests to.
Only big difference is the SoftLayer_Resource_Metadata service only exists on the private network API.
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |