Introduction to APIs¶
APIs, Application Program Interfaces, are collections of code that allow software components to communicate with each other.
The Datavyu API lets users write scripts in a Ruby programming interface that can modify the contents of Datavyu spreadsheets.
Suppose you have a dataset that contains fifty Datavyu files and videos. After you analyze your data, you realize that you want to go back and code a new pass for all of your files. Instead of manually creating a new column in all fifty Datavyu files, you can write a script that will do it for you! The script can include any and all desired codes within the column, save time, and reduce the potential risk of error.
Or suppose you want to change the name of a code. You can use a script to make the changes across all the relevant files.
Or perhaps you’d like a reliability coder to score 25% of each participant’s video. You can use a script to create a “reliability column” and insert every fourth cell (or a randomly selected 25% or any other metric) for a specific column.
Or maybe you want to check each file for typos or impossible onset/offset times. Use a script for data checking!
Computers are ideally suited for doing repetitive tasks quickly and conistently. The Datavyu API enables a researcher to perform these kinds of tasks programmatically, so that doing a repetitive task becomes a matter of writing a few lines of computer code and running the script.
Writing scripts with the API is straightforward and accessible to even a novice programmer. The ability to use scripts to automate tasks greatly increases the ways that Datavyu can facilitate data coding and analysis, and is well worth overcoming the initial learning curve.
Ruby and You¶
For a good introduction to Ruby, consider going through the Ruby in Twenty Minutes tutorial, which provides a quick overview to working in Ruby.
You do not need to be an experienced programmer or even understand the ins and outs of Ruby to be able to write scripts with the Datavyu API. Following the API tutorials is a good way to become familiar with scripting for Datavyu. With some practice, you will likely be able to customize the sample scripts for your own purposes. However, gaining a grounding in some programming concepts will make it easier to create your own scripts for your unique use cases and needs.
Consider Classes, Methods, and Parameters for an introduction to object oriented programming, classes, and methods. Also, Introduction to Scripting discusses the requirements you should keep in mind when you start writing scripts.