PHPackages                             wikisource/api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. wikisource/api

ActiveLibrary

wikisource/api
==============

A PHP API to Wikisources (all languages).

2.0.8(1y ago)117341GPL-2.0-or-laterPHP

Since Nov 4Pushed 1y ago6 watchersCompare

[ Source](https://github.com/wikisource/api)[ Packagist](https://packagist.org/packages/wikisource/api)[ RSS](/packages/wikisource-api/feed)WikiDiscussions main Synced 2mo ago

READMEChangelog (9)Dependencies (12)Versions (29)Used By (0)

Wikisource API
==============

[](#wikisource-api)

This is an client API library for retrieving data from [Wikisources](https://wikisource.org/). It uses data from Wikidata where it can, or MediaWiki API data from specific Wikisources, or resorts to scraping HTML where that's the only option.

[![CI](https://github.com/wikisource/api/actions/workflows/ci.yml/badge.svg)](https://github.com/wikisource/api/actions/workflows/ci.yml)

Features (some are in development and are not yet functional):

- List all Wikisources.
- Get metadata about a single Wikisource: language code, language name (in that language), and information about namespaces (their names and IDs).
- List all Works in a Wikisource.
- Get metadata about a single Work on a Wikisource: URL, page name, work title, author, year of publication, proofreading quality, and a list of Index Pages used by the Work.
- Get metadata about a single Index Page on a Wikisource: URL, page name, list of Pages, and proofreading quality.
- Get metadata about a single proofreading Page on a Wikisource (i.e. a wiki-page in the Page namespace): URL, wiki-page name, page number (in Djvu/PDF), page label (in the Index's page-list), and proofreading quality.

Installation
------------

[](#installation)

Install with [Composer](https://getcomposer.org/):

```
$ composer require wikisource/api
```

You might also want [something that implements `psr/log`](https://packagist.org/providers/psr/log-implementation)and [something that implements `psr/cache`](https://packagist.org/providers/psr/cache-implementation), if you want to use the logging and caching features of this library.

Usage
-----

[](#usage)

Find all Wikisources:

```
$wsApi = new \Wikisource\Api\WikisourceApi();
$wikisources = $wsApi->fetchWikisources();
```

Get a single work:

```
$wsApi = new \Wikisource\Api\WikisourceApi();
$enWs = $wsApi->fetchWikisource('en');
$prideAndPrejudice = $enWs->getWork('Pride and Prejudice');
echo $work->getWorkTitle().' was published in '.$work->getYear();
```

Let it cache results, such as the seldom-changing list of available Wikisources as derived from Wikidata (any implementation of [PSR-6](http://www.php-fig.org/psr/psr-6/)works here):

```
$wsApi = new \Wikisource\Api\WikisourceApi();
$cache = new Pool(new FileSystem(['path' => __DIR__.'/cache']));
$wsApi->setCache($cache);
```

See the `examples/` directory for fully-functioning examples that you can run straight away from the command line.

Caching
-------

[](#caching)

Every external request that this library performs will be cached if you provide a cache pool via `WikisourceApi::setCache()`. The default cache times are as follows:

DataDefault lifetimeOverrideList of Wikisources30 daysParameter to `WikisourceApi::getWikisources()`Index Page metadata1 hourParameter to `IndexPage::__construct()`A Work's Wikidata Item number1 day*Not possible*Logging
-------

[](#logging)

You can enable logging by passing `WikisourceApi::setLogger()` any object that implements [PSR-3's](http://www.php-fig.org/psr/psr-3/) `LoggerInterface`.

Issues
------

[](#issues)

Please report all issues via Phabricator (tag them with the ['wikisource-api' project](https://phabricator.wikimedia.org/project/view/2349/)).

Licence
-------

[](#licence)

Copyright © 2016 Sam Wilson and other contributors.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~115 days

Recently: every ~207 days

Total

26

Last Release

600d ago

Major Versions

1.5.0 → 2.0.02020-11-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0281a00958518a98244b8a6052f91e86d1599aebf9b7bb6c55bca30d98774e7?d=identicon)[samwilson](/maintainers/samwilson)

---

Top Contributors

[![samwilson](https://avatars.githubusercontent.com/u/213655?v=4)](https://github.com/samwilson "samwilson (69 commits)")

---

Tags

wikidatawikimediawikisource

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikisource-api/health.svg)

```
[![Health](https://phpackages.com/badges/wikisource-api/health.svg)](https://phpackages.com/packages/wikisource-api)
```

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k348.9M2.5k](/packages/symfony-cache)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
