An open-source protocol and framework for REST data services

Optimize REST interactions. Avoid excessive requests to server when navigating backend data graphs.

Agrest Flow Play Video from JEEConf

Getting Started

<!-- Add Maven Dependency -->
<dependency>
    <groupId>io.agrest</groupId>
    <artifactId>agrest</artifactId>
    <version>3.0</version>
</dependency>
// Load in JAX RS Application
@ApplicationPath("/")
public class JaxRsApplication extends ResourceConfig {
    public JaxRsApplication() {
        ServerRuntime cayenneRuntime = ..
        AgRuntime agRuntime = AgBuilder.build(cayenneRuntime);
        register(agRuntime);
    }
}
// Write a JAX-RS Resourcy
@Path("myentity")
@Produces(MediaType.APPLICATION_JSON)
public class MyEntityResource {
    
    @Context
    private Configuration config;

    @GET
    public DataResponse<MyEntity> getAll(@Context UriInfo uriInfo) {
        return Ag.select(MyEntity.class, config).uri(uriInfo).get();
    }
}
# Start Sending Requests
curl -i -X GET \
'http://127.0.0.1:8080/myapp/my-entity'

Read full documentation in Docs section

Features

Agrest as frameworkFramework

Java DSL for Building REST APIs for Data Stores

Features easy-to-use fluent Java API to build customized processors for entity web methods. API works on top of JAX-RS standard. Reuses / extends entity model of a pluggable backend provider.

Supports Relational Databases

Supports relational databases via Cayenne ORM backend provider out of the box.

Pluggable Backend Providers for Other Data Stores

Supports alternative user-defined backends. E.g. for NoSQL stores, analytical queries, LDAP / Active Directory, etc.

Fine Grained Security

Straightforward integration with any Java authorization framework to provide attribute-level and object-level access control.

Agrest as protocolProtocol

Client Shapes the Response

Provides REST API that allows client to filter, sort, paginate the response. Client can request specific properties of "root" entity and recursively include data of related entities.

GET, POST, PUT, DELETE

Supports reading / modifying data objects, collections and relationships.

Vanilla HTTP / JSON

Based on common REST HTTP interactions. Serves data as JSON.