{"id":16776857,"url":"https://github.com/renanbr/crossref-client","last_synced_at":"2025-04-10T20:14:33.282Z","repository":{"id":36876138,"uuid":"41183117","full_name":"renanbr/crossref-client","owner":"renanbr","description":"Crossref REST API client written in PHP.","archived":false,"fork":false,"pushed_at":"2023-11-15T19:10:06.000Z","size":82,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-03-15T03:34:42.310Z","etag":null,"topics":["api-client","crossref","crossref-api","crossref-client","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/renanbr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-22T00:18:25.000Z","updated_at":"2023-10-04T03:19:17.000Z","dependencies_parsed_at":"2024-10-13T07:11:21.518Z","dependency_job_id":"1d0a4522-7699-4f6f-92d2-38b9b0a3c827","html_url":"https://github.com/renanbr/crossref-client","commit_stats":{"total_commits":44,"total_committers":3,"mean_commits":"14.666666666666666","dds":"0.15909090909090906","last_synced_commit":"d4d66fdf4baca4dff5892a89a584f41e59764271"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renanbr%2Fcrossref-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renanbr%2Fcrossref-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renanbr%2Fcrossref-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renanbr%2Fcrossref-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/renanbr","download_url":"https://codeload.github.com/renanbr/crossref-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248288393,"owners_count":21078903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","crossref","crossref-api","crossref-client","php"],"created_at":"2024-10-13T07:11:09.466Z","updated_at":"2025-04-10T20:14:33.259Z","avatar_url":"https://github.com/renanbr.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ePHP CrossRef Client\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n    This is a library for the\n    \u003ca href=\"https://www.crossref.org/services/metadata-delivery/rest-api/\"\u003eCrossref REST API\u003c/a\u003e\n    written in \u003ca href=\"https://php.net\"\u003ePHP\u003c/a\u003e.\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.crossref.org/services/metadata-delivery/rest-api/\"\u003e\n        \u003cimg src=\"https://assets.crossref.org/logo/crossref-metadata-apis-200.svg\" width=\"200\" height=\"83\" alt=\"Crossref Metadata APIs logo\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://php.net\"\u003e\n        \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/2/27/PHP-logo.svg\" height=\"83\" alt=\"PHP logo\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n![Tests](https://github.com/renanbr/crossref-client/workflows/Tests/badge.svg)\n[![codecov](https://codecov.io/gh/renanbr/crossref-client/branch/master/graph/badge.svg)](https://codecov.io/gh/renanbr/crossref-client)\n![Static Analysis](https://github.com/renanbr/crossref-client/workflows/Static%20Analysis/badge.svg)\n![Coding Standards](https://github.com/renanbr/crossref-client/workflows/Coding%20Standards/badge.svg)\n\n## Table of contents\n\n* [Introduction](#introduction)\n* [Installing](#installing)\n* [Usage](#usage)\n   * [Singletons](#singletons)\n   * [Determine existence of a singleton](#determine-existence-of-a-singleton)\n   * [Lists](#lists)\n* [Configuration](#configuration)\n   * [Caching results](#caching-results)\n   * [Identifying your script](#identifying-your-script)\n   * [Tying to a specific major version](#tying-to-a-specific-major-version)\n   * [Rate limits](#rate-limits)\n* [Handling errors](#handling-errors)\n\n## Introduction\n\nThis is **NOT** an official library! The intent of this library is to provide an easy way to make requests to the CrossRef's REST API. You **SHOULD** read this documentation in conjunction with the [official documentation](https://github.com/CrossRef/rest-api-doc).\n\nHighlighted features:\n\n- You don't need to worry about making HTTP requests;\n- Proper exceptions are thrown if an HTTP error occurs;\n- You receive responses as-is, without overlay;\n- [Filter](https://github.com/CrossRef/rest-api-doc#filter-names) and [facet](https://github.com/CrossRef/rest-api-doc#facet-counts) parameters are encoded if needed;\n- You can [cache responses](https://github.com/CrossRef/rest-api-doc#etiquette) easily;\n- You can [identify yourself](https://github.com/CrossRef/rest-api-doc#good-manners--more-reliable-service), then you can benefit better service;\n- You can [tie to a specific major version of the API](https://github.com/CrossRef/rest-api-doc#how-to-manage-api-versions);\n- Your application complies with the [rate limit](https://github.com/CrossRef/rest-api-doc#rate-limits) (it works better if cache is configured).\n\nLibrary's summary:\n\n```php\nclass RenanBr\\CrossRefClient\n{\n    // Returns JSON decoded as array\n    public function request($path, array $parameters = []);\n\n    // Returns boolean\n    public function exists($path);\n\n    public function setUserAgent($userAgent);\n    public function setCache(Psr\\SimpleCache\\CacheInterface $cache);\n    public function setVersion($version);\n}\n```\n\n## Installing\n\n```bash\ncomposer require renanbr/crossref-client ^1\n```\n\n## Usage\n\n### Singletons\n\n\u003e Singletons are single results. Retrieving metadata for a specific identifier (e.g. DOI, ISSN, funder_identifier) typically returns in a singleton result.\n\nSee: https://github.com/CrossRef/rest-api-doc#singletons\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n$client = new RenanBr\\CrossRefClient();\n$work = $client-\u003erequest('works/10.1037/0003-066X.59.1.29');\nprint_r($work);\n```\n\nThe above example will output:\n\n```\nArray\n(\n    [status] =\u003e ok\n    [message-type] =\u003e work\n    [message-version] =\u003e 1.0.0\n    [message] =\u003e Array\n        (\n            ...\n\n            [DOI] =\u003e 10.1037/0003-066x.59.1.29\n            [type] =\u003e journal-article\n\n            ...\n\n            [title] =\u003e Array\n                (\n                    [0] =\u003e How the Mind Hurts and Heals the Body.\n                )\n\n            ...\n        )\n)\n```\n\n### Determine existence of a singleton\n\n\u003e (...) [You can] determine \"existence\" of a singleton. The advantage of this technique is that it is very fast because it does not return any metadata (...)\n\nSee: https://github.com/CrossRef/rest-api-doc#headers-only\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n$client = new RenanBr\\CrossRefClient();\n$exists = $client-\u003eexists('members/98');\nvar_dump($exists);\n```\n\nThe above example will output:\n\n```\nbool(true)\n```\n\n### Lists\n\n\u003e Lists results can contain multiple entries. Searching or filtering typically returns a list result.\n\nA list has two parts: Summary; and Items. Normally, an API list result will return both.\n\nSee: https://github.com/CrossRef/rest-api-doc#lists\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n$client = new RenanBr\\CrossRefClient();\n\n$parameters = [\n    'query' =\u003e 'global state',\n    'filter' =\u003e [\n        'has-orcid' =\u003e true,\n    ],\n];\n$result = $client-\u003erequest('works', $parameters);\n\nforeach ($result['message']['items'] as $work) {\n    // ...\n}\n```\n\n## Configuration\n\n### Caching results\n\n\u003e Cache data so you don't request the same data over and over again.\n\nSee: https://github.com/CrossRef/rest-api-doc#etiquette\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n$client = new RenanBr\\CrossRefClient();\n$client-\u003esetCache(new voku\\cache\\CachePsr16());\n\n// ...\n```\n\nThe above example uses [voku/simple-cache](https://github.com/voku/simple-cache) as cache implementation, but you can use [any PSR-16 implementation](https://packagist.org/providers/psr/simple-cache-implementation) because `setCache()` accept [Psr\\SimpleCache\\CacheInterface](http://www.php-fig.org/psr/psr-16/#21-cacheinterface) as argument.\n\n### Identifying your script\n\n\u003e As of September 18th 2017 any API queries that use HTTPS and have appropriate contact information will be directed to a special pool of API machines that are reserved for polite users.\n\nSee: https://github.com/CrossRef/rest-api-doc#good-manners--more-reliable-service\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n$client = new RenanBr\\CrossRefClient();\n$client-\u003esetUserAgent('GroovyBib/1.1 (https://example.org/GroovyBib/; mailto:GroovyBib@example.org)');\n\n// ...\n```\n\nThe above example makes all subsequent requests attach the contact information given.\n\n### Tying to a specific major version\n\n\u003e If you need to tie your implementation to a specific major version of the API, you can do so by using version-specific routes. The default route redirects to the most recent version of the API.\n\nSee: https://github.com/CrossRef/rest-api-doc#how-to-manage-api-versions\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n$client = new RenanBr\\CrossRefClient();\n$client-\u003esetVersion('v55');\n\n// ...\n```\n\nThe above example tie all subsequent requests to the API version `v55`.\n\n### Rate limits\n\nBy default, this library conforms to the rate limit imposed by the API for the **current execution**.\n\nIf you want to keep this behavior **across multiple executions**, you must configure the cache, as mentioned above.\n\n## Handling errors\n\nAs this library uses [guzzlehttp/guzzle](http://guzzlephp.org) internally. Please refer to the [Guzzle Exceptions documentation](http://docs.guzzlephp.org/en/stable/quickstart.html#exceptions) to see how to handle exceptions properly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenanbr%2Fcrossref-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frenanbr%2Fcrossref-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenanbr%2Fcrossref-client/lists"}