Download the PHP package hedii/zotero-api without Composer
On this page you can find all versions of the php package hedii/zotero-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hedii/zotero-api
More information about hedii/zotero-api
Files in hedii/zotero-api
Package zotero-api
Short Description A php wrapper for zotero web api.
License MIT
Homepage https://github.com/hedii/zotero-api
Informations about the package zotero-api
Zotero Api
A php wrapper for zotero web api.
Table of contents
- Table of contents
- Installation
- Usage
- Instantiation
- User and group libraries
- Items
- Multiple items
- Single item
- Top level items
- Items in the trash
- Child items
- Item tags
- Collections
- Multiple collections
- Single collection
- Items in a collection
- Top level items in a collection
- Collection tags
- Sub collections
- Versions
- Tags
- Searches
- Multiple searches
- Single search
- Key
- Groups
- Sorting and pagination
- Sorting
- Direction
- Limit
- Start
- Request timeout
- Connection timeout
- Sending a request and getting a response
- Sending the request
- Response body
- Response json
- Response headers
- Response status code
- Response reason phrase
- Raw query
- Examples
- Testing
- License
Installation
Install via composer
Usage
Instantiation
ZoteroApi has to be instantiated with an api key. You can generate a zotero api key here if you have an account on zotero.org.
User and group libraries
Every call to zotero web api has to be made on a user or a group library (except for key($apiKey)
method).
This is reflected on this package by the fact that you always have to call the method user($userId)
or the method group($groupId)
at the beginning of each call.
Items
Multiple items
To access all items in a library, call the items()
method.
Single item
To access a specific item in a library, call items($itemKey)
method with the item key as a parameter.
Top level items
To access only top level items in a library, call top()
method just after the items()
method.
Items in the trash
To access items that have been put in the trash, call trash()
method just after items()
method.
Child items
To access an item's child items, call children()
method just after items($itemKey)
method.
Item tags
To access all tags associated with a specific item, call tags()
method just after items($itemKey)
method.
Collections
Multiple collections
To access all collections in a library, call the collections()
method.
Single collection
To access a specific collection in a library, call collections($collectionKey)
method with the collection key as a parameter.
Items in a collection
To access all items in a collection, call items()
method after calling a specific collection.
Top level items in a collection
To access only top items in a collection, call top()
method after calling items in a specific collection.
Collection tags
To access all tags associated with a specific collection, call tags()
method just after collections($collectionKey)
method.
Sub collections
To access sub collections within a specific collection, call subCollection()
method just after collections($collectionKey)
method.
Versions
To get all resources (either collections or items) versions, call versions()
method after items()
or collections()
method.
Tags
All tags
To access all tags in a library, call tags()
method.
Matching tags
To access tags matching a specific name in a library, call tags($tagName)
method with $tagName
a string as a parameter.
Searches
Multiple searches
To access all saved searches in a library, call searches()
method.
Single search
To access a specific saved search in a library, call searches($searchKey)
method with the search key as a parameter.
Key
To access the privilege information of a given api key, call key($apiKey)
method on the ZoteroApi
instance.
Groups
To access all groups the current API key has access to, call groups()
method just after user($userId)
method.
Sorting and pagination
Sorting and pagination methods can be called after calling a resource method.
Sorting
The sortBy($value)
method set by what type of value the response will by sorted.
The $value
parameter has to be one of :
- dateAdded
- dateModified
- title
- creator
- type
- date
- publisher
- publicationTitle
- journalAbbreviation
- language
- accessDate
- libraryCatalog
- callNumber
- rights
- addedBy
- numItems
Direction
The direction($value)
method set the sorting direction of the field specified by the sortBy($value)
method.
The $value
parameter has to be one of :
- asc
- desc
Limit
The limit($value)
method set the maximum number of results to return with a single request.
The $value
parameter has to be an integer between 1 and 100. The default number of result provided by zotero web api is 50.
Start
The start($value)
method determines the index of the first result.
The $value
parameter has to be an integer. The default starting index is 0.
Combine with the limit parameter to select a slice of the available results.
Request timeout
Request timeout can be set using the setTimeout($timeout)
method, with $timeout
an integer in milliseconds as a parameter.
Default request timeout is 0.
You can get the current request timeout value using the getTimeout()
method.
Connection timeout
Connection timeout can be set using the setConnectionTimeout($connectionTimeout)
method, with $connectionTimeout
an integer in milliseconds as a parameter.
Default connection timeout is 0.
You can get the current connection timeout value using the getConnectionTimeout()
method.
Sending a request and getting a response
Sending the request
To send a request after chaining available methods, call the send()
method.
Response body
To access the response body as an array, call the getBody()
method on the response.
Response json
To access the response body as a json string, call the getJson()
method on the response.
Response headers
To access the response headers as an array, call the getHeaders()
method on the response.
Response status code
To access the response status code, call the getStatusCode()
method on the response.
Response reason phrase
To access the response reason phrase, call the getReasonPhrase()
method on the response.
Raw query
To build the request url yourself, call the raw($url)
method, with $url
a string as a parameter.
Examples
Testing
License
hedii/zotero-api is released under the MIT Licence. See the bundled LICENSE file for details.