Archive

Archive for August, 2024

Chinese Vehicle License Plate #API now available

With a database of 16 Million Chinese number plates and associated vehicle details and owners, we’ve launched an API that allows a lookup on this data. This allows you to determine the make, model and owner of a Chinese Vehicle from it’s license plate, assuming it’s found in our database (Which admittedly is only 4% of the vehicles in China).

The website is available here; https://www.chepaiapi.cn/ and we also have offline data available, for analysis for other purposes.

Car registration plates in China use the /CheckChina  endpoint and returns the following information:

  • Make / Model
  • Age
  • Engine Size
  • VIN
  • Owner details
  • Representative image

In China, only 4% of all vehicles are covered by our database, therefore most searches will not return data, there is no charge for a failed search.

Sample Registration Number: 

浙GCJ300

Sample Json:

{
  "Description": "haima Family",
  "RegistrationYear": "2004",
  "CarMake": {
    "CurrentTextValue": "haima"
  },
  "CarModel": {
    "CurrentTextValue": "Family"
  },
  "Variant": "GL New Yue Class",
  "EngineSize": {
    "CurrentTextValue": "1.6L"
  },
  "MakeDescription": {
    "CurrentTextValue": "haima"
  },
  "ModelDescription": {
    "CurrentTextValue": "Family"
  },
  "NumberOfSeats": {
    "CurrentTextValue": 5
  },
  "NumberOfDoors": {
    "CurrentTextValue": 4
  },
  "BodyStyle": "saloon",
  "VIN": "LH17CKJF04H035018",
  "EngineNumber": "ZM",
  "FuelType": {
    "CurrentTextValue": "gasoline"
  },
  "Owner": {
    "Name": "王坚强",
    "Id": "330725197611214838",
    "Address": "义乌市稠城街道殿山村",
    "Tel": "13868977994"
  },
  "Gonggao": "HMC7161",
  "Location": "浙江省金华市",
  "ImageUrl": "http://chepaiapi.cn/image.aspx/@aGFpbWEgRmFtaWx5"
}
Categories: Uncategorized

Tiny C# code to test webhooks with NGrok

TL;DR; Here is the github repo: https://github.com/infiniteloopltd/MiniServer/

If you need to test webhooks, it can be sometimes awkward, since you have to deploy your webhook handling code to a server, and once there, you can’t debug it. Running it on localhost, then the remote service can’t reach it.

This is where NGrok comes in handy, you can use it to expose (Temporarily) a local website – including your webhook handler, and then use the URL from NGgok as the webhook endpoint. Once it’s working locally, you can deploy it to the server, for more testing.

Here I wrote a tiny webserver that just prints to screen what it HTTP posted / Get’d to it,

static void Main(string[] args)
        {
            HttpListener listener = new HttpListener();
            listener.Prefixes.Add("http://localhost:8080/");
            listener.Start();
            Console.WriteLine("Listening for requests on http://localhost:8080/ ...");

            while (true)
            {
                HttpListenerContext context = listener.GetContext();
                HttpListenerRequest request = context.Request;

                // Log the request method (GET/POST)
                Console.WriteLine("Received {0} request for: {1}", request.HttpMethod, request.Url);

                // Log the headers
                Console.WriteLine("Headers:");
                foreach (string key in request.Headers.AllKeys)
                {
                    Console.WriteLine("{0}: {1}", key, request.Headers[key]);
                }

                // Log the body if it's a POST request
                if (request.HttpMethod == "POST")
                {
                    using (var reader = new StreamReader(request.InputStream, request.ContentEncoding))
                    {
                        string body = reader.ReadToEnd();
                        Console.WriteLine("Body:");
                        Console.WriteLine(body);
                    }
                }

                // Respond with a simple HTML page
                HttpListenerResponse response = context.Response;
                string responseString = "<html><body><h1>Request Received</h1></body></html>";
                byte[] buffer = Encoding.UTF8.GetBytes(responseString);
                response.ContentLength64 = buffer.Length;
                Stream output = response.OutputStream;
                output.Write(buffer, 0, buffer.Length);
                output.Close();
            }

Then the server is exposed via NGrok with

ngrok http 8080 --host-header="localhost:8080" 

I’ve tried similar code with CloudFlare tunnels, but it wasn’t as easy to set up as NGrok.

Categories: Uncategorized