Instructional Material: What is an API?

Simply put, an API or Application Programming Interface, is a library of pre-written computer programs that simplify the use of software or hardware features. When you look at a robot, there is a lot of low level programming needed to operate motors, read sensors, control valves, all at the binary level. There has to be different low level code for each different hardware component. For instance, two different models of motor may require different types of voltage input in order to properly move. It would be very tedious, error prone and time consuming if you had to write all of that low level code as well as the higher level instructions to perform the overall function of your robot.

To solve this problem, other programmers have written all of that low level code and provided it to you in the form of Java Object Libraries. You use these library objects in your program to handle all of the low level tasks for you, allowing you control the robot hardware at a much higher level. So rather than understanding all of the nuances and technical issues in controlling motor voltages, you can simply create a motor object (from the object library) and call the motor.SetSpeed() function to make the motor turn at your desired speed. The motor API is written so that you do not need to understand the specifics of how particular models of motors or servos (or other hardware) vary in their voltage level, but instead can focus on the actions you want the robot to complete. It is important to note, however, that sometimes the small differences in how hardware behaves at the low level (as controlled by the API), can result in surprising, undesired, or otherwise unexpected results when the robot is running.

There are many functions and many devices available for each robot platform and the object library has many objects representing all of the features of the robot hardware. Taken together, all of these library objects are called an API. For the EV3, the API is called the leJOS API. For the Tetrix, the API is called the FTC SDK. On the RoboRio, the API is called the WpiLib.

The term API may also be used for subsets of the overall API. For instance the WpiLib, which is a large API, has a subset of objects dealing with robot vision named the Vision API.

Here is the Wikipedia discussion of an API.

Material Type: 
Lecture/Presentation
Education Level: 
Middle School
High School
Focus Subject: 
Computing / Computer Science
Robotics Software
HW Platform: 
EV3
RoboRIO
Tetrix
SW Platform: 
Java
Interactivity Style: 
Mixed
Audience: 
Learner