Skip to content

Commit 649c1b6

Browse files
committed
Separate local API into its own file
1 parent 04a91f8 commit 649c1b6

3 files changed

Lines changed: 43 additions & 38 deletions

File tree

content/dev/web_api/v3/basics.md

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Zotero Web API Documentation
22

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.
44

55
## Base URL
66

77
The base URL for all API requests is
88

99
https://api.zotero.org
1010

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).)
1212

1313
## API Versioning
1414

@@ -43,38 +43,11 @@ Use of an HTTP header is recommended, as it allows use of URLs returned from the
4343

4444
`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.
4545

46-
The [local API](#local_api) does not use authentication.
46+
The [local API](dev/web_api/v3/local_api) does not use authentication.
4747

4848
## Local API
4949

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.
7851

7952
## Resources
8053

@@ -182,7 +155,7 @@ Export formats, valid only for item requests, produce output in the specified fo
182155
</tbody>
183156
</table>
184157

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.
186159

187160
### Parameters for "format=json"
188161

@@ -239,7 +212,7 @@ If multiple formats are requested, <code>&lt;content&gt;</code> will contain mul
239212
</tbody>
240213
</table>
241214

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.
243216

244217
### Parameters for "format=bib", "include/content=bib", "include/content=citation"
245218

@@ -284,7 +257,7 @@ The following bibliographic data formats can be used as `format`, `include`, and
284257
| `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. |
285258
| `tag` | [search syntax](#search_syntax) | null | Tag search |
286259

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.
288261

289262
### Search Parameters (Items Endpoints)
290263

@@ -340,7 +313,7 @@ The following parameters are valid only for multi-object read requests such as `
340313
| `limit` | integer 1-100\* | `25` | The maximum number of results to return with a single request. Required for export formats. |
341314
| `start` | integer | `0` | The index of the first result. Combine with the limit parameter to select a slice of the available results. |
342315

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.
344317

345318
#### Total Results
346319

@@ -368,7 +341,7 @@ In addition to making conditional requests, clients downloading data for entire
368341

369342
See [Syncing](dev/web_api/v3/syncing) for more information on library and object versioning.
370343

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.
372345

373346
## Rate Limiting
374347

@@ -440,7 +413,7 @@ Several examples of read request URLs and their responses:
440413
</tbody>
441414
</table>
442415

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.
444417

445418
## HTTP Status Codes
446419

@@ -456,10 +429,11 @@ Passing an `Expect` header, which is unsupported, will result in a `417 Expectat
456429

457430
`429 Too Many Requests` indicates that the client has been [rate-limited](#rate_limiting).
458431

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/`).
460433

461434
## Additional API Documentation
462435

436+
- [Local API](dev/web_api/v3/local_api)
463437
- [Write Requests](dev/web_api/v3/write_requests)
464438
- [File Uploads](dev/web_api/v3/file_upload)
465439
- [Syncing](dev/web_api/v3/syncing)

content/dev/web_api/v3/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This is the default version of the API, and it is recommended for new developmen
55
## API Documentation
66

77
- [Basics](dev/web_api/v3/basics)
8+
- [Local API](dev/web_api/v3/local_api)
89
- [Item Types/Fields](dev/web_api/v3/types_and_fields)
910
- [Write Requests](dev/web_api/v3/write_requests)
1011
- [File Uploads](dev/web_api/v3/file_upload)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Zotero Local API
2+
3+
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

Comments
 (0)