Tag Archives: APIs

All about APIs

I had always heard this term “API,” and I think I knew just two things about it — it’s everywhere, and it’s powerful. After going through the readings and videos, I’m clearer on the actual technology, but still unsure of how I would use it in my site or in my reporting.

I’m also left with questions about security and ethics. In the WebConcepts video, the presenter said that in order to send a tweet through the Twitter API, you need to authenticate and get what’s called an “access token.” But I couldn’t see where he actually provided his login information in order to authenticate. I’m also wondering if this method circumvents any type of two-factor authentication.

I’m also wondering what companies get out of making all of this data public? This seems like a wealth of internal, constantly updating and valuable information that other companies can easily use to make their own products more valuable.

Conversely, having access to so much data and so much proprietary data is It’s also clearly a way to snuff out the competition. I read further about how Facebook has actually used access to their API to snuff out competitive companies by revoking their access. Revoking access to Facebook’s API means that whatever company is trying to use Facebook to create a user profile (these are the “Login with Facebook” or “Login with Google” buttons that allow you to basically autofill a profile with information you’ve already given to these two companies) is a real hindrance. Who wants to actually fill all that crap out?!

 

APIs, The Unsung Hero

Through this week’s reading, I have realized that APIs is an important part of my life because it allows interactions between applications, data and devices, giving us the connectivity that we love and deserve! To be honest, I was originally skimming through this week’s reading and I had a lot of trouble understanding APIs at first, causing me to be extremely frustrated.  As soon as I slowed down and gave the API readings a chance, I realized that “what is an API” is a question that people should be asking more often, especially with how imperative technology is in our world.

So what is an API?! This is a question I surely have been asking all night. I enjoyed watching the analogy in a video I watched this week that described an API as you requesting an order and the waiter acts as the communicator telling the kitchen your order and delivering the food back to you. I have noticed that many programmers have different definitions for what they believe an API is. Simply put, APIs make a lot of sense using the waiter analogy, but gets extremely complicated to me when I hear about there being unique APIs for Google and WordPress. In one of the articles, it says that the difference in a Google API is the format of the request and the response. Are most APIs typically very similar in format? I also noticed that the WordPress API also uses  JSON, but I am not sure if they are the same kind of API. I thought of the JSON version of an API as the waiter receiving an order from a foreigner, trying to make sense of it in the kitchen and then returning words in a new language. Not sure if this analogy makes sense, but hopefully there is one that would explain the format better to me.

I am still trying to make sense of APIs because it seems like it is a title some programmer just threw out there. Is an API something a programmer creates with the server? Although there are many questions out there, at least I know that APIs are our unsung hero!

APIs & Agile

API Lite, Please

The first two readings this week helped solidify my understanding of what an API does: It’s the mechanism by which a client communicates with a server (like a waiter taking an order from a customer, retrieving it from the kitchen, and delivering it back to the customer).

The second two readings, on REST APIs, completely blew my mind.

In addition to taking and delivering data, APIs can also post them. Moreover, you can make API requests in a browser to view JSON data specific to your query, including specific parameters that you control. Then, you can take the data you mine from an API request on one website, and use it to access or reference additional data on another website! This waiter is multi-talented!

It does bring up a question for me about security, however. I know that access tokens must be passed to authenticate that the person accessing the data is allowed to access it, but do systems become vulnerable for malicious data scraping when their APIs are available on something like Apigee? This goes back to the recurring theme of developer tools being transparent and accessible—from web inspectors to API management software—while also being acutely aware of the risks of the internet.

Back to Agile Framework

Since Week 8’s discussion of agile frameworks, I’ve been paying more attention to how teams in my workplace function. I remembered that one of my colleagues, who works as a project manager for the marketing and technology teams, had regular “scrum” meetings on her calendar. I asked if those teams operated under an agile structure, and she (impressed by my question) responded that yes, our Chief Information Officer prefers to operate that way.

She explained they work within a framework that’s most similar to scrum, with sprints (a blend of technology and design work) lasting 10-15 days each. It’s interesting to think about this technology culture being nested within the framework of higher education, which operates on a much more drawn out and fluid timeline.

My colleague noted that, while projects aren’t always strictly within the set scrum framework, it’s been helpful for the members of the team to operate using a common language and set of expectations, and the framework has allowed them to complete a lot of high level projects with success.

She also mentioned that she uses the tool MS Project, which allows her to help the team visualize the consequences of contingencies and dependent tasks not being completed.

Getting Back in Order

After what was a tumultuous couple of weeks for me, personally and academically, I am starting to feel like I’m getting back into a productive groove. With scheduling and organizing it feels good to feel at least somewhat on top of my work.

So I’ve truly begun the process of starting to find modifications that I would be interested in applying to my final project. The contact form example that we worked on was very interesting me, although it may seem like a basic part of an e-portfolio, it helped narrow the scope to things that I deemed to be practical. I’m thinking maybe leaving a comments box on the page could be a plausible idea. Hopefully I can come up with a few more ideas to solidify my modifications and then from there I can put them and motion and get my web portfolio up and running.

The readings this week were informative. I was confused watching the API video, but the article helped to break down the term piece by piece. This is a modification I could see wanting to put on my website. The possibility of being able to schedule an interview or something else through the website could prove to be useful.

Week 10: Still Trying To Understand How the Web Works

APIs — Application Programming Interfaces — are waiters. What does that mean exactly? Well, MuleSoft explains it like a restaurant. You sit down at your table, persuing the various delicacies available for your choosing. You know the kitchen will be able to make your order, but how do you let the kitchen know what you want? And how does the kitchen get you your food? Surely, you can’t do it yourself so this is waiters (or APIs) come in. An API is a messenger that takes requests and tells a system what you want to do. Then, the API will return the response back to you.

Real API examples are third-party travel sites. When you use services such as Kayak or Priceline, they are interacting with airlines’ and hotels’ APIs. You tell them what you want, they tell the companies, and then they give you the companies’ responses.

In essence, APIs rule the internet. The web (did I use those right??) would be far less connected that what we see today. They connect the web, allowing developers, applications, and sites to tap into databases and services (or, assets)—much like open-source software. APIs do this by acting like a universal converter plug offering a standard set of instructions.

Get it? Got it? Good! Now you have a basic (emphasis on basic) understanding of how APIs work. You can try out our example below to get a better understanding of the mechanics behind APIs or watch our video about getting started with APIs.

Click the button to go to the next lesson!

 

Click Here for "REST APIs & JSON"—>

 

Side note: often on like third-party travel sites, there aren’t Southwest flights. I usually use Google Flights, so I can’t speak for everyone, but does that mean Southwest doesn’t allow third-party access to their APIs? And what would be the motive for doing so?

API Readings and Project Update

Readings

In terms of this week’s readings, I’ll echo Allie’s thoughts in that I understand the general purpose of APIs, but, like she pointed out in her post, I’m not quite sure how they apply to our final projects and am a little confused on the more minute details, like resting APIs and JSON.

Final Project

I have to say I’m feeling a little discouraged about our final project. I had issues over the weekend with my MAMP not starting the servers when I prompted it to and couldn’t access my local site. I was able to figure out how to get the app to work with a few hours of Googling and was feeling pretty good (and like a real web developer – yay!) but quickly realized that I’ve now stumbled on a new issue that’s still preventing me from accessing my local site.

My new problem is that when I run my local server and type in the address for my project (http://localhost:8888/finalproject/), I’m taken to the wp-admin page below:

I’m a little confused about why I’m seeing this page because it was my understanding that we had already installed WordPress in class together a few weeks ago? When I go through the final steps of installing WordPress here, I get a page showing me a bunch of database errors telling me certain files don’t exist:

And finally, when I click “login” at the bottom of the errors page, I get the following error message on a new page:

So far, Google has been unsuccessful in helping me figure out what’s wrong.

I didn’t want to lose time so I’ve continued to make changes to the code in my htdocs, even though I can’t preview it to see if the changes are correct. I created a child theme last week and have been working on creating a custom post type, which is probably my most complex customization. As suggested, I’m modifying this book list plugin.

I will keep Googling to see if I can find a solution, and, hopefully, I can get the local site issue resolved before Wednesday or can get help fixing it during class. In the meantime, I have a few other questions:

  • We talked about how some of the more superficial changes should be made on our live site, rather than our local site because the changes won’t necessarily transfer over, and I want to know when we can do that? Should we wait until we make all of our more back-end changes or can we go ahead and make these smaller changes to our other site now?
  • I think we may have covered this in class as well, but how often should we be saving the changes we are making to our GitHub repository? Is it enough to save it after we’ve completed a customization or should it be more frequent?

APIs and Building My First Plugin

I had heard of APIs before taking this class, but this week’s readings and videos did a good job of breaking down this complex topic. The kitchen analogy used in the “What is an API?” video was helpful in terms of understanding how an API works as a messenger that communicates user requests and delivers responses back to the user. I recently booked a flight using the online travel service Kayak, and did not think about the fact that Kayak was using airline APIs to find me flights based on the parameters I defined. Kayak accesses the airline APIs and aggregates information from them based on user requests.

I also tried out one of the examples provided in the video about REST APIs. I typed the sample URL into my search bar and tweaked it for my hometown of Mendon, Massachusetts, which resulted in a page written in JSON that allowed me to access the GPS coordinates for my hometown (latitude: 42.1056525, longitude: -71.5522859). I then went to the main Google Maps site and entered these coordinates, and was taken directly to the center of my hometown on the map. I will have to do a bit more research on the topic of APIs in order to more fully understand how the concepts can be applied to WordPress. I imagine that APIs are probably used in a lot of plugins that access data from outside websites, such as those that pull in data from Twitter or Instagram feeds.

I spent this weekend working on the modifications for my WordPress site. As I mentioned in last week’s blog post, I was able to create my child theme and activate it on my local site, but I still have to play around with the fonts and colors of the site. I plan to do that towards the end of my project, once all of my other modifications are complete. One specific question I had regarding editing the styles.css file for my child theme is, how do you edit the fonts if your parent theme uses the Font Awesome toolkit? For example, I tried changing the font for my site header, but it is not working, and I’m thinking it’s due to the fact that my parent theme uses Font Awesome and thus has multiple CSS files. How do I change the fonts in this case? 

I also decided to tackle the custom post type modification by building a custom post type plugin. I was able to write the code for this plugin using these instructions, but ran into a lot of issues on the way to getting it to work. For example, when I tried to activate the plugin from my wp-admin panel on my local site, I kept getting the following error:

Parse error: syntax error, unexpected ” => array(‘ (T_CONSTANT_ENCAPSED_STRING), expecting ‘)’ in /Applications/MAMP/htdocs/finalproject/wp-content/plugins/therunningglover-run-post-plugin/therunningglover-run-post-plugin.php on line 18

I could not for the life of me figure out what the issue on line 18 was, and so back to Google I went. Luckily, the Stack Overflow gods were there to help out, and I figured out that I had forgotten a single quote (‘) on line 18 of my plugin code. I fixed the issue, refreshed the page, and the plugin was activated. However, the custom post type was still not appearing in my admin panel, and so I decided to go back to square one and rewrite my code using the steps listed on the WordPress codex. I got it to work within five minutes. Lesson learned — use the WordPress codex first. I now have a custom post type on my left admin panel called “Run.” Now I’m working on adding a custom metabox called “Run Details” with metadata (custom fields). One question I have is, how do I get my custom post type posts to show up on the home page of my site, rather than just under the Blog page?

This coming week, I want to download a plugin for Strava and see how I can use it to pull in information about my most recent running routes onto the sidebar of my site. When modifying the code of an existing plugin, do we need to create a “child plugin” (if that is such a thing)? I will also attempt to build a lightbox slideshow to display some of my photographs, but may end up using a plugin for this. I’m also planning to load some of my files using the FTP client later this week, to ensure everything is working correctly on my hosted site. I’m feeling a bit overwhelmed at all that I have to do in the next week-and-a-half, and am hoping that I can at least get three quarters of my proposed modifications done before the final project deadline.

Regarding GitHub, should I only be syncing files that I’m coding myself? For example, the plugins that I downloaded and added to my page from WP also synced to my final project GitHub repo. Should I remove the code for these plugins from my final project repo since these are not something I coded myself? If so, what is the best way to do this?