Part 16 - Learning API for Beginners

Written by Eric Muss-Barnes, 23 December 2018

The term "API" is an abbreviation for "Application Programming Interface" and is basically a way for a webpage to communicate with some other kind of computer system. The way an API typically works, a company will provide a service you want to implement on your website. That company will have a small snippet of code, their API, which you will integrate into the code of your website.

I know that sounds kind of weird, but when I give you some concrete examples, you will understand it instantly.

For engineers who build an API from scratch, an API is very difficult and complicated. But, for developers like you and I, using an API should be simple. That is the whole point. An API integration is intended to be very easy. If it's really difficult, then it's a poorly written API.

The whole point is that a company is providing a service to you, as a customer, so their API code should be simple to understand, and you integrate their API into your website, to enhance the capabilities of your website. I have used many different API solutions over the years. For example...

While building an order form on a website for a printing company, I used an API from UPS, to calculate shipping charges.

When building a website for California motorcycle gatherings, I used an API from Google Maps, to make a map displaying locations of the events.

During my years working at a real estate investment company, I used an API to display MLS properties, for a real estate office in Colorado.

And for this example, I will show you a simple API from Mailchimp, used to add email addresses onto a mailing list. I am going to base it on the PHP order form we used in the previous lesson, and simply add the new code into the page.


<!DOCTYPE HTML> <html> <body> <!-- The one new facet of this form from the previous lesson is that it contains a HIDDEN field. This field will not appear on the webpage, but it contains data that will get sent along with the form. Since we are using a Mailchimp API, this "campaignname" field will identify that our form is for a newsletter signup. --> Filling out the form below will take you to a thank you page and it will send you an email. <br><br> The processing page would also submit the data to Mailchimp, if you had a legitimate Mailchimp account. For the purposes of this demo, the Mailchimp account number and mailing list numbers are fake. <br><br> <form name="thisisthecontactform" method="post" action="includes/send_form_email.php"> <input type="text" name="fullname" placeholder="Your Name"><br> <input type="email" name="email" placeholder="Email Address"><br> <input type="hidden" value="Newsletter" name="campaignname"><br> <input value="Submit" type="submit" id="submit"> </form> </body> </html>

The real "lesson" here is to go look at the additional code in the submission form and the "mailchimp" folder used in the .ZIP file. The API from Mailchimp is fairly simple. There is literally just one PHP file that gets uploaded to the server, then a few additional lines of code get added to the web form processing page. Since you went through the previous lesson and learned how to get a PHP page to send an email, this lesson is really easy because it's the identical code as the previous lesson, with just a few extra lines added.

So, don't get intimidated when people ask if you have used an API. There isn't much to it. Companies that provide an API will typically have the process documented explicitly and it will be very easy to implement.

And remember, kids, the world owes you nothing... until you create things of value.



API is an abbreviation for "Application Programming Interface" and is basically a way for a webpage to communicate with some other kind of computer system.


Other Articles