---
schema_version: "1"
id: 043f7f1f7822423aa9cbb2061703cd7400a44b9b6a9f2a466935e2e0af4788e6
title: Generate Code from the Proto File
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/event-bus/pub-sub-api/guides/generate-code-proto-file.md
canonical_url: https://developer.salesforce.com/docs/platform/pub-sub-api/guide/generate-code-proto-file.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: a6c1fe2ca4c8f940a2bb56385f4007b07d256fa380584045af228e1b8a652f9f
products:
  - Pub/Sub API
  - Event Bus Docs
---
# Generate Code from the Proto File

To generate code from the proto file, use a gRPC plug-in with protoc. This process generates client code, server code, and protocol buffer code for populating, serializing, and retrieving message types. For more information, see [Introduction to gRPC](https://grpc.io/docs/what-is-grpc/introduction/) in the gRPC documentation.

The [quick starts](https://developer.salesforce.com/docs/platform/pub-sub-api/guide/quick-start.md) walk you through the steps of generating the code from the proto file using gRPC tools.

## Execute RPC Methods from the Generated Code

The client has a local object known as a stub that implements the service methods. When a gRPC client calls the API, the corresponding API implementation is called on the server. The gRPC infrastructure decodes incoming requests, executes service methods, and encodes service responses. The client calls the methods on the local object, wrapping the parameters for the call in the appropriate protocol buffer message type. gRPC handles sending the requests to the server and returning the server’s protocol buffer responses.

The gRPC server serializes the response of a Subscribe RPC call based on the protocol buffer message type specified in the proto file. Similarly, when an event is published through one of the publish RPC methods, the publish request is serialized based on the protocol buffer message type. The payload of a published or received event is in the Avro binary format. For more information, see [Protocol Buffers](https://developers.google.com/protocol-buffers/docs/overview) in the gRPC documentation and [Event Data Serialization with Apache Avro](https://developer.salesforce.com/docs/platform/pub-sub-api/guide/event-avro-serialization.md).

**See Also**

- [_GitHub_: Pub/Sub API proto file](https://github.com/forcedotcom/pub-sub-api/blob/main/pubsub_api.proto)
