Your first API

To have your first API you just need to create an Endpoint. It is done very easily with a scaffold:

mvn yawp:endpoint -Dmodel=person

Now we can change the Person class to add the name attribute:

@Endpoint(path = "/people")
public class Person {
    IdRef<Person> id;
    String name;

Just start the development server:

mvn yawp:devserver

After the development server starts, you can play with the Person endpoint’s APIs using cURL. To create a person, execute in a shell:

curl -H "Content-type: application/json" -X POST \
     -d "{'name': 'John'}" http://localhost:8080/api/people

To list the created person:

curl http://localhost:8080/api/people

To access it from your web or Node.js apps, you can use the YAWP! JavaScript client library.

Install it:

npm install yawp --save

And create a person:

var yawp = require('yawp');

var promise = yawp('/people').create({name: 'janes'}).then(function(person) {
    console.log('created',; = 'janes joplin';
    return {