#Yelp API implemented in C# @yelpdev

September 28, 2016 Leave a comment

yelp

Yelp offer an API that allows you extract their data in JSON format; really cool, and a very useful resource. If you’re using C#, then you can use this code to access it (I’ve removed the access key and client id)

static void Main(string[] args)
{
var strUrl = “https://api.yelp.com/oauth2/token”;

var strPostData = “grant_type=client_credentials”;
strPostData += “&client_id=A-xxxxx”;
strPostData += “&client_secret=xxxxx”;
WebClient wc = new WebClient();
var strResponse = wc.UploadString(strUrl, strPostData);
var login = JavascriptDeserialize<OAuthLogin>(strResponse);

//var strSearch =
// “https://api.yelp.com/v3/businesses/search?term=bar&latitude=51&longitude=0.1&#8221;;

var strSearch = “https://api.yelp.com/v3/businesses/the-crow-and-gate-crowborough&#8221;;
wc.Headers.Add(“Authorization”, “Bearer ” + login.access_token);
var strSearchResponse = wc.DownloadString(strSearch);
}

public static T JavascriptDeserialize<T>(string json)
{
var jsSerializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue };
return jsSerializer.Deserialize<T>(json);
}

public class OAuthLogin
{
public string token_type { get; set; }
public int expires_in { get; set; }
public string access_token { get; set; }
}

Categories: Uncategorized

Use #AI to recognise an image in c# @imagga

September 23, 2016 Leave a comment

download

Being able to tell the difference between an image of a car, and a banana is a ridiculously simple task for a human, but it’s not easy for a computer. Scan the image, and sum the yellow pixels as a percentage of the total pixels, but that doesn’t work on a yellow car, or an unripe banana.

This is where AI comes in, and it’s not just the realm of academia or data scientists any more. Real world business needs this service. Imagine you sell used cars online?, do you check every uploaded image to say it’s actually a car, or pornography?

I came across imagga, which offers a free 2,000 calls / month package. Given an image URL, it returns a list of keywords (tags) and a % confidence in each one. So if I want to check an image is a car, I can look for a tag called “car” and require a confidence > 90%

var strUrl = “http://api.imagga.com/v1/tagging?url=&#8221; + url;
var wc = new WebClient
{
Credentials = new NetworkCredential(“acc_xxxxxxxxxx”, “xxxxxxxxxxxxxxxx”)
};
var strJson = wc.DownloadString(strUrl);
var oRecognise = JavascriptDeserialize<imaggaResults>(strJson);
var carConfidence = oRecognise.results[0].tags.First(o => o.tag == “car”).confidence;
return carConfidence > 90;

With the following ‘helper’ methods

public static T JavascriptDeserialize<T>(string json)
{
var jsSerializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue };
return jsSerializer.Deserialize<T>(json);
}

#region imagga objects
public class Tag
{
public double confidence { get; set; }
public string tag { get; set; }
}

public class imaggaResult
{
public object tagging_id { get; set; }
public string image { get; set; }
public List<Tag> tags { get; set; }
}

public class imaggaResults
{
public List<imaggaResult> results { get; set; }
}
#endregion

Categories: Uncategorized

#Danish Car lookup #SKAT #DMR #API

September 12, 2016 Leave a comment

copenhagen_cnt_30apr10_is_b

We’ve just upgraded our Danish car lookup API at http://dk.registreringsnummerapi.com/ to include a whole host of data from the Denmark’s SKAT DMR Service

Car registration plates in Denmark use the /CheckDenmark endpoint and return the following information:

  • Make and Model
  • Year of Registration
  • VIN number
  • And the table of information below:
Property Meaning
EF-Type-godkendelsenr. EC-Type-godkendelsenr.
Typeanmeldelses-nummer/bremsedata-erklæringsnummer Typeanmeldelses number / brake data Statement Number
Supplerende anvendelser additional applications
Status status
Type Type
EU-variant European variant
EU-version EU version
Kategori Category
Fabrikant Manufacturer
Anmodningsårsag request Cause
Beskrivelse Description
Kilometerstand Mileage
Køretøjes stand vehicle’s condition
KøretøjsID KøretøjsID
Stelnummer tilkoblet sidevogn Chassis number attached sidecar
Farve Colour
Model-år Model-year
1. registreringsdato 1. registration date
Ibrugtagningsdato commissioning Date
Bestået NCAP test med mindst 5 stjerner NCAP passed the test with at least 5 stars
Varevogn 30 procent afgift Van 30 percent charge
Fuelmode Fuel Mode
Vejvenlig luftaf-fjedring Vejvenlig luftaf-spring system
Dokumentation for kilometerstand Documentation for odometer
Bemærkninger for stand Notes for stand
Køretøj stand vehicle condition
Trafikskade traffic Injury
Original veterankøretøj Original vintage vehicle
1- eller 2-zone klima 1- or 2-zone climate
3- eller 4-zone klima 3- or 4-zone climate
Afstandsradar Distance Radar
Aktiv fartpilot active cruise Control
Antal selealarmer Number Belt Alarms
Bakkamera Reversing camera
El-opvarmet forrude Electrically heated windscreen
Elektrisk bagklap Power tailgate
Elektrisk lukning af døre Electrically closing the doors
Head-up display Head-up display
HiFi musikanlæg HiFi sound system
Key-less go (nøglefri) Key-less go (keyless)
Linievogter line Guardian
Manuel Aircondition manual Air Conditioning
Natsyns-udstyr Night Vision Equipment
Navigationssystem med skærm Navigation system with display
Original tyverialarm Original alarm
Parkeringsassistent Park Assist
Parkeringskontrol bag The parking control back
Parkeringskontrol for Parking Control for
Solcellekøling, kabine Solar Cooling, cabin
Stemmestyring Voice control
Vognbaneskift-alarm Lane departure alert
3 el. flere sæderækker 3 el. more rows of seats
Dobbeltkabine double Cab
El-soltag Electric sunroof
Glastag Glass roof
Kurvelys adaptive light
Metalfoldetag RHT
Metallak Metallak
Ombygget karrosseri rebuilt body
Targa Targa
Uden siderude i (varerum) bag førersædet i bilens venstre side Without side pane (load area) behind the driver’s seat in the car’s left side
Xenon forlygter Xenon headlights
6-gear manuel 6-speed manual transmission
ESC stabilitetskontrol ESC stability control
Kompressor Compressor
Motor/kabinevarmer Engine / cab heater
Motornummer engine number
Tunet/anden motor Tuned / second engine
ABS bremser ABS brakes
Keramiske skiver ceramic discs
Skivebremser bag Disc brakes behind
Skivebremser for Disc brakes
Affjedret stel Suspension frame
Elektroniske dæmpere electronic dampers
Luftaffjedring Air suspension
Niveauregulering Levelling
Ombygget stel rebuilt frame
Stift stel rigid frame
Større hjul end 20 Larger wheels than 20
Antal airbags number of airbags
Radio Radio
Automatgear automatic
Firehjulstræk (4WD) All-wheel drive (4WD)
Ratbetjent gear Ratbetjent gear
Del-lædersæder Part-leather seats
El-gardiner i bagdøre Electric blinds in the rear doors
El-gardiner i bagrude Electric curtains in the rear window
El-indstillelige sæder bag El-adjustable seats behind
Faste sidetasker Fixed side bags
Integreret barnesæde Integrated child seat
Læder/skindsæder Leather / leather seats
Massagesæder Massage Seats
Memory-sæder for Memory seats for
Sport-/komfortsæder Sport / comfort seats
Ventilation i sæder Ventilation in seats
El-indstilleligt rat El-adjustable steering wheel
Højrestyring right Management
Lang forgaffel long fork
Multifunktionsrat Multifunctional
Opvarmet rat/styr Heated steering wheel / track
Turbo Turbo
Andet udstyr Other equipment

 

Sample Json:

{“ABICode”:””,”Description”:”VOLKSWAGEN GOLF PLUS 2″,”RegistrationYear”:”2016″,”CarMake”:{“CurrentTextValue”:”VOLKSWAGEN”},”CarModel”:{“CurrentTextValue”:” GOLF PLUS”},”EngineSize”:{“CurrentTextValue”:””},”FuelType”:{“CurrentTextValue”:””},”MakeDescription”:{“CurrentTextValue”:” GOLF PLUS”},”ModelDescription”:{“CurrentTextValue”:” GOLF PLUS”},”Immobiliser”:{“CurrentTextValue”:””},”NumberOfSeats”:{“CurrentTextValue”:””},”IndicativeValue”:{“CurrentTextValue”:””},”DriverSide”:{“CurrentTextValue”:””},”BodyStyle”:{“CurrentTextValue”:””},”VechileIdentificationNumber”:”WVWZZZ1KZAW532291″,”ExtendedInformation”:{“EF-Type-godkendelsenr.”:”e1*2001/116*0304″,”Typeanmeldelses\u0026shy;nummer/bremsedata-erklæringsnummer”:”E51888-08″,”Supplerende anvendelser”:”-“,”Status”:”Registreret (har fået tilknyttet en gyldig registrering)”,”Type”:”1KP”,”EU-variant”:”-“,”EU-version”:”-“,”Kategori”:”-“,”Fabrikant”:”-“,”Anmodningsårsag”:”-“,”Beskrivelse”:”-“,”Kilometerstand”:”-“,”Køretøjes stand”:”-“,”KøretøjsID”:”1027901200913768″,”Stelnummer tilkoblet sidevogn”:”-“,”Farve”:”Ukendt”,”Model-år”:”-“,”1. registreringsdato”:”02-09-2009″,”Ibrugtagningsdato”:”-“,”Bestået NCAP test med mindst 5 stjerner”:”Ja”,”Varevogn 30 procent afgift”:”-“,”Fuelmode”:”-“,”Vejvenlig luftaf\u0026shy;fjedring”:”Nej”,”Dokumentation for kilometerstand”:”-“,”Bemærkninger for stand”:”DMR Konvertering”,”Køretøj stand”:”-“,”Trafikskade”:”-“,”Original veterankøretøj”:”-“,”1- eller 2-zone klima”:”Nej”,”3- eller 4-zone klima”:”Nej”,”Afstandsradar”:”Nej”,”Aktiv fartpilot”:”Nej”,”Antal selealarmer”:”2″,”Bakkamera”:”Nej”,”El-opvarmet forrude”:”Nej”,”Elektrisk bagklap”:”Nej”,”Elektrisk lukning af døre”:”Nej”,”Head-up display”:”Nej”,”HiFi musikanlæg”:”Nej”,”Key-less go (nøglefri)”:”Nej”,”Linievogter”:”Nej”,”Manuel Aircondition”:”Nej”,”Natsyns-udstyr”:”Nej”,”Navigationssystem med skærm”:”Nej”,”Original tyverialarm”:”Nej”,”Parkeringsassistent”:”Nej”,”Parkeringskontrol bag”:”Nej”,”Parkeringskontrol for”:”Nej”,”Solcellekøling, kabine”:”Nej”,”Stemmestyring”:”Nej”,”Vognbaneskift-alarm”:”Nej”,”3 el. flere sæderækker”:”Nej”,”Dobbeltkabine”:”Nej”,”El-soltag”:”Nej”,”Glastag”:”Nej”,”Kurvelys”:”Nej”,”Metalfoldetag”:”Nej”,”Metallak”:”Nej”,”Ombygget karrosseri”:”Nej”,”Targa”:”Nej”,”Uden siderude i (varerum) bag førersædet i bilens venstre side”:”Nej”,”Xenon forlygter”:”Nej”,”6-gear manuel”:”Nej”,”ESC stabilitetskontrol”:”Ja”,”Kompressor”:”Nej”,”Motor/kabinevarmer”:”Nej”,”Motornummer”:”Nej”,”Tunet/anden motor”:”Nej”,”ABS bremser”:”Ja”,”Keramiske skiver”:”Nej”,”Skivebremser bag”:”Nej”,”Skivebremser for”:”Nej”,”Affjedret stel”:”Nej”,”Elektroniske dæmpere”:”Nej”,”Luftaffjedring”:”Nej”,”Niveauregulering”:”Nej”,”Ombygget stel”:”Nej”,”Stift stel”:”Nej”,”Større hjul end 20″:”Nej”,”Antal airbags”:”4″,”Radio”:”Ja”,”Automatgear”:”Nej”,”Firehjulstræk (4WD)”:”Nej”,”Ratbetjent gear”:”Nej”,”Del-lædersæder”:”Nej”,”El-gardiner i bagdøre”:”Nej”,”El-gardiner i bagrude”:”Nej”,”El-indstillelige sæder bag”:”Nej”,”Faste sidetasker”:”Nej”,”Integreret barnesæde”:”0″,”Læder/skindsæder”:”Nej”,”Massagesæder”:”Nej”,”Memory-sæder for”:”Nej”,”Sport-/komfortsæder”:”Nej”,”Ventilation i sæder”:”Nej”,”El-indstilleligt rat”:”Nej”,”Højrestyring”:”Nej”,”Lang forgaffel”:”Nej”,”Multifunktionsrat”:”Nej”,”Opvarmet rat/styr”:”Nej”,”Turbo”:”Nej”,”Andet udstyr”:”-“}

Categories: Uncategorized

#EuroNcap API – European car safety

September 9, 2016 Leave a comment

free-vector-euro-ncap_046874_euro-ncap

The European New Car Assessment Program (Euro NCAP) is a European car safety performance assessment program based in Brussels (Belgium) and founded in 1997 by the Transport Research Laboratory for the UK Department for Transport and backed by several European governments, as well as by the European Union.

We’ve set up a free API for accessing EuroNCAP data in XML format via a SOAP interface here: https://www.regcheck.org.uk/api/bespokeapi.asmx?op=CheckEuroNCap – you’ll need an account on www.regcheck.org.uk – but there’s no cost to use the API.

Here’s the data you can expect back:

<ArrayOfPreAssessmentSearchResult xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns=”http://Regcheck.org.uk/”&gt;
<PreAssessmentSearchResult>
<AdultOccupantStars>4</AdultOccupantStars>
<AdultOccupantStrikeThrough>false</AdultOccupantStrikeThrough>
<ChildOccupantStars>3</ChildOccupantStars>
<ChildOccupantStrikeThrough>false</ChildOccupantStrikeThrough>
<PedestrianStars>1</PedestrianStars>
<PedestrianStrikeThrough>false</PedestrianStrikeThrough>
<Id>15675</Id>
<Title>Mitsubishi Colt (2005)</Title>
<Name>Mitsubishi Colt (2005)</Name>
<Make>Mitsubishi</Make>
<Model>Colt</Model>
<Content>test</Content>
<Url>/results/mitsubishi/colt/15675</Url>
<Year>2005</Year>
<ClassEN>Supermini</ClassEN>
<ClassDE>Kleinstwagen</ClassDE>
<ClassNL>Supermini</ClassNL>
<ClassES>Segmento B</ClassES>
<ClassFR>Citadine</ClassFR>
<ClassIT>Supermini</ClassIT>
<ClassRU>Сверхмалый автомобиль</ClassRU>
<ClassSV>Supermini</ClassSV>
<ClassTR>Supermini</ClassTR>
<ClassZH>微型车</ClassZH>
<ClassId>1202</ClassId>
<MakeImageLarge>

</MakeImageLarge>
<MakeImageSmall>

</MakeImageSmall>
<ProtocolId>14999</ProtocolId>
<MakeId>7302</MakeId>
<ModelId>16055</ModelId>
<IsPublished>true</IsPublished>
<CreateDate>2015-01-29T19:07:15Z</CreateDate>
<ReleaseDate>2015-01-29T19:07:15Z</ReleaseDate>
<Images>

</Images>
<YoutubeVideos>https://www.youtube.com/watch?v=yQ4gAkl8Swk</YoutubeVideos&gt;
<YoukuVideos></YoukuVideos>
<IsPreProtocol>true</IsPreProtocol>
<IsFleet>false</IsFleet>
<SortOrder>166</SortOrder>
<LifecycleStatus>25</LifecycleStatus>
<FirstPublished>2005-11-23T00:00:00Z</FirstPublished>
</PreAssessmentSearchResult>
</ArrayOfPreAssessmentSearchResult>

 

Categories: Uncategorized

Read #Android Play Store data with C# via @appTweak

September 7, 2016 Leave a comment

n9dzneni_400x400

The AppTweak API allows up to 100 queries against the Google Play Store for free. Which is a great free trial. I was looking to import a few apps ad-hoc into http://www.androidappstore.com.cn/en/ – and instead of re-importing the database, this was a handy way.

So, here’s how I did it using C# (I’ve omitted the license key, you can get one yourself!).

WebClient wc = new WebClient();
wc.Headers.Add(“X-Apptweak-Key”, “{{Your Key}}“);
wc.Encoding = Encoding.UTF8;
var strJson = wc.DownloadString(“https://api.apptweak.com/android/applications/uk.org.regcheck.app.json”);
var app = JavascriptDeserialize<RootObject>(strJson);

Note that in the above example uk.org.regcheck.app is the package name of the app.

The JavascriptDeserialize function is defined as follows, – it converts the JSON to a strongly typed object

public static T JavascriptDeserialize<T>(string json)
{
var jsSerializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue };
return jsSerializer.Deserialize<T>(json);
}

Then “RootObject”, and it’s members are defined as follows;

public class Developer
{
public string name { get; set; }
public string email { get; set; }
public string website { get; set; }
}

public class Version
{
public string version { get; set; }
public string release_notes { get; set; }
public string release_date { get; set; }
}

public class Current
{
public string discovered_at { get; set; }
public string confirmed_at { get; set; }
public int data { get; set; }
}

public class History
{
public string discovered_at { get; set; }
public string confirmed_at { get; set; }
public int data { get; set; }
}

public class Size
{
public Current current { get; set; }
public List<History> history { get; set; }
}

public class StoreInfo
{
public List<Version> versions { get; set; }
public string icon { get; set; }
public List<string> genres { get; set; }
public string title { get; set; }
public string description { get; set; }
public string short_description { get; set; }
public string price { get; set; }
public List<string> permissions { get; set; }
public List<string> screenshots { get; set; }
public List<object> videos { get; set; }
public Size size { get; set; }
public string slug { get; set; }
}
public class Ratings
{
public double average { get; set; }
public int count { get; set; }

}

public class Us
{
public string en { get; set; }
}

public class Gb
{
public string en { get; set; }
}

public class AppInfoUpdater
{
public Us us { get; set; }
public Gb gb { get; set; }
}

public class RobotsRunTime
{
public AppInfoUpdater app_info_updater { get; set; }
}

public class SchemaVersion
{
public int app_info_updater { get; set; }
}

public class Content
{

public string application_id { get; set; }
public Developer developer { get; set; }
public StoreInfo store_info { get; set; }
public Ratings ratings { get; set; }
public RobotsRunTime _robots_run_time { get; set; }
public SchemaVersion _schema_version { get; set; }
public List<object> reviews { get; set; }
public List<object> rankings { get; set; }
public List<object> country_rankings { get; set; }
public string country_code { get; set; }
public string language { get; set; }
}

public class Params
{
public string country { get; set; }
public string language { get; set; }

public string id { get; set; }
public string format { get; set; }
}

public class Request
{
public string path { get; set; }
public string store { get; set; }
public Params @params { get; set; }
public string performed_at { get; set; }
}

public class Content2
{
}

public class Metadata
{
public Request request { get; set; }
public Content2 content { get; set; }
}

public class RootObject
{
public Content content { get; set; }
public Metadata metadata { get; set; }
}
}

Categories: Uncategorized

UK Car price estimate #API

September 6, 2016 Leave a comment

homepage-image

Want to estimate the price of a UK car from its reg number, then we’ve got an API for that.

https://www.regcheck.org.uk/api/bespokeapi.asmx?op=CheckPrice

You provide it with a number plate, mileage and a username from RegCheck.org.uk In return you get a description of the car and the min and max price that can be expected of a private sale.

<ArrayOfNameValue xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=”http://www.w3.org/2001/XMLSchema xmlns=”http://Regcheck.org.uk/>
<NameValue>
<Name>Description</Name>
<Value>FORD KUGA DIESEL ESTATE</Value>
</NameValue>
<NameValue>
<Name>MinPrice</Name>
<Value>8500</Value>
</NameValue>
<NameValue>
<Name>MaxPrice</Name>
<Value>9100</Value>
</NameValue>
</ArrayOfNameValue>

 

Categories: Uncategorized

WMI Code allocations by city #database

September 2, 2016 Leave a comment

The first three characters uniquely identify the manufacturer of the vehicle using the World Manufacturer Identifier or WMI code. A manufacturer that builds fewer than 900 vehicles per year uses a 9 as the third digit and the 12th, 13th and 14th position of the VIN for a second part of the identification. Some manufacturers use the third character as a code for a vehicle category (e.g., bus or truck), a division within a manufacturer, or both. For example, within 1G (assigned to General Motors in the United States), 1G1 represents Chevrolet passenger cars; 1G2, Pontiac passenger cars; and 1GC, Chevrolet trucks.

 

You can download this database for free from ftp://ftp.nhtsa.dot.gov/manufacture/manufacturer.mdb

Categories: Uncategorized