You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/dev/web_api/v3/basics.md
+12-38Lines changed: 12 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
# Zotero Web API Documentation
2
2
3
-
This page documents read requests available in the [Zotero Web API](dev/web_api/v3/), providing read-only access to online Zotero libraries. The Zotero desktop client exposes the same endpoints as a [local API](#local_api) that serves data from the local database, which is useful for code running on the user's computer.
3
+
This page documents read requests available in the [Zotero Web API](dev/web_api/v3/), providing read-only access to online Zotero libraries. The Zotero desktop client exposes the same endpoints as a [local API](dev/web_api/v3/local_api) that serves data from the local database, which is useful for code running on the user's computer.
4
4
5
5
## Base URL
6
6
7
7
The base URL for all API requests is
8
8
9
9
https://api.zotero.org
10
10
11
-
All requests must use HTTPS. (The local API uses `http://localhost:23119/api/` instead; see [Local API](#local_api).)
11
+
All requests must use HTTPS. (The local API uses `http://localhost:23119/api/` instead; see [Local API](dev/web_api/v3/local_api).)
12
12
13
13
## API Versioning
14
14
@@ -43,38 +43,11 @@ Use of an HTTP header is recommended, as it allows use of URLs returned from the
43
43
44
44
`Authorization: Bearer` is also the authentication mechanism for OAuth 2.0. While Zotero currently supports only OAuth 1.0a, when support for OAuth 2.0 is added, clients will no longer need to extract the API key from the OAuth response and pass it to the API separately.
45
45
46
-
The [local API](#local_api) does not use authentication.
46
+
The [local API](dev/web_api/v3/local_api) does not use authentication.
47
47
48
48
## Local API
49
49
50
-
Recent versions of the Zotero desktop client expose a local implementation of this API on `localhost:23119` under `/api/`, serving data from the user's local database. Because nothing touches the network, the local API works offline, has no rate limits, and is typically much faster than the Web API. It is intended for code running on the user's own computer, like utilities and command-line tools, that would otherwise need to read directly from the SQLite database or fall back to the Web API.
51
-
52
-
The local API must be enabled in Zotero's preferences (Settings → Advanced → "Allow other applications on this computer to communicate with Zotero"). Requests will return `403 Forbidden` if it is not enabled.
53
-
54
-
The base URL is
55
-
56
-
http://localhost:23119/api/
57
-
58
-
Most endpoints documented below work identically when accessed under that prefix. The notable differences from the Web API are:
59
-
60
-
- Only API version 3 is supported, and only one version will ever be supported at a time. If a future version is released and your client needs to work against both old and new copies of Zotero, request `/api/` first and read the `Zotero-API-Version` response header to determine which version the running client speaks before making further requests.
61
-
- Write requests are currently unsupported. Only `GET` is accepted. (An upcoming version of Zotero will support write requests.)
62
-
- There is no authentication. Anyone with access to the loopback interface can read the user's library, so do not forward the port or otherwise expose it externally.
63
-
- Only data for the locally logged-in user is available. Pass `0` as the user ID or the user's actual numeric ID, which can be found on the [API Keys](/settings/keys) page. Requests for any other user ID return `400`.
64
-
- Group metadata is limited to what's needed to identify the group; permissions, member lists, and similar details are not included.
65
-
- Atom is not supported. Requests with `format=atom` or `content=atom` return `501 Not Implemented`.
66
-
- Item type and field endpoints (see [Item Types and Fields](dev/web_api/v3/types_and_fields)) return localized names in the user's locale. The `locale` query parameter is ignored. `/api/creatorFields` is the exception and always returns English names, matching the Web API.
67
-
- Results are not paginated by default. The local API will return the full set of matching objects in one response, since nothing has to be transferred over the network. The `limit` and `start` parameters still work if you want them, and `Link` headers are still included.
68
-
- The implementation aims to match the Web API's documented behavior but does not attempt to replicate every implementation detail. Sort order on equal keys, quicksearch matching, and the exact JSON produced for an object may differ in minor ways. Clients that depend on undefined behavior or unusual corner cases of the Web API should be tested against both implementations.
69
-
70
-
The local API also supports a few things the Web API does not:
71
-
72
-
-`<userOrGroupPrefix>/searches/<searchKey>/items` returns the items matching a saved search. The Web API exposes search metadata but does not actually execute searches.
73
-
-`<userOrGroupPrefix>/items/<itemKey>/file` returns a `302` redirect to a `file://` URL for the attachment on disk, and `/file/view` does the same. `/file/view/url` returns the URL as plain text rather than redirecting.
74
-
75
-
Responses include a `Zotero-Schema-Version` header reflecting the schema version of the local Zotero instance, which may lag behind or run ahead of the version served by the Web API.
76
-
77
-
The remainder of this page documents the API as a whole. Sections below note where local API behavior diverges from the Web API.
50
+
The Zotero desktop client exposes a local implementation of this API on `localhost:23119` under `/api/`, serving data from the user's local database. See [Local API](dev/web_api/v3/local_api) for details. The sections below note where local API behavior diverges from the Web API.
78
51
79
52
## Resources
80
53
@@ -182,7 +155,7 @@ Export formats, valid only for item requests, produce output in the specified fo
182
155
</tbody>
183
156
</table>
184
157
185
-
The [local API](#local_api) does not support `format=atom`; requests using it return `501 Not Implemented`. All other formats are supported.
158
+
The [local API](dev/web_api/v3/local_api) does not support `format=atom`; requests using it return `501 Not Implemented`. All other formats are supported.
186
159
187
160
### Parameters for "format=json"
188
161
@@ -239,7 +212,7 @@ If multiple formats are requested, <code><content></code> will contain mul
239
212
</tbody>
240
213
</table>
241
214
242
-
The Atom parameters above do not apply to the [local API](#local_api), which does not produce Atom output.
215
+
The Atom parameters above do not apply to the [local API](dev/web_api/v3/local_api), which does not produce Atom output.
243
216
244
217
### Parameters for "format=bib", "include/content=bib", "include/content=citation"
245
218
@@ -284,7 +257,7 @@ The following bibliographic data formats can be used as `format`, `include`, and
284
257
|`since`| integer |`0`| Return only objects modified after the specified library version, returned in a previous `Last-Modified-Version` header. See [Syncing](dev/web_api/v3/syncing) for more info. |
285
258
|`tag`|[search syntax](#search_syntax)| null | Tag search |
286
259
287
-
The [local API](#local_api) accepts the same search parameters but uses Zotero's local quicksearch implementation, so the set of items returned by a given `q` value may not match the Web API exactly.
260
+
The [local API](dev/web_api/v3/local_api) accepts the same search parameters but uses Zotero's local quicksearch implementation, so the set of items returned by a given `q` value may not match the Web API exactly.
288
261
289
262
### Search Parameters (Items Endpoints)
290
263
@@ -340,7 +313,7 @@ The following parameters are valid only for multi-object read requests such as `
340
313
|`limit`| integer 1-100\*|`25`| The maximum number of results to return with a single request. Required for export formats. |
341
314
|`start`| integer |`0`| The index of the first result. Combine with the limit parameter to select a slice of the available results. |
342
315
343
-
The [local API](#local_api) does not impose a default or maximum `limit`. If `limit` is omitted, all matching objects are returned in one response. Pagination parameters and `Link` headers still work for clients that want them.
316
+
The [local API](dev/web_api/v3/local_api) does not impose a default or maximum `limit`. If `limit` is omitted, all matching objects are returned in one response. Pagination parameters and `Link` headers still work for clients that want them.
344
317
345
318
#### Total Results
346
319
@@ -368,7 +341,7 @@ In addition to making conditional requests, clients downloading data for entire
368
341
369
342
See [Syncing](dev/web_api/v3/syncing) for more information on library and object versioning.
370
343
371
-
Conditional requests work the same way against the [local API](#local_api), but local responses are already inexpensive to produce, so aggressive caching on the client side is less important. The `?since=` parameter is also supported and is the preferred way to fetch only changed objects from a large local library.
344
+
Conditional requests work the same way against the [local API](dev/web_api/v3/local_api), but local responses are already inexpensive to produce, so aggressive caching on the client side is less important. The `?since=` parameter is also supported and is the preferred way to fetch only changed objects from a large local library.
372
345
373
346
## Rate Limiting
374
347
@@ -440,7 +413,7 @@ Several examples of read request URLs and their responses:
440
413
</tbody>
441
414
</table>
442
415
443
-
The [local API](#local_api) does not currently apply rate limiting.
416
+
The [local API](dev/web_api/v3/local_api) does not currently apply rate limiting.
444
417
445
418
## HTTP Status Codes
446
419
@@ -456,10 +429,11 @@ Passing an `Expect` header, which is unsupported, will result in a `417 Expectat
456
429
457
430
`429 Too Many Requests` indicates that the client has been [rate-limited](#rate_limiting).
458
431
459
-
The [local API](#local_api) returns `403 Forbidden` when the local API preference is not enabled and `501 Not Implemented` when a request asks for something it does not support (Atom output, or an API version other than 3 on an endpoint other than `/api/`).
432
+
The [local API](dev/web_api/v3/local_api) returns `403 Forbidden` when the local API preference is not enabled and `501 Not Implemented` when a request asks for something it does not support (Atom output, or an API version other than 3 on an endpoint other than `/api/`).
Recent versions of the Zotero desktop client expose a local implementation of the [Zotero Web API](dev/web_api/v3/basics) on `localhost:23119` under `/api/`, serving data from the user's local database. Because nothing touches the network, the local API works offline, has no rate limits, and is typically much faster than the Web API. It is intended for code running on the user's own computer, like utilities and command-line tools, that would otherwise need to read directly from the SQLite database or fall back to the Web API.
4
+
5
+
The local API must be enabled in Zotero's preferences (Settings → Advanced → "Allow other applications on this computer to communicate with Zotero"). Requests will return `403 Forbidden` if it is not enabled.
6
+
7
+
The base URL is
8
+
9
+
http://localhost:23119/api/
10
+
11
+
Most endpoints documented on the [Basics](dev/web_api/v3/basics) page work identically when accessed under that prefix. The notable differences from the Web API are:
12
+
13
+
- Only API version 3 is supported, and only one version will ever be supported at a time. If a future version is released and your client needs to work against both old and new copies of Zotero, request `/api/` first and read the `Zotero-API-Version` response header to determine which version the running client speaks before making further requests.
14
+
- Write requests are currently unsupported. Only `GET` is accepted. (An upcoming version of Zotero will support write requests.)
15
+
- There is no authentication. Anyone with access to the loopback interface can read the user's library, so do not forward the port or otherwise expose it externally.
16
+
- Only data for the locally logged-in user is available. Pass `0` as the user ID or the user's actual numeric ID, which can be found on the [API Keys](/settings/keys) page. Requests for any other user ID return `400`.
17
+
- Group metadata is limited to what's needed to identify the group; permissions, member lists, and similar details are not included.
18
+
- Atom is not supported. Requests with `format=atom` or `content=atom` return `501 Not Implemented`.
19
+
- Item type and field endpoints (see [Item Types and Fields](dev/web_api/v3/types_and_fields)) return localized names in the user's locale. The `locale` query parameter is ignored. `/api/creatorFields` is the exception and always returns English names, matching the Web API.
20
+
- Results are not paginated by default. The local API will return the full set of matching objects in one response, since nothing has to be transferred over the network. The `limit` and `start` parameters still work if you want them, and `Link` headers are still included.
21
+
- The implementation aims to match the Web API's documented behavior but does not attempt to replicate every implementation detail. Sort order on equal keys, quicksearch matching, and the exact JSON produced for an object may differ in minor ways. Clients that depend on undefined behavior or unusual corner cases of the Web API should be tested against both implementations.
22
+
23
+
The local API also supports a few things the Web API does not:
24
+
25
+
-`<userOrGroupPrefix>/searches/<searchKey>/items` returns the items matching a saved search. The Web API exposes search metadata but does not actually execute searches.
26
+
-`<userOrGroupPrefix>/items/<itemKey>/file` returns a `302` redirect to a `file://` URL for the attachment on disk, and `/file/view` does the same. `/file/view/url` returns the URL as plain text rather than redirecting.
27
+
28
+
Responses include a `Zotero-Schema-Version` header reflecting the schema version of the local Zotero instance, which may lag behind or run ahead of the version served by the Web API.
29
+
30
+
The [Basics](dev/web_api/v3/basics) page documents the API as a whole and notes where local API behavior diverges from the Web API.
0 commit comments