references/search-params.md
3.7 KB查看排版效果| 1 | # Search & Request Parameters |
| 2 | |
| 3 | Supported parameters can be passed directly to a Read API call, or configured for the next call with `add_parameters()`. Pass a format and its options together on one call: a later call with keyword arguments can reset a preconfigured export to JSON in 1.15.2. |
| 4 | |
| 5 | ```python |
| 6 | # Inline parameters (valid for one call only) |
| 7 | results = zot.items(q='climate change', limit=50, sort='date', direction='desc') |
| 8 | |
| 9 | # Configure the next call |
| 10 | zot.add_parameters(limit=50, sort='dateAdded') |
| 11 | results = zot.items() |
| 12 | ``` |
| 13 | |
| 14 | ## Available Parameters |
| 15 | |
| 16 | | Parameter | Type | Description | |
| 17 | |-----------|------|-------------| |
| 18 | | `q` | str | Quick search — titles and creator fields by default | |
| 19 | | `qmode` | str | `'titleCreatorYear'` (default) or `'everything'` (full-text) | |
| 20 | | `itemType` | str | Filter by item type. See search syntax for operators | |
| 21 | | `tag` | str or list | Filter by tag(s). Multiple tags = AND logic | |
| 22 | | `since` | int | Return only objects modified after this library version | |
| 23 | | `sort` | str | Sort field (see below) | |
| 24 | | `direction` | str | `'asc'` or `'desc'` | |
| 25 | | `limit` | int | 1–100, or `None` | |
| 26 | | `start` | int | Zero-based offset into result set (default 0) | |
| 27 | | `format` | str | Response format (see exports.md) | |
| 28 | | `itemKey` | str | Comma-separated item keys (up to 50) | |
| 29 | | `content` | str | Legacy Atom content; remote API only | |
| 30 | | `include` | str | JSON members such as `'data,bib'`, `'citation'`, or `'csljson'` | |
| 31 | | `style` | str | CSL style name (used with `content='bib'`) | |
| 32 | | `linkwrap` | str | `'1'` to wrap URLs in `<a>` tags in bibliography output | |
| 33 | |
| 34 | ## Sort Fields |
| 35 | |
| 36 | `dateAdded`, `dateModified`, `title`, `creator`, `itemType`, `date`, `publisher`, |
| 37 | `publicationTitle`, `journalAbbreviation`, `language`, `accessDate`, |
| 38 | `libraryCatalog`, `callNumber`, `rights`, `addedBy`; `numItems` applies to tag lists. |
| 39 | |
| 40 | ## Tag Search Syntax |
| 41 | |
| 42 | ```python |
| 43 | # Single tag |
| 44 | zot.items(tag='machine learning') |
| 45 | |
| 46 | # Multiple tags — AND logic (items must have all tags) |
| 47 | zot.items(tag=['climate', 'adaptation']) |
| 48 | |
| 49 | # OR logic (items with any tag) |
| 50 | zot.items(tag='climate || adaptation') |
| 51 | |
| 52 | # Exclude a tag |
| 53 | zot.items(tag='-retracted') |
| 54 | ``` |
| 55 | |
| 56 | ## Item Type Filtering |
| 57 | |
| 58 | ```python |
| 59 | # Single type |
| 60 | zot.items(itemType='journalArticle') |
| 61 | |
| 62 | # OR multiple types |
| 63 | zot.items(itemType='journalArticle || book') |
| 64 | |
| 65 | # Exclude a type |
| 66 | zot.items(itemType='-note') |
| 67 | ``` |
| 68 | |
| 69 | Common item types: `journalArticle`, `book`, `bookSection`, `conferencePaper`, |
| 70 | `thesis`, `report`, `dataset`, `preprint`, `note`, `attachment`, `webpage`, |
| 71 | `patent`, `statute`, `case`, `hearing`, `interview`, `letter`, `manuscript`, |
| 72 | `map`, `artwork`, `audioRecording`, `videoRecording`, `podcast`, `film`, |
| 73 | `radioBroadcast`, `tvBroadcast`, `presentation`, `encyclopediaArticle`, |
| 74 | `dictionaryEntry`, `forumPost`, `blogPost`, `instantMessage`, `email`, |
| 75 | `document`, `computerProgram`, `bill`, `newspaperArticle`, `magazineArticle` |
| 76 | |
| 77 | ## Examples |
| 78 | |
| 79 | ```python |
| 80 | # Recent journal articles matching query, sorted by date |
| 81 | zot.items(q='CRISPR', itemType='journalArticle', sort='date', direction='desc', limit=20) |
| 82 | |
| 83 | # Items modified since a known library version |
| 84 | zot.items(since=4000) |
| 85 | |
| 86 | # Items with a specific tag, offset for pagination |
| 87 | zot.items(tag='to-read', limit=25, start=25) |
| 88 | |
| 89 | # Full-text search |
| 90 | zot.items(q='gene editing', qmode='everything', limit=10) |
| 91 | ``` |
| 92 | |
| 93 | For tag endpoints, `qmode='contains'` is the default; prefix matching requires `qmode='startsWith'`. Read parameters are endpoint-specific, not valid on every method. `limit=None` omits the limit: it does **not** fetch a whole remote JSON item list (the server defaults to 25). Local and remote quick search implementations may return different matches. Source: [search, sorting, and pagination contracts](https://www.zotero.org/support/dev/web_api/v3/basics#search_parameters). |
文件内容是平台检查时读出的文本,只供查看。平台不会运行包里的任何脚本或程序。

