Archive
Car Registration API available as a #Go #Package

Following on from my earlier post on making an authenticated HTTP request in GO, I’ve packaged up the code, and published it to github for Go developers to easily import a wrapper for the http://www.vehicleregistrationapi.com API into their GO code.
The Repo lives at https://github.com/infiniteloopltd/GoCarRegistrationAPI
Here’s the documentation if you want to use the code –
GoCarRegistrationAPI
A wrapper for the Car Registration API in Go. To use this package you will need a username and password from http://www.vehicleregistrationapi.com
Usage
package main
import "github.com/infiniteloopltd/GoCarRegistrationAPI"
import "fmt"
func main() {
data := car_registration.Australia_lookup("YHC14Y","NSW","***Your Username***","***Your Password***")
m := data.(map[string]interface{})
//fmt.Printf("%+v", m)
fmt.Println(m["Description"])
}
The methods of car_registration are Australia_lookup, USA_lookup and European_lookup, all methods reuturn an interface{}, which can be cast to a string map as shown above.
Australia_lookup
Australia lookup accepts four parameters, the registration number, the state, and your username and password, in that order.
USA_lookup
USA lookup accepts four parameters, the registration number, the state, and your username and password, in that order.
European_lookup
European lookup accepts four parameters, the endpoint, the registration number, and your username and password, in that order, where the endpoint can be one of:
- Check (UK)
- CheckBelgium
- CheckCroatia
- CheckCzechRepublic
- CheckDenmark
- CheckEstonia
- CheckFinland
- CheckFrance
- CheckHungary
- CheckIndia
- CheckIreland
- CheckItaly
- CheckNetherlands
- CheckNewZealand
- CheckNigeria
- CheckNorway
- CheckPortugal
- CheckRussia
- CheckSlovakia
- CheckSouthAfrica
- CheckSpain
- CheckSriLanka
- CheckSweden
- CheckUAE
Make a #Synchronous #HTTP request in #Swift3

Often you may want to chain HTTP requests in Swift, So, you may want to request something, then wait until that’s finished before doing something else. – for example, you may not want your terminal script to exit before the last HTTP call is made. So cobbling together a few code examples, this is what I came up with
import Foundation
extension URLSession {
func synchronousDataTask(urlrequest: URLRequest) -> (Data?, URLResponse?, Error?) {
var data: Data?
var response: URLResponse?
var error: Error?let semaphore = DispatchSemaphore(value: 0)
let dataTask = self.dataTask(with: urlrequest) {
data = $0
response = $1
error = $2semaphore.signal()
}
dataTask.resume()_ = semaphore.wait(timeout: .distantFuture)
return (data, response, error)
}
}var request = URLRequest(url: URL(string: “http://icanhazip.com”)!)
request.httpMethod = “GET”
let (data, response, error) = URLSession.shared.synchronousDataTask(urlrequest: request)
if let error = error {
print(“Synchronous task ended with error: \(error)”)
}
else {
print(NSString(data: data!, encoding: String.Encoding.utf8.rawValue) ?? “Error”)
}
Make an authenticated #HTTP Get request and parse #JSON in #Golang

Go is a programming language developed by Google, and with a name like that behind it, it’s worth learning a little about it, so, here’s a quick code example that make a HTTP get request, with basic authentication, and parses the response as a Json object.
package main
import “net/http”
import “fmt”
import “io/ioutil”
import “encoding/base64”
import “encoding/json”func basicAuth(username, password string) string {
auth := username + “:” + password
return base64.StdEncoding.EncodeToString([]byte(auth))
}func australia_lookup(registration_number, state, username, password string) interface{} {
url := string(“https://www.regcheck.org.uk/api/json.aspx/CheckAustralia/” + registration_number + “/” + state)
return generic_lookup(url, username, password)
}func usa_lookup(registration_number, state, username, password string) interface{} {
url := string(“https://www.regcheck.org.uk/api/json.aspx/CheckUSA/” + registration_number + “/” + state)
return generic_lookup(url, username, password)
}func european_lookup(endpoint, registration_number, username, password string) interface{} {
url := string(“https://www.regcheck.org.uk/api/json.aspx/” + endpoint + “/” + registration_number)
return generic_lookup(url, username, password)
}func generic_lookup(url, username, password string) interface{} {
var client http.Client
req, err := http.NewRequest(“GET”, url, nil)
req.Header.Add(“Authorization”,”Basic “+basicAuth(username,password))if err != nil {}
resp, err3 := client.Do(req)if err3 != nil {}
defer resp.Body.Close()
if resp.StatusCode == 200 { // OK
bodyBytes, err2 := ioutil.ReadAll(resp.Body)
bodyString := string(bodyBytes)
var data interface{}
json.Unmarshal([]byte(bodyString), &data)
return data
if err2 != nil {}
}
return nil}
func main() {
data := european_lookup(“Check”,”SL14MKM”,”***your username***”,”***your password***”)
m := data.(map[string]interface{})
//fmt.Printf(“%+v”, m)
fmt.Println(m[“Description”])
}
The example uses the RegCheck webservice, so you’ll need a username and password to check this out.
Car Registration API now available as a Crate for #Rust developers
If you program in Rust, then you know just how useful crates are, and how they are an integral part of the language itself.
So to help Rust developers use our API, we’ve wrapped ours up in a Rust Crate that makes it super easy to call our API from your Rust code.
You can find the code documentation here: https://blog.dotnetframework.org/car-registration-api-crate-documentation/
And the link to the crate itself here:
https://crates.io/crates/car_registration
For those interested in seeing how it works under the hood, the GIT repo is public, and you can see that here: https://github.com/infiniteloopltd/RustCrateCarRegistration
Make a get #HTTP Request in #Rust using #Curl

There are plenty of examples of making a HTTP request using Rust online, but so many of them gloss over very important details, like how to import the library you need to make the request, and for a beginner, it’s not really helpful to give a snippet of code without the surrounding instructions. Plus, it appears that perhaps there are different versions of code that just aren’t backwards compatible. This example works on
rustc 1.19.0 (0ade33941 2017-07-17)
If you have a different version, then, I can’t guarantee this works, but try it anyway.
First off, you need to install Cargo, I am using cargo version
cargo 0.20.0 (a60d185c8 2017-07-13)
Create a new cargo project called http by typing
cargo new http — bin
Then edit the cargo.toml file, and add the CURL dependency here;
[dependencies]
curl = “0.2.11”
now, edit the main.rs file, and add this code;
extern crate curl;
use curl::http;
// Thanks to https://github.com/hjr3/rust-get-data-from-url
pub fn main() {let url = “http://icanhazip.com/”;
let resp = http::handle()
.get(url)
.exec()
.unwrap_or_else(|e| {
panic!(“Failed to get {}; error is {}”, url, e);
});if resp.get_code() != 200 {
println!(“Unable to handle HTTP response code {}”, resp.get_code());
return;
}let body = std::str::from_utf8(resp.get_body()).unwrap_or_else(|e| {
panic!(“Failed to parse response from {}; error is {}”, url, e);
});println!(“{}”,body);
}
What this does, is it makes a CURL get HTTP request to http://icanhazip.com/ , which simply returns the IP address of the client (you), and prints it to screen.
To run it, type cargo build, then
./target/debug/http
:::Update:::
Ok, being a bit of a noob here, I have noticed, that this example is quite dated, using CURL version 0.2.11, when the latest is 0.4.8 ; but you have to change the code completely to use version 0.4.8
First, update the cargo.toml to
[dependencies]
curl = “0.4.8”
Then the main.rs to
extern crate curl;
use curl::easy::{Easy, List};
// Capture output into a local `Vec`.
fn main() {
let mut easy = Easy::new();
easy.url(“http://icanhazip.com”).unwrap();let mut html: String = String::new();
{
let mut transfer = easy.transfer();
transfer.write_function(|data| {
html = String::from_utf8(Vec::from(data)).unwrap();
Ok(data.len())
}).unwrap();transfer.perform().unwrap();
};
println!(“{}”,html);
}
Car Registration #API now has a home on #Packagist for #PHP #devs
Packagist is a public repository for composer packages for PHP, and it makes it super easy to load third party PHP code into your application. So, not to be left out of the game, we’ve submitted our package to Packagist. at the url below
https://packagist.org/packages/infiniteloop/carregistration
You install the package via
composer require infiniteloop/carregistration
Usage
require_once 'vendor/autoload.php'; use carregistration\carregistration; $conv = new carregistration; $json = $conv->lookup('***your username***','CheckUSA','H84jae','nj'); print_r($json->Description);
Parameters
The function “lookup” returns an associative array that differs by country, but maintains consistency where possible. It accepts four parameters, being username, endpoint, registration number and state, in that order.
The username is that which is used on www.vehicleregistrationapi.com
The endpoint specifies the country to be searched, and must be one of the following.
- Check (UK)
- CheckBelgium
- CheckCroatia
- CheckCzechRepublic
- CheckDenmark
- CheckEstonia
- CheckFinland
- CheckFrance
- CheckHungary
- CheckIndia
- CheckIreland
- CheckItaly
- CheckNetherlands
- CheckNewZealand
- CheckNigeria
- CheckNorway
- CheckPortugal
- CheckRussia
- CheckSlovakia
- CheckSouthAfrica
- CheckSpain
- CheckSriLanka
- CheckSweden
- CheckUAE
- CheckUSA
- CheckAustralia
The state parameter is only used for USA and Australia, and can be left empty for all other countries.
Car Registration #API now available as #Python #Package (#Egg)

CarRegistration
This is an API Wrapper for Python for the VehicleRegistrationApi.com API which allows you to get car data from it’s number plate in many countries across the globe, from the USA, Europe, Australia, and Africa.
An account username and password is required from VehicleRegistrationApi.com
When using the Generic “CarRegistration” function, the fourth parameter is an API endpoint, which can be one of;
- Check (UK)
- CheckBelgium
- CheckCroatia
- CheckCzechRepublic
- CheckDenmark
- CheckEstonia
- CheckFinland
- CheckFrance
- CheckHungary
- CheckIndia
- CheckIreland
- CheckItaly
- CheckNetherlands
- CheckNewZealand
- CheckNigeria
- CheckNorway
- CheckPortugal
- CheckRussia
- CheckSlovakia
- CheckSouthAfrica
- CheckSpain
- CheckSriLanka
- CheckSweden
- CheckUAE
For Australia and USA, you must also pass a state parameter, and therefore you must use the CarRegistrationUSA or CarRegistrationAustralia methods.
Installation
easy_install CarRegistration
Usage (UK)
from CarRegistration import *
CarRegistration("BL64JTZ","***YOUR USERNAME***","***YOUR PASSWORD***","Check")
Usage (France)
from CarRegistration import *
CarRegistration("Eg258ma","***YOUR USERNAME***","***YOUR PASSWORD***","CheckFrance")
Usage (USA)
from CarRegistration import *
CarRegistrationUSA("H84jae","nj","***YOUR USERNAME***","***YOUR PASSWORD***")
Usage (Australia)
from CarRegistration import *
CarRegistrationAustralia("YHC14Y","NSW","***YOUR USERNAME***","***YOUR PASSWORD***")
Sample output
{u'RegistrationYear': u'2015', u'CarModel': {u'CurrentTextValue': u'208'}, u'NumberOfDoors': {u'CurrentTextValue': u'3'}, u'EngineSize': {u'CurrentTextValue': u'1397
And here’s the source code for those interested:
import urllib2, base64, json
def CarRegistration(registrationNumber, username, password):
request = urllib2.Request(“http://www.regcheck.org.uk/api/json.aspx/Check/” + registrationNumber)
base64string = base64.encodestring(‘%s:%s’ % (username, password)).replace(‘\n’, ”)
request.add_header(“Authorization”, “Basic %s” % base64string)
result = urllib2.urlopen(request)
data = json.load(result)
return(data)
Our APIs are now on #RubyGems to help Ruby developers get started quickly

We’re now on RubyGems.org at https://rubygems.org/profiles/fiach – with a total of 25 Ruby Gems to be installed. They make using our Car Registration API’s Really easy to use for Ruby Developers
Just type:
gem install CarRegistrationUKirb
(Replacing “UK” with any other country we support)
Then, type;
require(“CarRegistrationUK”)
data = CarRegistrationUK.Lookup(“SL14MKM”,”**username**”,”**password**”)
- Obviously, you need to get your own username and password from RegCheck.org.uk – and SL14MKM is just a sample plate.
And get an object array back such as;
{“ABICode”=>”18503204”,
“Description”=>”2014 Ford Mondeo Titanium X Business Edit Tdci 140, 1997CC Diesel, 5DR, Manual”,
“RegistrationYear”=>”2014”,
“CarMake”=>{“CurrentTextValue”=>”Ford”},
“CarModel”=>{“CurrentTextValue”=>”Mondeo”},
“EngineSize”=>{“CurrentTextValue”=>”1997CC”},
“FuelType”=>{“CurrentTextValue”=>”Diesel”},
“MakeDescription”=>”Ford”,
“ModelDescription”=>”Mondeo”,
“Immobiliser”=>{“CurrentTextValue”=>””},
“NumberOfSeats”=>{“CurrentTextValue”=>5},
“IndicativeValue”=>{“CurrentTextValue”=>””},
“DriverSide”=>{“CurrentTextValue”=>”RHD”},
“Transmission”=>{“CurrentTextValue”=>”Manual”},
“NumberOfDoors”=>{“CurrentTextValue”=>”5”},
“ImageUrl”=>”http://www.regcheck.org.uk/image.aspx/@Rm9yZCBNb25kZW8=”,
“VehicleInsuranceGroup”=>”19”}
You can access any property of this like so
data[“Description”]
Giving –
“2014 Ford Mondeo Titanium X Business Edit Tdci 140, 1997CC Diesel, 5DR, Manual”
For those interested in looking under the hood, here is the source code of the Ruby Gem itself ;
require “open-uri”
require “json”class CarRegistrationLookupError < StandardError def initialize(msg=”Unknown error”) super end end class CarRegistrationUK def self.Lookup(registrationNumber,username,password) begin @data = open(“https://www.regcheck.org.uk/api/json.aspx/Check/” + registrationNumber,http_basic_authentication: [username, password]).read rescue OpenURI::HTTPError => error
raise CarRegistrationLookupError, error.io.string
end
return JSON.parse(@data)
end
end
#Nigerian Car Registration #API

Nigeria, home to 186 million people, and 10 million cars is the newest country to be added to our growing coverage of car registration APIs, and it’s accessible via http://ng.carregistrationapi.com/
It’s our third country in the Middle East / Africa continent to be added to our network, after UAE and South Africa, and we hope to add more in the coming months.
Prices start at 7 Naira per lookup, 0.02 USD – but we’re happy to offer introductory free credits for new companies for the next few months.
#AvatarAPI is now on #NPM for #NodeJS users

Let’s face it, not all your users bother with uploading a photo of themselves on your website, but it looks bland and boring when you just assign everyone with a placeholder image. AvatarAPI allows you get the real name and profile picture of your users from their email address. Great for giving that splash of colour and friendliness to your website.
We’ve just created an NPM package for the Avatar API so that NodeJS users can easily import the functionality into their apps.
Installation
Usage
