Microsoft unveils TypeSpec language for API development

By Paul Krill

Microsoft has introduced TypeSpec, a language for API-centric development.

Unveiled April 25, TypeSpec is designed to meet the needs of API developers, managers, and architects in an environment where delivering high-quality APIs and related experiences has become increasingly critical and complex, Microsoft said. The company described TypeSpec as a lightweight language that describes APIs using any protocol or serialization format and encapsulates common data types, API patterns, and API guidelines into high level, reusable components. It can define complex data and API shapes with minimal types.

The language was inspired by Microsoft’s TypeScript and C# languages and is easy to learn, according to Microsoft, which has used TypeSpec internally for many Azure cloud services. Instructions on getting started with the language can be found on the project website. Installation requirements also are accessible.

TypeSpec provides a platform that enables abstraction, encourages code reuse, and leverages modern tools including Visual Studio and Visual Studio Code for rapid development, Microsoft said. APIs are described using any protocol or serialization format with familiar syntax. The language can compile to OpenAPI, JSON Schema, Protobuf (Protocol Buffers), or all three simultaneously.

Microsoft said TypeSpec is “not just another API description language” but a higher-level definition language capable of defining an API and then outputting different protocols, clients, servers, documentation, and other capabilities. The language thus becomes a tool to adapt to a variety of development scenarios. Plus the tools for TypeSpec make development and maintenance easy, surfacing errors and guideline violations at development time, the company said.

© Info World