API End Points
End Point
The MarketHub API is built on the MVC WebAPi. Authenticated users can interact with any of our URIs by using
the specified HTTP request method. We recommend using SSL encryption by making requests through HTTPS and as a result
is compulsory. All standard HTTP requests will be redirected to the HTTPS counterpart.
The base url endpoint for the this API instance is as shown below.
EndPoint URL
https://madic-esl.markethubpulse.com/api/Authentication
All requests to MarketHubs’s API requires authentication. The API uses basic autentication so you must send the correct HTTP header endocded with the correct credentials.The authenthication process requires the http header to be configured for basic authentication and the
credentials must be seperated by a ':' and base 64 encoded.
For example, an API with the user account 'testuser' and the password 'testpassword' would need to be encoded
from "testuser:testpassword". The basic-64 encocding for this string is "dGVzdHVzZXI6dGVzdHBhc3N3b3Jk". The resulting
HTTP header would be as shown below.
Authorisation: Basic dGVzdHVzZXI6dGVzdHBhc3N3b3Jk
It is however not recommended that you calculate the base encoding and hardcode the credentials into your client application.The crednetials should be encrypted and encoded as the requests are made.
Most development languages will have base64 encoding functionality and the ability to send HTTP Requests.
An example of the preperation of an HTTP request in C# using the previous credentials is as follows:
string credentials = "testuser:testpassword";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://madic-esl.markethubpulse.com/api/");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
var byteArray = Encoding.ASCII.GetBytes(rawCredentials);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
HttpResponseMessage actionResponse = await client.GetAsync("SampleApiUrl");
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://madic-esl.markethubpulse.com/api/");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
var byteArray = Encoding.ASCII.GetBytes(rawCredentials);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
HttpResponseMessage actionResponse = await client.GetAsync("SampleApiUrl");
