A .proto file defines the shape of your data and assigns each field a stable numeric identity. The names make the schema readable to humans. The numbers are what make the binary format compact and compatible over time.
Anatomy of a .proto file
This diagram breaks down the parts of a .proto file. Each label links to the page that covers it in detail.
ORDER.PROTO
edition = "2024";
package shop.v1;
message Order {
string id = 1;
Status status = 2;
repeated string tags = 3;
map<string, uint32> quantities = 4;
oneof payment {
string card_token = 5;
string invoice_id = 6;
}
}
enum Status {
STATUS_UNSPECIFIED = 0;
STATUS_PLACED = 1;
}
message OrderRequest {
string order_id = 1;
}
service Orders {
rpc GetOrder(OrderRequest) returns (Order);
}
Next
Messages
The primary containers for Protobuf data, and the contract they enforce across every language that touches them.