|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: 'A2A Java SDK: Support for the REST Transport is Now Here' |
| 4 | +date: 2025-09-15 |
| 5 | +tags: ai a2a |
| 6 | +synopsis: 'Today, we released A2A Java SDK 0.3.0.Beta1 which adds support for the HTTP+JSON/REST transport.' |
| 7 | +author: fjuma |
| 8 | +--- |
| 9 | + |
| 10 | +Today, we've released A2A Java SDK 0.3.0.Beta1 which introduces support for the HTTP+JSON/REST transport. |
| 11 | + |
| 12 | +Our last https://quarkus.io/blog/quarkus-a2a-java-0-3-0-alpha-release/[blog post] covered what's new in the 0.3.0 version of the A2A Java SDK. In this post, we'll focus on how to make use of the new HTTP+JSON/REST transport for both A2A server agents and clients. |
| 13 | + |
| 14 | +== Configuring an A2A Server Agent to Support the REST Transport |
| 15 | + |
| 16 | +To enable your A2A server agent to support communication using HTTP+JSON/REST, add the following dependency: |
| 17 | + |
| 18 | +[NOTE] |
| 19 | +==== |
| 20 | +The `io.github.a2asdk` `groupId` is temporary and will likely change for future releases. Keep an eye on the `a2a-java` https://github.com/a2aproject/a2a-java/blob/main/README.md[README] for up-to-date documentation. |
| 21 | +==== |
| 22 | + |
| 23 | +[source,xml] |
| 24 | +---- |
| 25 | +<dependency> |
| 26 | + <groupId>io.github.a2asdk</groupId> |
| 27 | + <artifactId>a2a-java-sdk-reference-rest</artifactId> <1> |
| 28 | +</dependency> |
| 29 | +---- |
| 30 | + |
| 31 | +<1> `a2a-java-sdk-reference-rest` provides access to the core classes that make up the A2A specification and provides the HTTP endpoints that implement the A2A protocol using the HTTP+JSON/REST transport. |
| 32 | + |
| 33 | +After adding this dependency, simply update your agent card to declare support for this new transport: |
| 34 | + |
| 35 | +[source,java] |
| 36 | +---- |
| 37 | +@Produces |
| 38 | +@PublicAgentCard |
| 39 | +public AgentCard agentCard() { |
| 40 | + return new AgentCard.Builder() |
| 41 | + .url(YOUR_HTTP_JSON_URL) <1> |
| 42 | + .preferredTransport(TransportProtocol.HTTP_JSON.asString()) <2> |
| 43 | + .additionalInterfaces(List.of( |
| 44 | + new AgentInterface(TransportProtocol.HTTP_JSON.asString(), |
| 45 | + YOUR_HTTP_JSON_URL) |
| 46 | + ... <3> |
| 47 | + )) |
| 48 | + ... |
| 49 | + .build(); |
| 50 | +} |
| 51 | +---- |
| 52 | + |
| 53 | +<1> This is the primary URL for your A2A server agent. This should be the URL for your preferred transport (e.g., `http://localhost:8080`). |
| 54 | +<2> Your A2A server agent's preferred transport, HTTP+JSON/REST in this example. |
| 55 | +<3> The `additionalInterfaces` can optionally contain an entry for the preferred transport. Any other transports you'd like to support (e.g., `TransportProtocol.JSONRPC.asString()` or `TransportProtocol.GRPC.asString()`) can be specified here too. |
| 56 | + |
| 57 | +For more details on configuring your A2A server agent to support multiple transports, refer to our previous https://quarkus.io/blog/quarkus-a2a-java-0-3-0-alpha-release/[blog post]. |
| 58 | + |
| 59 | +== Configuring an A2A Client to Support the REST Transport |
| 60 | + |
| 61 | +To get your A2A client to communicate using the HTTP+JSON/REST transport, you'll need to add a couple |
| 62 | +dependencies. |
| 63 | + |
| 64 | +First, add the `a2a-java-sdk-client` dependency to your project. This will provide access to a `Builder` that you can use to create your A2A `Client`. |
| 65 | + |
| 66 | +[source,xml] |
| 67 | +---- |
| 68 | +<dependency> |
| 69 | + <groupId>io.github.a2asdk</groupId> |
| 70 | + <artifactId>a2a-java-sdk-client</artifactId> <1> |
| 71 | +</dependency> |
| 72 | +---- |
| 73 | + |
| 74 | +Next, add the specific dependency for the HTTP+JSON/REST transport: |
| 75 | + |
| 76 | +[source,xml] |
| 77 | +---- |
| 78 | +<dependency> |
| 79 | + <groupId>io.github.a2asdk</groupId> |
| 80 | + <artifactId>a2a-java-sdk-client-transport-rest</artifactId> |
| 81 | +</dependency> |
| 82 | +---- |
| 83 | + |
| 84 | +You can now use `Client.builder()` to create a `Client` that supports the HTTP+JSON/REST transport using the `withTransport` method as shown below: |
| 85 | + |
| 86 | +[source,java] |
| 87 | +---- |
| 88 | +// Create the client using the builder |
| 89 | +Client client = Client |
| 90 | + .builder(agentCard) |
| 91 | + .withTransport(RestTransport.class, new RestTransportConfig()) <1> |
| 92 | + .... |
| 93 | + .build(); |
| 94 | +---- |
| 95 | +<1> This specifies that our client can support the HTTP+JSON/REST transport. At least one transport must be configured using the `withTransport` method. |
| 96 | + |
| 97 | +For a deep dive into creating clients with the `Client.Builder`, check out this https://quarkus.io/blog/quarkus-a2a-java-0-3-0-alpha-release/[post]. |
| 98 | + |
| 99 | +== Conclusion |
| 100 | + |
| 101 | +With the release of A2A Java SDK 0.3.0.Beta1, building flexible, interoperable multi-agent systems just got easier with the new support for the HTTP+JSON/REST transport. |
| 102 | + |
| 103 | +=== Further Reading |
| 104 | + |
| 105 | +* https://quarkus.io/blog/quarkus-a2a-java-0-3-0-alpha-release/[Getting Started with Quarkus and A2A Java SDK 0.3.0] |
| 106 | +* https://github.com/a2aproject/a2a-samples/tree/main/samples/java/agents[A2A Java SDK Samples] |
| 107 | +* https://github.com/a2aproject/a2a-java/blob/main/README.md[A2A Java SDK Documentation] |
| 108 | +* https://a2a-protocol.org/latest/specification/[A2A Specification] |
| 109 | + |
| 110 | + |
0 commit comments