sdk-generator / elife-sdk
Unofficial PHP SDK for the eLife API: research articles, reviewed preprints, digests, collections, events and more from the eLife open-access journal. Generated from eLife's published RAML.
Requires
- php: ^8.4
- sdk-generator/sdk-runtime: ^1.15.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
None
Provides
None
Conflicts
None
Replaces
- dmorenof/elife-sdk: v0.1.1
This package is auto-updated.
Last update: 2026-12-03 22:17:22 UTC
README
The eLife journal's articles, preprints and magazine content as typed PHP, no API key.
Research articles (VOR and POA), reviewed preprints, subjects, collections, digests, interviews, podcasts, events, people and search from the eLife API, with every answer read into a model. The API is open and needs no key.
Unofficial. Not affiliated with, endorsed by or supported by eLife Sciences Publications, Ltd. See NOTICE.md.
Why this SDK
- Generated from a RAML API description. eLife describes its API in RAML 1.0 with draft-04 JSON schemas; the generator reads that document as it is published.
- Free API without a key: install and call.
- Checked against the live service. An SDK generated from this description made 125 real calls across its operations: 123 answers matched it, and the 2 that did not found a gap in eLife's own description, corrected in contract/SOURCE.md.
- Versioned media types handled. eLife serves
application/vnd.elife.article-vor+json; version=8and older versions; the SDK asks for and reads the newest. - Generated from eLife's published RAML, never edited by hand.
src/is produced by sdk-generator from the RAML 1.0 document (with its JSON schemas) described in contract/SOURCE.md, on top of the shared sdk-runtime: when the source changes you regenerate, you do not patch. - Typed end to end. 48 operations and 824 typed request, answer and model classes. A request is a model whose fields are checked where you assign them (PHP 8.4 property hooks); an answer is a model; a list is a typed collection. PHPStan at the maximum level reports no error on the whole SDK.
- One way to fail. An HTTP answer the contract does not declare as success is an
ApiExceptionthat keeps the raw response and, when the API documents it, the decoded error as a model. Network failures keep their own type. - Production controls included. PSR-18 HTTP client (Guzzle by default), timeouts (30 s / 10 s by default), retries with
Retry-After, redirect policy, middleware and per-environment servers, all in oneConfigurationobject.
Install
PHP 8.4 or later.
composer require sdk-generator/elife-sdk
Quick start
<?php use ElifeSDK\Articles; use ElifeSDK\Configuration; use ElifeSDK\ELifeSciencesAPISDK; use ElifeSDK\GetParams\Subjects as SubjectsParams; use ElifeSDK\Subjects; ELifeSciencesAPISDK::configure(new Configuration()); $params = new SubjectsParams(); $params->perPage = 5; $subjects = Subjects::get($params); echo $subjects->total, " subjects\n"; foreach ($subjects->items as $subject) { echo '- ', $subject->name, "\n"; } $article = Articles::getById(9560); // a research article (VOR or POA model) echo $article->title, "\n";
The same example is in examples/quickstart.php. Every operation is listed in docs/OPERATIONS.md.
What it covers
48 operations. The biggest areas:
| Area | Operations |
|---|---|
articles |
5 |
digests |
3 |
metrics |
3 |
annual-reports |
2 |
blog-articles |
2 |
collections |
2 |
covers |
2 |
events |
2 |
highlights |
2 |
interviews |
2 |
Handling errors
use Dmorenof\SdkRuntime\ApiException; try { // ... any call from the quick start } catch (ApiException $e) { echo $e->response->status, "\n"; // the HTTP status echo $e->response->body, "\n"; // the raw body, always kept var_dump($e->error); // the decoded error model, when the API documents one }
Configuration
Configuration is the only place to set anything: baseUrl, securityCredentials, headers, timeout, connectTimeout, retryPolicy, redirectPolicy, middleware, httpClient (any PSR-18 client), serverVariables. Use Client::connect($configuration) instead of the static facades when you need several independent connections.
Good to know
- The API is open; eLife asks heavy users to be considerate. Cache what you can.
- Article content (abstracts, bodies) is a typed tree of blocks (paragraphs, sections, figures, tables...): each block is its own model.
- Answers are versioned media types: the SDK reads the newest version of each, as a client that names none receives it.
- Version
0.1.0is a first release: the API of the SDK follows the source description, and a regenerated one can rename classes. Pin a version.
Documentation
- Operations catalog
- Vendor documentation
- sdk-runtime (what every SDK shares) and sdk-generator
- CHANGELOG.md, CONTRIBUTING.md, SECURITY.md
License
MIT, see LICENSE.md. The license covers this SDK's code, not the API, its trademarks or its terms: see NOTICE.md.