-
-
Notifications
You must be signed in to change notification settings - Fork 18
REST API example
epicmonkey edited this page Sep 28, 2013
·
27 revisions
- Authentication
$ curl -d "username=test" -d "password=test" http://localhost:3000/v1/session
{
"err": null,
"status": "success",
"user": {
"id": "ecad21a5-45be-4eb8-9398-db51415992fb",
"username": "test",
"info": {
"screenName": "test",
"email": "[email protected]",
"receiveEmails": "0"
}
}
}
- Registration
$ curl -d "username=test" -d "password=test" http://localhost:3000/v1/signup
{
"err": null,
"status": "success",
"user": {
"id": "f6f55f5d-c0b5-4fae-92e8-4d12b84fbe2d",
"username": "test",
"info": {
"screenName": "test"
}
}
}
- Create new post
curl -b "connect.sid=s%3A2H%2FlKW2M%2BC1qsjkwuIOrfL2q.WtQIfmnzNYqVfsfR2opIM5CeDg3y1%2FQNy7nCwJsT14" -d "body=test2" http://localhost:3000/v1/posts
{
"id": "237318ed-0c51-4c0a-9be8-2904d3458ce8",
"body": "test2",
"createdAt": 1380397179394,
"updatedAt": 1380397179394,
"comments": [],
"attachments": [],
"likes": [],
"createdBy": {
"id": "0aeb1250-7686-43b6-be15-35b7cede21b4",
"username": "test",
"info": {
"screenName": "test"
}
},
"groups": [
{
"id": "0aeb1250-7686-43b6-be15-35b7cede21b4",
"username": "test",
"info": {
"screenName": "test"
}
}
]
}
- Read post
$ curl http://localhost:3000/v1/posts/237318ed-0c51-4c0a-9be8-2904d3458ce8
{
"id": "237318ed-0c51-4c0a-9be8-2904d3458ce8",
"body": "test2",
"createdAt": 1380397179394,
"updatedAt": 1380397179395,
"comments": [],
"attachments": [],
"likes": [],
"createdBy": {
"id": "0aeb1250-7686-43b6-be15-35b7cede21b4",
"username": "test3",
"info": {
"screenName": "test3"
}
},
"groups": [
{
"id": "0aeb1250-7686-43b6-be15-35b7cede21b4",
"username": "test3",
"info": {
"screenName": "test3"
}
}
]
}
- Update post
curl -b "connect.sid=s%3A2H%2FlKW2M%2BC1qsjkwuIOrfL2q.WtQIfmenzNYqVfsfR2opIM5CeDg3y1%2FQNy7nCwJsT14" -d "body=test" -X PATCH http://localhost:3000/v1/posts/237318ed-0c51-4c0a-9be8-2904d3458ce8
{}
- Delete post
curl -b "connect.sid=s%3A2H%2FlKW2M%2BC1qsjkwuIOrfL2q.WtQIfmenzNYqVfsfR2opIM5CeDg3y1%2FQNy7nCwJsT14" -X DELETE http://localhost:3000/v1/posts/237318ed-0c51-4c0a-9be8-2904d3458ce8
{}