Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit 03a6589

Browse files
author
Kevin Richter
committed
Add information about headers, offset
1 parent 0b33d09 commit 03a6589

File tree

1 file changed

+72
-2
lines changed

1 file changed

+72
-2
lines changed

source/v1/index.html.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,71 @@ All JSON responses from the API is wrapped in a base object.
136136

137137
Be sure to include an `Accept: application/json` header, otherwise errors like `401`, `403` & `404` will either return HTML or redirect you to the login page.
138138

139+
## Headers
140+
141+
### Exposed Headers
142+
143+
- `Content-Type`(`application/json` or the filetype, e.g. `image/png`)
144+
- `Content-Disposition` (only for files, defaults to `attachment; filename="filename.ext"`)
145+
146+
### For Pagination
147+
See [pagination](#pagination)
148+
149+
- `X-Paginate-Total`
150+
- `X-Paginate-Pages`
151+
- `X-Paginate-Offset`
152+
153+
### For HTTP Caching we Expose
154+
155+
- `Cache-Control`
156+
- `Last-Modified`
157+
- `ETag` [(weak)](https://en.wikipedia.org/wiki/HTTP_ETag#Strong_and_weak_validation)
158+
159+
> Create Route
160+
161+
```
162+
/v1/users
163+
```
164+
> Get Route
165+
166+
```
167+
/v1/users/1
168+
```
169+
170+
All returned model resources have an `ETag` and `Last-Modified` header.
171+
172+
`ETag` are returned from get, create & update requests.
173+
Because the ETags are weak they can be used on other routes as well.
174+
175+
For example, when creating a new resource, the API will return an `ETag`,
176+
this `ETag` can be used on the get route to check if the resource has been modified since creating it.
177+
178+
### We Also Expose CORS Headers
179+
180+
- `Access-Control-Allow-Origin` (default `*`)
181+
- `Access-Control-Allow-Methods`
182+
- `Access-Control-Allow-Headers`
183+
- `Access-Control-Expose-Headers`
184+
- `Access-Control-Max-Age`
185+
186+
### Accepted Headers
187+
188+
- `Authorization`
189+
- `Accept`
190+
- `Content-Type`
191+
192+
### For Pagination
193+
See [pagination](#pagination)
194+
195+
- `X-Page`
196+
- `X-Per-Page`
197+
- `X-Offset`
198+
199+
### For HTTP Caching
200+
201+
- `If-Match`
202+
- `If-Modified-Since`
203+
139204
## Query Parameters
140205

141206
The API has a few query parameters available that you can use to help find the resources you need.
@@ -147,21 +212,26 @@ All three of these query parameters are only available on listing endpoints, so
147212
> As Query Parameter
148213
149214
```
150-
?page=1&per_page=50
215+
?page=1&per_page=50&offset=0
151216
```
152217

153218
> As Header
154219
155220
```
156221
X-Page: 1
157222
X-Per-Page: 50
223+
X-Offset: 0
158224
```
159225

160226
By default the API returns 12 items per page and defaults to page 1.
161227

162228
The number of items per page can be increased to a maximum of 50 items.
163229

164-
<br/><br/><br/><br/><br/><br/>
230+
### Offset
231+
232+
`offset` is a special parameter within our pagination system, the `offset` will remove the first `n` items from the list you are querying. `offset` can be used to work around getting duplicate data.
233+
234+
So, for example: if the list has 600 items and the `offset` is set to 100, the `X-Paginate-Total` will report 500 items, other headers like `X-Paginate-Pages` will also be calculated from the new total.
165235

166236
### Sorting
167237

0 commit comments

Comments
 (0)