Home > Uncategorized > Irish Company search #API example in C#

Irish Company search #API example in C#

logo-Companies-Registration-OfficeLike the UK’s companies house, you can access basic information about Irish companies using an API that is free to use (mostly), and quite easy to implement.

I say mostly, because unlike the UK version, they charge €2.50 for document downloads.

Here’s the code example (without my credentials) in c#

var strUrl = “https://services.cro.ie/cws/companies?company_num=389820&htmlEnc=1”;

string userName = “** An email address **”;
string password = “**A GUID**”;
WebClient client = new WebClient();
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(userName + “:” + password));
client.Headers[HttpRequestHeader.Authorization] = string.Format(“Basic {0}”, credentials);
client.Headers[HttpRequestHeader.Accept] = “application/json”;
string strJson = “”;
try
{
strJson = client.DownloadString(strUrl);
}
catch (WebException exception)
{

if (exception.Response != null)
{
var responseStream = exception.Response.GetResponseStream();

if (responseStream != null)
{
using (var reader = new StreamReader(responseStream))
{
strJson = reader.ReadToEnd();
}
}
}
}

Console.Write(strJson);

Advertisement
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: