REST Api
General informations
REST Api token
Your REST Api token is available as soon as one of the following condition is met:
- you subscribed a monthly account type which gives you access to the REST Api accroding to a certain number of call per consecutive 24 hours during the month
- you bought credits to use the REST Api and your credits are still usable (meaning you bought the credits less than 30 days ago)
Response formats
The Api allows to get response either as:
- JSON
- JSONP
- PHP
- XML
The response format has to be indicated at the very end of the request as:
- .json
- .jsonp: in this particular case, the GET parameter callback must be set with the javascript function to be called in return
- .php
- .xml
Saved request ID
The saved request id is the ID value indicated within the popin that lists the saved requests.
The error id and messages
The Api always returns informations about the response state. To do so, the following keys are present:
- error_code:
- type: integer
- values: 1, 2, etc.
- error:
- type: boolean
- values: 1 or 0
- error_reason:
- type: string
- values: Account desactivated, etc.
Concretely, when you receive a response, you should always check the error value. It the value is 0, then there is no reason to check the error_code and error_reason values as it means there is no error at all.
If the error has 1 for value, then you should look to the error_code and/or error_reason values to know what happened.
Error code | Error reason |
---|---|
0 | empty |
1 | User not authorized/recognized |
2 | Account desactivated |
3 | Error on login |
4 | Internal Error, no package found |
5 | SoapCall undefined or not saved |
6 | Exception intercepted when sending request |
7 | SoapCall undefined or not saved |
8 | No POST data found, aborted |
Requests
Methods that apply to requests.
GET Saved request
Returns the saved request details.
Resource url:
- https://api.wsdlotphp.com/rest/request/v1/get/[API_TOKEN]/[REQUEST_ID][RESPONSE_FORMAT]
Parameters:
- API_TOKEN: see General informations > REST Api token
- REQUEST_ID: see General informations > Saved request id
- RESPONSE_FORMAT: see General informations > Response formats
Example request:
- http://api.wsdltophp.com/rest/request/v1/get/53d5dbf25871fddb417ca10105ee06ba2022f2a2/846.json
Example response:
{
"error_code":0,
"error":false,
"error_reason":null,
"output_format":"json",
"data":{
"soapcall":{
"id":"846",
"title":"Request sent on 13 February 2014 at 22h58m46s",
"description":"Call of PayPalServiceGet::GetBalance, nouvelle version PSR-2 de WsdlToPhp",
"created":"1392328700",
"packagename":"PayPal",
"servicename":"PayPalServiceGet",
"methodname":"GetBalance"
},
"requests":{
"soapoptions":{
"wsdl_url":"https:\/\/www.paypalobjects.com\/wsdl\/PayPalSvc.wsdl",
"location":"https:\/\/api-3t.paypal.com\/2.0\/"
},
"soapheaders":{
"namespace":{
"1":"urn:ebay:api:PayPalAPI"
},
"name":{
"1":"RequesterCredentials"
},
"mustunderstand":{
"1":"0"
},
"actor":{
"1":""
},
"data_type":{
"1":"PayPalStructCustomSecurityHeaderType"
},
"data":{
"1":{
"1":"",
"2":"",
"3":{
"1":"",
"2":"",
"3":"",
"4":"*************************",
"5":"*************************",
"6":"**************************************************",
"7":"",
"8":""
}
}
}
},
"httpheaders":{
"name":[""],
"value":[""]
},
"parameters":{
"1":{
"1":{
"1":"1",
"2":"VALUE_RETURNALL",
"3":"",
"4":"109",
"5":""
}
}
}
}
}
}
GET Response from saved request
Returns the live response from the SOAP Web service using the saved request.
Resource url:
- https://api.wsdlotphp.com/rest/request/v1/send/[API_TOKEN]/[REQUEST_ID][/FULL][RESPONSE_FORMAT]
Parameters:
- API_TOKEN: see General informations > REST Api token
- REQUEST_ID: see General informations > Saved request id
- FULL: allows to indicate if the response must contain the saved request details or not
- RESPONSE_FORMAT: see General informations > Response formats
Example request:
- http://api.wsdltophp.com/rest/request/v1/send/53d5dbf25871fddb417ca10105ee06ba2022f2a2/846.xml: the response does not contain the saved request details
- http://api.wsdltophp.com/rest/request/v1/send/53d5dbf25871fddb417ca10105ee06ba2022f2a2/846/1.xml: the response does contain the saved request details
Example response (full response):
<xml formated="false">
<error_code>0</error_code>
<error />
<error_reason />
<output_format>xml</output_format>
<data>
<soapcall>
<id>846</id>
<title>Request sent on 13 February 2014 at 22h58m46s</title>
<description> Call of PayPalServiceGet::GetBalance, nouvelle version PSR-2 de WsdlToPhp</description>
<created>1392328700</created>
<packagename>PayPal</packagename>
<servicename>PayPalServiceGet</servicename>
<methodname>GetBalance</methodname>
</soapcall>
<requests>
<soapoptions>
<wsdl_url>https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl</wsdl_url>
<location>https://api-3t.paypal.com/2.0/</location>
</soapoptions>
<soapheaders>
<namespace>
<array_element index="1">urn:ebay:api:PayPalAPI</array_element>
</namespace>
<name>
<array_element index="1">RequesterCredentials</array_element>
</name>
<mustunderstand>
<array_element index="1">0</array_element>
</mustunderstand>
<actor>
<array_element index="1" />
</actor>
<data_type>
<array_element index="1">PayPalStructCustomSecurityHeaderType</array_element>
</data_type>
<data>
<array_element index="1">
<array_element index="1" />
<array_element index="2" />
<array_element index="3">
<array_element index="1" />
<array_element index="2" />
<array_element index="3" />
<array_element index="4">************************</array_element>
<array_element index="5">************************</array_element>
<array_element index="6">************************************************</array_element>
<array_element index="7" />
<array_element index="8" />
</array_element>
</array_element>
</data>
</soapheaders>
<httpheaders>
<name>
<array_element index="0" />
</name>
<value>
<array_element index="0" />
</value>
</httpheaders>
<parameters>
<array_element index="1">
<array_element index="1">
<array_element index="1">1</array_element>
<array_element index="2">VALUE_RETURNALL</array_element>
<array_element index="3" />
<array_element index="4">109</array_element>
<array_element index="5" />
</array_element>
</array_element>
</parameters>
</requests>
<responses>
<xmlrequest>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:ebay:apis:eBLBaseComponents" xmlns:ns2="urn:ebay:api:PayPalAPI">
<SOAP-ENV:Header>
<ns2:RequesterCredentials>
<ns1:Credentials>
<ns1:Username>************************</ns1:Username>
<ns1:Password>************************</ns1:Password>
<ns1:Signature>************************************************</ns1:Signature>
</ns1:Credentials>
</ns2:RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns2:GetBalanceReq>
<ns2:GetBalanceRequest>
<ns1:DetailLevel>ReturnAll</ns1:DetailLevel>
<ns1:Version>109</ns1:Version>
<ns2:ReturnAllCurrencies>1</ns2:ReturnAllCurrencies>
</ns2:GetBalanceRequest>
</ns2:GetBalanceReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</xmlrequest>
<xmlresponse>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ed="urn:ebay:apis:EnhancedDataTypes" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI">
<SOAP-ENV:Header>
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType" />
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
<Username xsi:type="xs:string" />
<Password xsi:type="xs:string" />
<Signature xsi:type="xs:string" />
<Subject xsi:type="xs:string" />
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body id="_0">
<GetBalanceResponse xmlns="urn:ebay:api:PayPalAPI">
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2014-04-30T21:51:26Z</Timestamp>
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Success</Ack>
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">5788f1bca66bc</CorrelationID>
<Version xmlns="urn:ebay:apis:eBLBaseComponents">109</Version>
<Build xmlns="urn:ebay:apis:eBLBaseComponents">10277387</Build>
<Balance xsi:type="cc:BasicAmountType" currencyID="EUR">996.79</Balance>
<BalanceTimeStamp xsi:type="xs:dateTime">2014-04-30T21:51:26Z</BalanceTimeStamp>
<BalanceHoldings xsi:type="cc:BasicAmountType" currencyID="EUR">996.79</BalanceHoldings>
</GetBalanceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</xmlresponse>
<httpheaderrequest>
<Host>api-3t.paypal.com</Host>
<Connection>Keep-Alive</Connection>
<User-Agent>PHP-SOAP/5.3.5</User-Agent>
<Content-Type>text/xml; charset=utf-8</Content-Type>
<SOAPAction>""</SOAPAction>
<Content-Length>770</Content-Length>
</httpheaderrequest>
<httpheaderresponse>
<Date>Wed, 30 Apr 2014 21:51:26 GMT</Date>
<Server>Apache</Server>
<Content-Length>1940</Content-Length>
<Connection>close</Connection>
<Content-Type>text/xml; charset=utf-8</Content-Type>
</httpheaderresponse>
<phprequest>
<array_element index="0" type="PayPalStructGetBalanceReq">
<GetBalanceRequest type="PayPalStructGetBalanceRequestType">
<ReturnAllCurrencies>1</ReturnAllCurrencies>
<DetailLevel>ReturnAll</DetailLevel>
<ErrorLanguage />
<Version>109</Version>
<any />
</GetBalanceRequest>
</array_element>
</phprequest>
<phpresponse type="PayPalStructGetBalanceResponseType">
<Balance type="PayPalStructBasicAmountType">
<currencyID>EUR</currencyID>
<_>996.79</_>
</Balance>
<BalanceTimeStamp>2014-04-30T21:51:26Z</BalanceTimeStamp>
<BalanceHoldings>
<array_element index="0" type="PayPalStructBasicAmountType">
<currencyID>EUR</currencyID>
<_>996.79</_>
</array_element>
</BalanceHoldings>
<Timestamp>2014-04-30T21:51:26Z</Timestamp>
<Ack>Success</Ack>
<CorrelationID>5788f1bca66bc</CorrelationID>
<Errors />
<Version>109</Version>
<Build>10277387</Build>
<any />
</phpresponse>
<soapfault />
</responses>
</data>
</xml>
POST A request overriding a saved request
This method is similar to GET Response from saved request. Its advantage is that it lets you override the saved request in order to alter its values before they are actually sent to the SOAP Web service.
Resource url:
- https://api.wsdlotphp.com/rest/request/v1/send/[API_TOKEN]/[REQUEST_ID][/FULL][RESPONSE_FORMAT]
Parameters:
- API_TOKEN: see General informations > REST Api token
- REQUEST_ID: see General informations > Saved request id
- FULL: allows to indicate if the response must contain the saved request details or not
- RESPONSE_FORMAT: see General informations > Response formats
Example request:
- http://api.wsdltophp.com/rest/request/v1/send/53d5dbf25871fddb417ca10105ee06ba2022f2a2/846.php: the response does not contain the saved request details
- http://api.wsdltophp.com/rest/request/v1/send/53d5dbf25871fddb417ca10105ee06ba2022f2a2/846/1.php: the response does contain the saved request details
POST data:
$posts = array(
'parameters'=>array(
1=>array(
1=>array(
4=>112))),
'soapheaders'=>array(
'mustunderstand'=>array(
1=>1)),
'soapoptions'=>array(
'wsdl_url'=>__DIR__ . '/../../wsdl/112.0/PayPalSvc.wsdl'),
'httpheaders'=>array(
'name'=>array(
'X-FROM',
'X-TO'),
'value'=>array(
'ME',
'YOU')));
$url = 'https://api.wsdltophp.com/rest/request/v1/send/53d5dbf25871fddb417ca10105ee06ba2022f2a2/846/1.php';
$http = new HttpRequest($url,HTTP_METH_POST);
$http->setPostFields($posts);
$data = $http->send();
print_r(unserialize($data->body));
Example response (full response):
a:5:{
s:10:"error_code";i:0;
s:5:"error";b:0;
s:12:"error_reason";N;
s:13:"output_format";s:3:"php";
s:4:"data";a:3:{
s:8:"soapcall";a:7:{
s:2:"id";s:3:"846";
s:5:"title";s:45:"Request sent on 13 February 2014 at 22h58m46s";
s:11:"description";s:73:"Call of PayPalServiceGet::GetBalance, nouvelle version PSR-2 de WsdlToPhp";
s:7:"created";s:10:"1392328700";
s:11:"packagename";s:6:"PayPal";
s:11:"servicename";s:16:"PayPalServiceGet";
s:10:"methodname";s:10:"GetBalance";
}
s:8:"requests";a:4:{
s:11:"soapoptions";a:2:{
s:8:"wsdl_url";s:49:"https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl";
s:8:"location";s:30:"https://api-3t.paypal.com/2.0/";
}
s:11:"soapheaders";a:6:{
s:9:"namespace";a:1:{
i:1;s:22:"urn:ebay:api:PayPalAPI";
}
s:4:"name";a:1:{
i:1;s:20:"RequesterCredentials";
}
s:14:"mustunderstand";a:1:{
i:1;s:1:"0";
}
s:5:"actor";a:1:{
i:1;s:0:"";
}
s:9:"data_type";a:1:{
i:1;s:36:"PayPalStructCustomSecurityHeaderType";
}
s:4:"data";a:1:{
i:1;a:3:{
i:1;s:0:"";
i:2;s:0:"";
i:3;a:8:{
i:1;s:0:"";
i:2;s:0:"";
i:3;s:0:"";
i:4;s:26:"************************";
i:5;s:16:"************************";
i:6;s:56:"************************************************";
i:7;s:0:"";
i:8;s:0:"";
}
}
}
}
s:11:"httpheaders";a:2:{
s:4:"name";a:1:{
i:0;s:0:"";
}
s:5:"value";a:1:{
i:0;s:0:"";
}
}
s:10:"parameters";a:1:{
i:1;a:1:{
i:1;a:5:{
i:1;s:1:"1";
i:2;s:15:"VALUE_RETURNALL";
i:3;s:0:"";
i:4;s:3:"112";
i:5;s:0:"";
}
}
}
}
s:9:"responses";a:7:{
s:10:"xmlrequest";s:885:"<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:ebay:apis:eBLBaseComponents" xmlns:ns2="urn:ebay:api:PayPalAPI">
<SOAP-ENV:Header>
<ns2:RequesterCredentials>
<ns1:Credentials>
<ns1:Username>************************</ns1:Username>
<ns1:Password>************************</ns1:Password>
<ns1:Signature>************************************************</ns1:Signature>
</ns1:Credentials>
</ns2:RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns2:GetBalanceReq>
<ns2:GetBalanceRequest>
<ns1:DetailLevel>ReturnAll</ns1:DetailLevel>
<ns1:Version>109</ns1:Version>
<ns2:ReturnAllCurrencies>1</ns2:ReturnAllCurrencies>
</ns2:GetBalanceRequest>
</ns2:GetBalanceReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>";
s:11:"xmlresponse";s:2036:"<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ed="urn:ebay:apis:EnhancedDataTypes" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI">
<SOAP-ENV:Header>
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
<Username xsi:type="xs:string"/>
<Password xsi:type="xs:string"/>
<Signature xsi:type="xs:string"/>
<Subject xsi:type="xs:string"/>
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body id="_0">
<GetBalanceResponse xmlns="urn:ebay:api:PayPalAPI">
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2014-04-30T22:03:25Z</Timestamp>
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Success</Ack>
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">bf94944050c34</CorrelationID>
<Version xmlns="urn:ebay:apis:eBLBaseComponents">109</Version>
<Build xmlns="urn:ebay:apis:eBLBaseComponents">10277387</Build>
<Balance xsi:type="cc:BasicAmountType" currencyID="EUR">996.79</Balance>
<BalanceTimeStamp xsi:type="xs:dateTime">2014-04-30T22:03:25Z</BalanceTimeStamp>
<BalanceHoldings xsi:type="cc:BasicAmountType" currencyID="EUR">996.79</BalanceHoldings>
</GetBalanceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>";
s:17:"httpheaderrequest";a:6:{
s:4:"Host";s:17:"api-3t.paypal.com";
s:10:"Connection";s:10:"Keep-Alive";
s:10:"User-Agent";s:14:"PHP-SOAP/5.3.5";
s:12:"Content-Type";s:23:"text/xml; charset=utf-8";
s:10:"SOAPAction";s:2:"""";
s:14:"Content-Length";s:3:"770";
}
s:18:"httpheaderresponse";a:5:{
s:4:"Date";s:29:"Wed, 30 Apr 2014 22:03:25 GMT";
s:6:"Server";s:6:"Apache";
s:14:"Content-Length";s:4:"1940";
s:10:"Connection";s:5:"close";
s:12:"Content-Type";s:23:"text/xml; charset=utf-8";
}
s:10:"phprequest";a:1:{
i:0;O:25:"PayPalStructGetBalanceReq":6:{
s:17:"GetBalanceRequest";O:33:"PayPalStructGetBalanceRequestType":10:{
s:19:"ReturnAllCurrencies";s:1:"1";
s:11:"DetailLevel";s:9:"ReturnAll";
s:13:"ErrorLanguage";N;
s:7:"Version";s:3:"109";
s:3:"any";N;
s:23:"PayPalWsdlClassresult";N;
s:26:"PayPalWsdlClasslastError";a:0:{}
s:37:"PayPalWsdlClassinternArrayToIterate";N;
s:44:"PayPalWsdlClassinternArrayToIterateIsArray";N;
s:43:"PayPalWsdlClassinternArrayToIterateOffset";N;
}
s:23:"PayPalWsdlClassresult";N;
s:26:"PayPalWsdlClasslastError";a:0:{}
s:37:"PayPalWsdlClassinternArrayToIterate";N;
s:44:"PayPalWsdlClassinternArrayToIterateIsArray";N;
s:43:"PayPalWsdlClassinternArrayToIterateOffset";N;
}
}
s:11:"phpresponse";O:34:"PayPalStructGetBalanceResponseType":14:{
s:7:"Balance";O:27:"PayPalStructBasicAmountType":7:{
s:10:"currencyID";s:3:"EUR";
s:1:"_";s:6:"996.79";
s:23:"PayPalWsdlClassresult";N;
s:26:"PayPalWsdlClasslastError";N;
s:37:"PayPalWsdlClassinternArrayToIterate";N;
s:44:"PayPalWsdlClassinternArrayToIterateIsArray";N;
s:43:"PayPalWsdlClassinternArrayToIterateOffset";N;
}
s:16:"BalanceTimeStamp";s:20:"2014-04-30T22:03:25Z";
s:15:"BalanceHoldings";a:1:{
i:0;O:27:"PayPalStructBasicAmountType":7:{
s:10:"currencyID";s:3:"EUR";
s:1:"_";s:6:"996.79";
s:23:"PayPalWsdlClassresult";N;
s:26:"PayPalWsdlClasslastError";N;
s:37:"PayPalWsdlClassinternArrayToIterate";N;
s:44:"PayPalWsdlClassinternArrayToIterateIsArray";N;
s:43:"PayPalWsdlClassinternArrayToIterateOffset";N;
}
}
s:9:"Timestamp";s:20:"2014-04-30T22:03:25Z";
s:3:"Ack";s:7:"Success";
s:13:"CorrelationID";s:13:"bf94944050c34";
s:6:"Errors";N;
s:7:"Version";s:3:"112";
s:5:"Build";s:8:"10277387";
s:23:"PayPalWsdlClassresult";N;
s:26:"PayPalWsdlClasslastError";N;
s:37:"PayPalWsdlClassinternArrayToIterate";N;
s:44:"PayPalWsdlClassinternArrayToIterateIsArray";N;
s:43:"PayPalWsdlClassinternArrayToIterateOffset";N;
}
s:9:"soapfault";s:0:"";
}
}
}