-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapiary.apib
More file actions
216 lines (159 loc) · 5.4 KB
/
apiary.apib
File metadata and controls
216 lines (159 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
FORMAT: 1A
# BooksSet API
Sample REST API for books set.
## Authentication
BooksSet API does not provide authenticated access.
## Media Types
Requests with a message-body are using plain JSON to set or update resource states.
## Error States
200 - OK, 400 - Bad Request, 500 - Internal Server Error
# BooksSet API Root [/]
BooksSet API entry point.
## Retrieve the Entry Point [GET]
+ Response 200 (application/json)
+ Body
{
"books": [
{
"book" : {
"id":"1234",
"title": "Война и мир",
"author": "Л.Н. Толстой",
"released": "1868"
}
},
{
"book" : {
"id":"1235",
"title":"Господин Ау",
"author": "Э. Успенский",
"released" : "1980"
}
}
]
, "_metadata" : [
{
"totalCount":250,
"limit":10,
"offset":0
}
]
}
# Group Book
Book-related resources of *BooksSet API*.
## Book [/v1/books/{id}{?fields}]
A single Book object. The Book resource is the only resource in the BooksSet API. It represents a single book in books set.
The Book resource has the following attributes:
- id
- title
- author
- released
The state *id* is assigned by the BooksSet API at the moment of creation.
+ Model (application/json)
JSON representation of Book Resource.
+ Headers
Link: <http:/api.booksset.com/books/1236>;rel="self"
+ Body
{
"id": "1236",
"title": "Yellow mist",
"author": "Alexander Volkov",
"released": "1970"
}
### Retrieve a Single Book [GET]
+ Parameters
+ id (required, number) ... numerical ID of the Book
+ fields (optional, string) ... comma separated list of required book attributes
+ Response 200
[Book][]
+ Response 400
+ Body
{"code" : 401, "message": "book wasn't found"}
### Edit a Book [PATCH]
To update a Book send a JSON with updated value for one or more of the Book resource attributes. All attributes values (states) from the previous version of this Book are carried over by default if not included in the hash.
+ Parameters
+ id (required, number) ... numerical ID of the Book
+ Request (application/json)
{
"released": "1970"
}
+ Response 200
[Book][]
### Delete a Book [DELETE]
+ Parameters
+ id (required, number) ... numerical ID of the Book
+ Response 204
+ Response 400
+ Body
{"code" : 401, "message": "book wasn't found"}
## Books Collection [/v1/books{?author,title,limit,offset}]
Collection of all Books.
The Book Collection resource has the following attribute:
- total
In addition it **embeds** *Book Resources* in the BooksSet API.
+ Model (application/json)
JSON representation of Book Collection Resource.
+ Headers
Link: <http:/api.booksset.com/books>;rel="self"
+ Body
{
"books": [
{
"book" : {
"id":"1234",
"title": "Война и мир",
"author": "Л.Н. Толстой",
"released": "1868"
}
},
{
"book" : {
"id":"1235",
"title":"Господин Ау",
"author": "Э. Успенский",
"released" : "1980"
}
}
]
, "_metadata" : [
{
"totalCount":250,
"limit":10,
"offset":20
}
]
, "_links" : [
{
"rel": "next",
"href": "/v1/books?offset=30&limit=10"
},
{
"rel": "prev",
"href": "/v1/books?offset=10"
},
{
"rel": "first",
"href": "/v1/books?offset=0"
},
{
"rel": "last",
"href": "/v1/books?offset=240"
}
]
}
### List All Books [GET]
+ Parameters
+ offset (optional, string) ...start position in the whole list of results
+ limit (optional, string) ...limit number of results
+ author (optional, string) ...filter list by author
+ title (optional, string) ...filter list by book title
+ Response 200
[Books Collection][]
### Create a Book [POST]
+ Request (application/json)
{
"title": "New book title",
"author": "Author of new book"
}
+ Response 201
[Book][]