What is an API?
An API is a set of rules that lets software components communicate with each other. That could be your own code talking to a game engine, an app talking to a third-party service, or a device talking to VR/AR hardware.
In Unity specifically, this includes programming in Unity via the Scripting API, which lets your code control GameObjects and components, as well as third-party APIs for services like analytics, ads, and VR/AR device SDKs.
How does an API work?
An API works like a messenger between software components. Your code sends a request in a defined format, and gets back a response, without needing to know how the other side is built. This creates a structured communication channel that lets developers access functionality without needing to understand how it's implemented underneath.
In a real-time development environment, that means accessing hardware features, system resources, external services, and specialized toolsets through documented methods and parameters, without writing that underlying functionality yourself.
How is an API used?
APIs generally show up at several levels in software development:
- Engine or platform APIs that control core functionality
- Third-party APIs and SDKs that bring in outside services
- Hardware-specific APIs that expose device features
- Server-side or backend APIs that run independent of any client at all
Layering these together is what lets one piece of software run across many platforms, operating systems, devices, and hardware form factors, without rewriting core logic for each one.
How is an API used in Unity?
In Unity specifically, you'll work with APIs at all of these levels. The Unity Scripting API is the one you'll use most. It’s how your C# scripts control GameObjects, physics, rendering, and input.
Beyond that, third-party SDKs bring in their own APIs for services like analytics, ads, and in-app purchases. VR/AR hardware works similarly. It exposes device-specific APIs (like OpenVR for SteamVR headsets), and Unity's VR/AR programming frameworks abstract those away so your code doesn't need to know which headset is connected.
There's also a server-side layer: Unity's own Web APIs let you call services like authentication, Cloud Save, and Cloud Code directly over REST, without needing the Unity Editor or a Client SDK at all.
What are the benefits of using APIs?
APIs make modern software development faster and more reliable:
- Faster development: reuse existing functionality instead of building it from scratch, whether that's a payment system, a map, or a VR headset's tracking data.
- Consistent behavior across platforms: the same API call works the same way regardless of the underlying hardware or operating system, which is what lets one Unity project reasonably target many platforms.
- Easier maintenance: updating what's behind an API doesn't require every application using it to change, as long as the API itself stays stable.
Frequently asked questions (FAQ)
Is an API the same as an SDK?
No. An API is the interface itself, the rules for how to request data or functionality. An SDK is a broader toolkit that usually includes one or more APIs plus other tools like documentation, sample code, and a compiler.
Do I need to understand APIs to use Unity?
Not to use the Editor's built-in tools, but yes, as soon as you write a script. Every script you write in Unity calls the Scripting API, so a basic understanding of how APIs work makes scripting far less mysterious.
What's the difference between a public and a private API?
A public API is open for any developer to use, often with documentation and a developer portal. A private (or internal) API is restricted to use inside one company or one project, and isn't meant for outside developers at all.
Related terms
Virtual Reality/Augmented Reality Programming