Introduction
This is the documentation for Eber APIReturn Format
All data returned will be in JSON format
Status Codes
Eber uses HTTP response status codes to report back when an issue was encountered. Below you can find a full table of the codes:
Code | Meaning |
---|---|
200 | Successful |
201 | Successful |
204 | Successful |
400 or greater | Unsuccessful. Check the error format below. |
Errors Format
Errors format as below. All errors is returned inside "error"
{ "error": { "error_1": [ "The last name may only contain letters." ], "error_2": [ "The email format is invalid." ] } }
Example 1
When submitting data for creating/updating
POST /v3/user HTTP/1.1 Host: https://api.eber.co Cache-Control: no-cache Content-Type: application/x-www-form-urlencoded first_name=Tony&last_name=Stark12&email=tony+at+stark+com&display_name=Tony+Stark
Result:
HTTP 400
{ "error": { "last_name": [ "The last name may only contain letters." ], "email": [ "The email format is invalid." ] } }
Example 2
When retrieving/deleting data
GET /v3/user/123 HTTP/1.1 Host: https://api.eber.co Cache-Control: no-cache Content-Type: application/x-www-form-urlencoded
Result:
HTTP Status: 404
{ "error": { "exception": [ "The requested resource was not found." ] } }
Example in PHP
$username = ''; //api key $password = ''; // leave empty, no password is needed $data = ['display_name' => 'Cid'] $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_URL, 'https://api.eber.co/v3/public/user/1122'); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLINFO_HEADER_OUT, true); $output = curl_exec($ch);
Example in ASP
<% Dim username: username = "" ' api key Dim password: password = "" ' leave empty, no password is needed Dim data: data = "display_name=Cid" Set xmlHttp = Server.Createobject("MSXML2.ServerXMLHTTP") xmlHttp.Open "POST", "https://api.eber.co/v3/user/23", False,username,password xmlHttp.setRequestHeader "User-Agent", "asp httprequest" xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" xmlHttp.Send data responseData = xmlHttp.responseText ' response data response.write(responseData) ' end response data xmlHttp.abort() set xmlHttp = Nothing %>
Example in ASP.NET
GET
string username = ""; // API key string password = ""; // leave empty, no password is needed string url = "https://api.eber.co/v3/public/user/1122"; //this is a working API endpoint WebRequest myReq = WebRequest.Create(url); myReq.Method = "GET"; string usernamePassword = username + ":" + password; UTF8Encoding enc = new UTF8Encoding(); myReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(enc.GetBytes(usernamePassword))); try { // Status 200 WebResponse wr = myReq.GetResponse(); Stream receiveStream = wr.GetResponseStream(); StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8); string content = reader.ReadToEnd(); Response.Write(content); } catch(WebException e) { // Status 404,405,500 using (WebResponse response = e.Response) { HttpWebResponse httpResponse = (HttpWebResponse) response; using (var streamReader = new StreamReader(response.GetResponseStream())) Response.Write(streamReader.ReadToEnd()); } }
POST
string username = ""; // API key string password = ""; // leave empty, no password is needed string url = ""; //replace by API endpoint string data = "display_name=ALEX&phone=91737740&phone_code=SG&business_id=65"; WebRequest myReq = WebRequest.Create(url); myReq.Method = "POST"; myReq.ContentLength = data.Length; myReq.ContentType = "application/x-www-form-urlencoded"; string usernamePassword = username + ":" + password; UTF8Encoding enc = new UTF8Encoding(); myReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(enc.GetBytes(usernamePassword))); using (Stream ds = myReq.GetRequestStream()) { ds.Write(enc.GetBytes(data), 0, data.Length); } try { // Status 200 WebResponse wr = myReq.GetResponse(); Stream receiveStream = wr.GetResponseStream(); StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8); string content = reader.ReadToEnd(); Response.Write(content); } catch(WebException e) { // Status 404,405,500 using (WebResponse response = e.Response) { HttpWebResponse httpResponse = (HttpWebResponse) response; using (var streamReader = new StreamReader(response.GetResponseStream())) Response.Write(streamReader.ReadToEnd()); } }