Skip to content

Instantly share code, notes, and snippets.

@vlucas
Created June 18, 2012 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vlucas/2950863 to your computer and use it in GitHub Desktop.
Save vlucas/2950863 to your computer and use it in GitHub Desktop.
Hypermedia API with "form"-like descriptions
{
"_links":{
"add":{
"title":"Add Budget",
"href":"http:\/\/localhost\/brightb.it\/budgetapp\/budgets",
"method":"post",
"parameters":{
"name":{
"type":"string",
"required":true
},
"amount":{
"type":"float",
"required":true,
"length":"10,2"
}
}
}
},
"items":[
{
"id":73,
"name":"Stroopwafels",
"amount":120,
"balance":70,
"_links":{
"self":{
"rel":"budget",
"href":"http:\/\/localhost\/brightb.it\/budgetapp\/budgets\/73",
"method":"get"
},
"delete":{
"title":"Delete",
"href":"http:\/\/localhost\/brightb.it\/budgetapp\/budgets\/73",
"method":"delete"
},
"transactions":{
"title":"Transactions",
"href":"http:\/\/localhost\/brightb.it\/budgetapp\/budgets\/73\/transactions",
"method":"get"
},
"add_transaction":{
"title":"Add Transaction",
"href":"http:\/\/localhost\/brightb.it\/budgetapp\/budgets\/73\/transactions",
"method":"post",
"parameters":{
"name":{
"type":"string",
"required":true
},
"amount":{
"type":"float",
"required":true,
"length":"10,2"
}
}
}
}
},
{
"id":74,
"name":"Souvenirs ",
"amount":200,
"balance":200,
"_links":{
"self":{
"rel":"budget",
"href":"http:\/\/localhost\/brightb.it\/budgetapp\/budgets\/74",
"method":"get"
},
"delete":{
"title":"Delete",
"href":"http:\/\/localhost\/brightb.it\/budgetapp\/budgets\/74",
"method":"delete"
},
"transactions":{
"title":"Transactions",
"href":"http:\/\/localhost\/brightb.it\/budgetapp\/budgets\/74\/transactions",
"method":"get"
},
"add_transaction":{
"title":"Add Transaction",
"href":"http:\/\/localhost\/brightb.it\/budgetapp\/budgets\/74\/transactions",
"method":"post",
"parameters":{
"name":{
"type":"string",
"required":true
},
"amount":{
"type":"float",
"required":true,
"length":"10,2"
}
}
}
}
}
]
}
@mikekelly
Copy link

Hey, this is quite interesting - I've also been doing some similar sketching to add something form-like on top of HAL:

https://gist.github.com/893552

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment