An API for my API?
Tags: machinelearning, passport, api
Published: 2020-10-09 20:41:50

---
title: An API for my API?
published: true
description: 
tags: MachineLearning, Passport, API
//cover_image: https://direct_url_to_image.jpg
canonical_url: https://mindee.com/blog/api-my-api
---
<h1>Please Add Your API<!-- wp:paragraph --></h1>

<p>Last weekend, the kids and I hopped into the car for a long day trip. I drove the car a few hours south to Folkestone, UK. We had our passports examined, and after a short wait, I drove our car onto a train. While we were still inside the car. 30 minutes later, the train stopped in Calais, and we were in France.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>The service is called Eurotunnel, and it is an easy way to get your right hand drive car to Europe, and drive on the right side of the road (or left hand drive car to drive on the left side in the UK).</p>

<p><!-- /wp:paragraph --><!-- wp:image {"id":2310,"sizeSlug":"large"} --></p>

<p><img alt="" src="https://dougsillarsblog.files.wordpress.com/2020/09/img20200919135709.jpg?w=1024" style="height:375px; width:500px" /></p>

<p>Leaving the Eurotunnel train. Photo by my daughter.</p>

<p><!-- /wp:image --><!-- wp:paragraph --></p>

<p>In our case, we literally drove 2 roundabouts, and then took the train back to the UK (its a strange visa thing, probably better that you don&#39;t ask :))</p>

<p><!-- /wp:paragraph --><!-- wp:heading --></p>

<h2>What does any of this have to do with APIs?</h2>

<p><!-- /wp:heading --><!-- wp:paragraph --></p>

<p>Boy, I&#39;m glad you asked, but I was getting there... really.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>When you book a trip on the Eurotunnel, you head over to Eurotunnel.com, and enter your travel dates, and your car&#39;s license plate. They use an API to lookup the make and model of your car - so that they can establish the cost for you to travel. (We have a large van, so we had to go in the oversized car section). <strong>See, there. I talked about an API!</strong></p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>You pick your dates, and your departure times - just like choosing a flight (remember when we could book a flight and take a holiday?). You see the price, enter your card number, and you end up on a success page! Hooray, you&#39;re heading to France!</p>

<p><!-- /wp:paragraph --><!-- wp:heading --></p>

<h2>Not so fast</h2>

<p><!-- /wp:heading --><!-- wp:paragraph --></p>

<p>A bit later, you check your email, and you see your confirmation email from Eurotunnel. At the top, it tells you about the times and that you need to get to the terminal 45 minutes before departure....blah blah blah. There&#39;s a section on traveling during Coronavirus - which you might glance at.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>If you&#39;re still in the email, but before you get to the &quot;follow Eurotunnel on Twitter&quot; button, there was a section that drew my attention:</p>

<p><!-- /wp:paragraph --><!-- wp:image {"id":2313,"sizeSlug":"large"} --></p>

<p><img alt="" src="https://dougsillarsblog.files.wordpress.com/2020/09/image-2.png?w=1024" style="height:207px; width:500px" /></p>

<p><!-- /wp:image --><!-- wp:paragraph --></p>

<p>&nbsp;</p>

<p><!-- /wp:paragraph --><!-- wp:heading --></p>

<h2>Ensure your API is Complete</h2>

<p><!-- /wp:heading --><!-- wp:paragraph --></p>

<p>Oh - like an <a href="https://swagger.io/solutions/getting-started-with-oas/">Open API Specification</a> - make sure that my API is complete... Then I remember that I am not reading an industry e-mail, I&#39;m reading my travel itinerary to take a train with my car.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>&quot;If you do not supply your API before travel&quot; - that seems oddly specific. Again, I bet most people do not have their own API.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>&quot;Add an API to your booking&quot;. Is this like a hackathon challenge? Will Eurotunnel refund some of my ticket if I build something cool? Alright - I&#39;m actually going to click that link!!</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>I land on a webpage that reads like like weird and demented developer clickbait.</p>

<p><!-- /wp:paragraph --><!-- wp:image {"id":2317,"sizeSlug":"large"} --></p>

<p><img alt="" src="https://dougsillarsblog.files.wordpress.com/2020/09/screenshot-2020-09-24-at-13.02.51.png?w=1024" style="height:121px; width:500px" /></p>

<p><!-- /wp:image --><!-- wp:paragraph --></p>

<p><strong>Need help populating your API</strong> - yes! yes I do! Are you going to provision some awesome API tokens or something?</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p><strong>API just got easier</strong> Awesome. Is there like a Zapier integration that I can leverage to connect your API? Will you help me become RESTful?</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>&nbsp;</p>

<p><!-- /wp:paragraph --><!-- wp:heading --></p>

<h2>Yeah, it is way less cool than that</h2>

<p>&nbsp;</p>

<p><!-- /wp:heading --><!-- wp:paragraph --></p>

<p>For developers, API means Application Programming Interface. What Eurotunnel really wanted was:</p>

<p><!-- /wp:paragraph --><!-- wp:image {"id":2319,"sizeSlug":"large"} --></p>

<p><img alt="" src="https://dougsillarsblog.files.wordpress.com/2020/09/screenshot-2020-09-24-at-12.57.20.png?w=1024" style="height:332px; width:500px" /></p>

<p><!-- /wp:image --><!-- wp:paragraph --></p>

<p>Advance Passenger Information? Lame.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>The above screenshot (with the happy green checkbox) is what it looks like <strong>AFTER</strong> you add your API. Beforehand, all the text is red, with a pink background, and it warns you that without adding your API, you might not get past the ticket booth, or that the border control might not let you on the train.. Or that they&#39;ll let you on the train, but never let you off.... I don&#39;t remember all of the details, but there were dire consequences.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>Needless to say, I provided my API. And it turns out, all they wanted was the information from my passport.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>First Name, Surname, Nationality,</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>passport number,</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>Date of Birth,</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>Passport Expiration.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>You know, the stuff we used to fill out on travel booking websites, back when we could travel internationally.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>&nbsp;</p>

<p><!-- /wp:paragraph --><!-- wp:heading --></p>

<h2>This got me thinking</h2>

<p><!-- /wp:heading --><!-- wp:paragraph --></p>

<p>If you&#39;ve ever applied for a job online, you know that you upload your resume, and the website scans all the text and autofills your name, address, email, and all your experience in a long form that you can then submit to a mailbox that nobody monitors.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>It&#39;s kind of cool that computers can read your whole resume and then ignore you.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>But why can&#39;t airlines (or the Eurotunnel) take a picture of my passport and extract all this standard passport data for me (and my kids)? Why did I fill out an online form for every flight (for for everyone traveling), when just uploading an image could have accomplished exactly the same thing?</p>

<p><!-- /wp:paragraph --><!-- wp:heading --></p>

<h2>The Passport API exists</h2>

<p><!-- /wp:heading --><!-- wp:paragraph --></p>

<p><a href="http://Mindee.com">Mindee.com</a> has a passport extraction API. There is a tutorial on how to use it on their website (and if you sign up, there is a live demo that you can test for free. Basically, you upload a photo of your passport photo page to their API endpoint, and it will extract all the information you want into a JSON object.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>The algorithm also gives you bounding boxes around the location of the information, allowing you to build images like this (this is the live demo on the API page):</p>

<p><!-- /wp:paragraph --><!-- wp:image {"id":2325,"sizeSlug":"large"} --></p>

<p><img alt="" src="https://dougsillarsblog.files.wordpress.com/2020/09/image-3.png?w=1024" style="height:355px; width:500px" /></p>

<p>This is a fake passport.</p>

<p><!-- /wp:image --><!-- wp:paragraph --></p>

<p>You also get a nice form with all of the extracted fields:</p>

<p><!-- /wp:paragraph --><!-- wp:image {"id":2326,"sizeSlug":"large"} --></p>

<p><img alt="" src="https://dougsillarsblog.files.wordpress.com/2020/09/image-4.png?w=940" style="height:354px; width:500px" /></p>

<p>Country, passport number and name - all extracted automatically from the image.</p>

<p><!-- /wp:image --><!-- wp:heading --></p>

<h2>An API for my API!</h2>

<p><!-- /wp:heading --><!-- wp:paragraph --></p>

<p>Perhaps my family travels more than average, but I have images saved of all of my family member&#39;s passports on my computer. Imagine how easy check-in would be if I could just upload 6 images, and the website could fill in all the passport dates (issue, expiration, birthdate) passport number and name for each traveller.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>There would probably be fewer errors for Eurotunnel, and it would be a lot faster and easier for their users.</p>

<p><!-- /wp:paragraph --><!-- wp:paragraph --></p>

<p>Then I thought...what if all the airlines did this? Give people an option. &quot;Fill in this form, or upload a picture of your passport&quot; (Kind of sounds like how you might apply for a job on LinkedIn, amirite?) It would make the whole process easier for customers!</p>

<p><!-- /wp:paragraph --><!-- wp:quote --></p>

<blockquote>
<p>ProTip: Ryanair- you could even offer automatic passport upload as an &quot;add-on&quot; (For &euro;1.50 per traveller, would you like to upload your passport rather than enter the values manually?)</p>
</blockquote>

<p><!-- /wp:quote --><!-- wp:heading --></p>

<h2>Manual Data Entry Sucks</h2>

<p><!-- /wp:heading --><!-- wp:paragraph --></p>

<p>Why doesn&#39;t EVERY travel company in the world offer this? It is not a security thing - many passport control gates look at the passport photo and decide if you are automatically allowed into the country or not. This should be a no-brainer for EVERY travel site in the world.</p>

<p><!-- /wp:paragraph --><!-- wp:heading --></p>

<h2>Conclusion</h2>

<p><!-- /wp:heading --><!-- wp:paragraph --></p>

<p>My initial joking about using APIs for passport data entry let me to look for an API that can actually parse passport data automatically. I found Mindee&#39;s and found it very easy to implement. Solutions like this will make check-in process faster, have fewer errors, and easier for customers. I cannot wait to see it in service in 2021, the next time I plan to travel internationally.</p>

<p><!-- /wp:paragraph --></p>