Hacker News new | ask | show | jobs
Patterns for REST API bulk operations (l1ghtm4n.com)
2 points by l1ghtm4n 4745 days ago
1 comments

HTTP PATCH is a very good way to do RESTful bulk operations

I frequently use the PATCH operation to create, update and delete in bulk, sometimes a combination of these. That is the best bulk operation I have found till date that is RESTFul and compliant across client/server.

Eg.

curl --dump-header - -H "Content-Type: application/json" -X PATCH --data '{"objects": [{"body": "Surprise! Another post!.", "pub_date": "2012-02-16T00:46:38", "slug": "yet-another-post", "title": "Yet Another Post"}], "deleted_objects": ["http://localhost:8000/api/v1/entry/4/"]}' http://localhost:8000/api/v1/entry/

That is definitely another way to do it. You do lose the significance of the HTTP verb, though. One reason i've come to the dedign i proposed is that a web form usually isn't creating and deleting in a single operation, so I used that to justify different entry points.