1881 Partner Search API
The Partner Search API is a RESTFull service that utilizes the HTTP/GET verb. Parameters are passed in the querystring of the HTTP request. The service can produce both xml and JSON formatted data. The JSON approach is mainly intended for intranet integration, while the xml version is for machine to machine integration.
Search:
Parameter name Mandatory Description
userName Yes The user name assigned to the customer by 1881. password Yes The password assigned to the customer by 1881. msisdn Yes The a-number of the end-user performing the search.
query No The search query. Should be url encoded.
format No Set to “json” for JSON formatted data.
Remove this parameter or set to “xml” for XML formatted data.
level No Defines the amount of data to return.
level=0;minimum amount of data level=1;includes address information
level=2;additional company/person information (lower performance)
catalogueIds No Catalogueid=0; public person listings Catalogueid=1; public company listings Catalogueid=5; internal catalogue
If this is empty, all available catalogues is included the list of id’s is separated by |.
pageSize No Number of hits to return. Maximum value allowed is 300. page No The page to return in the result set. If empty the first
page will be shown.
geoCodes No Geo code pairs separated with |.
Pair is presented in the following way: Latitude:Longitude
Lat/long is encoded like 62.7836 Example:
62.7836:7.367456|62.7346: 5.4736
Invalid formatted geocodes will be ignored.
xmlns No Namespace is by default included in xml format. To
exclude set xmlns=0. Extended parameters for advanced search:
firstName No FirstName. Should be url encoded.
lastName No LastName/CompanyName. Should be url encoded.
phone No Phone, mobile, fax. Should be url encoded.
street No Street. Should be url encoded.
postalCode No PostalCode. Should be url encoded.
postalArea No PostalArea. Should be url encoded.
Sørlandet. Should be url encoded. municipality No Municipality. Should be url encoded. Example:
/search?userName=<username>&msisdn=<msisdn>&password=<password>&query=<query>&le vel=0&format=json
Example advanced search:
/search?userName=<username>&msisdn=<msisdn>&password=<password>&firstName=<firstna me>&lastName=<lastname>&postalCode=<postalCode>&level=0&format=json
Details:
If you want to receive a specific resultitem and get more details you can use this one: Parameter name Mandatory Description
userName Yes The user name assigned to the customer by 1881. password Yes The password assigned to the customer by 1881. msisdn Yes The a-number of the end-user performing the search. itemid Yes The result itemid. From resultlist: Results.ResultItem.
ItemId
format No Set to “json” for JSON formatted data.
Remove this parameter or set to “xml” for XML formatted data.
xmlns No Namespace is by default included in xml format. To
exclude set xmlns=0. Example:
/search/Details?userName=<username>&msisdn=<msisdn>&password=<password>&itemid=<it emid>&format=json
GetCatalogues:
If you want to receive the catalogues connected to the user you can use this one: Parameter name Mandatory Description
userName Yes The user name assigned to the customer by 1881. password Yes The password assigned to the customer by 1881. msisdn Yes The a-number of the end-user performing the search.
format No Set to “json” for JSON formatted data.
Remove this parameter or set to “xml” for XML formatted data.
xmlns No Namespace is by default included in xml format. To
exclude set xmlns=0. Example:
/search/GetCatalogues?userName=<username>&msisdn=<msisdn>&password=<password>&for mat=json
Search result
Field name Description
StatusMessage Contains an error message if the search fails, otherwise empty TotalNumberOfResults The number of hits
.net proxy
1881 has developed a proxy for the service with strong typed message classes. The latest proxy can be downloaded from http://api.1881bedrift.no/download/proxy.
const string ApiUrl = "http://test.1881bedrift.pragma.no/api/";
//GetResult - list
var qList = new SearchQuery
{
Msisdn = "########", Password = "******", UserName = "########",
QueryLevel = QueryLevels.Medium, Query = "opplysningen",
PageSize = "5", Page = "1",
IncludedCatalogues = new List<string>() {"0","1"} };
using (var target = new SearchProxy()) {
var result = target.GetResult(new Uri(ApiUrl), qList); //TODO: do something with the result
}
//GetResult - listitem
var qListItem = new SearchQuery
{ Msisdn = "########", Password = "******", UserName = "########", ItemId = "200190583S1" };
using (var target = new SearchProxy()) {
var result = target.GetResult(new Uri(ApiUrl), qListItem); //TODO: do something with the result
}
//GetCatalogues
var qCatalogues = new SearchCataloguesRequest
{
Msisdn = "########", Password = "******", UserName = "########"
};
using (var target = new SearchProxy()) {
var result = target.GetSearchCatalogues(new Uri(ApiUrl), qCatalogues); }
JQuery sample:
<script type="text/javascript" language="javascript">
var userName = "########"; var msisdn = "########"; var password = "*****";
$(document).ready(function () {
//need to user charset=ISO-8859-1 in order to get Norwegian characters correct to the search service.
source: function (request, response) { $.ajax({ contentType: "application/x-www-form-urlencoded;charset=ISO-8859-1", url: GetSearchUrl(), type: "GET", dataType: "json",
success: function (data) { response($.map(data.Results, function (item) {
return { label: GetName(item) + "(" + GetPhone(item) + ")", value: GetName(item), code: GetPhone(item) };
})) }
, error: function (data)
{ $("#Phone")[0].innerText = "an error occurred while reading search service"; } })
},
select: function (data) {
$("#Code").value = data.item; $("#Phone").val(data.item); }, minLength: 1 }) }); function GetName(item) { if (item.CompanyName != null) return item.CompanyName;
return item.FirstName + " " + item.LastName;
}
function GetSearchUrl() {
var data = "/search?userName="
+ userName + "&msisdn=" + msisdn + "&password=" + password + "&query="
+ $.URLEncode($("#QueryBox").val()) + "&level=0&format=json";
$("#SearchUrl")[0].innerText = data; return data;
}
function GetPhone(item) {
if (item.ContactPoints == null) return "";
for (var i = 0; i < item.ContactPoints.length; i++) { if (item.ContactPoints[i].ContactPointType == 2) return item.ContactPoints[i].Address; }
return ""; }
$("#QueryBox").bind("autocompleteselect", function (event, ui) { $("#Code").val(ui.item.label);
$("#Phone")[0].innerText = ui.item.code; });
$.extend({ URLEncode: function (c) {
var o = ''; var x = 0; c = c.toString(); var r = /(^[a-zA-Z0-9_.]*)/; while (x < c.length) {
var m = r.exec(c.substr(x));
if (m != null && m.length > 1 && m[1] != '') { o += m[1]; x += m[1].length;
} else {
if (c[x] == ' ') o += '+'; else {
var d = c.charCodeAt(x); var h = d.toString(16); o += '%' + (h.length < 2 ? '0' : '') + h.toUpperCase(); } x++;
} return o; },
URLDecode: function (s) {
var o = s; var binVal, t; var r = /(%[^%]{2})/;
while ((m = r.exec(o)) != null && m.length > 1 && m[1] != '') { b = parseInt(m[1].substr(1), 16); t = String.fromCharCode(b); o = o.replace(m[1], t); } return o; } }); </script>
Example result set:
<?xml version="1.0"?>
<SearchResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://1881.no/api/PartnerSearch">
<ExtensionData />
<Results>
<ResultItem>
<ExtensionData />
<Addresses />
<BirthDate xsi:nil="true" />
<Collection>B2B</Collection>
<ContactPoints>
<ContactPoint_Search>
<ExtensionData />
<Address>93257288</Address>
<ContactPointType>Landline</ContactPointType>
<IsMain>true</IsMain>
</ContactPoint_Search>
<ContactPoint_Search>
<ExtensionData />
<Address>[email protected]</Address>
<ContactPointType>Email</ContactPointType>
<IsMain>true</IsMain>
</ContactPoint_Search>
<ContactPoint_Search>
<ExtensionData />
<Address>98855641</Address>
<ContactPointType>Mobile</ContactPointType>
<IsMain>true</IsMain>
</ContactPoint_Search>
<ContactPoint_Search>
<ExtensionData />
<Address>www.pragma.no</Address>
<ContactPointType>HomePage</ContactPointType>
<IsMain>true</IsMain>
</ContactPoint_Search>
</ContactPoints>
<FirstName>Jonas</FirstName>
<Gender>Unknown</Gender>
<ItemId>b2b¤5¤103272¤110781</ItemId>
<LastName>Syrstad</LastName>
<ResultType>Person</ResultType>
</ResultItem>
</Results>
<TotalNumberOfResults>1</TotalNumberOfResults> </SearchResponse>
ResultItem enum fields
Field name Values
Addresses.Address_Search .AddressType Visiting, Postal, Billing ContactPoints.ContactPoint_Search. ContactPointType HomePage,
Email, Mobile, Landline, Fax ContactPoints.ContactPoint_Search.IsMain True, False Collection Contacts , B2B
Contacts: collection from 1881.no - Person /1881.no - Company
B2B: collection from catalogues defined in B2B (employee/internal catalogues)
ResultType Person,