PHPackages                             cnizzardini/gov-info - 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. [API Development](/categories/api)
4. /
5. cnizzardini/gov-info

ActiveLibrary[API Development](/categories/api)

cnizzardini/gov-info
====================

Library for using api.govinfo.gov

v0.3.3(6y ago)253MITPHPPHP ^7.2CI failing

Since Jan 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/cnizzardini/gov-info)[ Packagist](https://packagist.org/packages/cnizzardini/gov-info)[ Docs](https://github.com/cnizzardini/gov-info)[ RSS](/packages/cnizzardini-gov-info/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (3)Versions (8)Used By (0)

GOVINFO: PHP library for accessing api.govinfo.gov
==================================================

[](#govinfo-php-library-for-accessing-apigovinfogov)

```
 _______  _______            _________ _        _______  _______
(  ____ \(  ___  )|\     /|  \__   __/( (    /|(  ____ \(  ___  )
| (    \/| (   ) || )   ( |     ) (   |  \  ( || (    \/| (   ) |
| |      | |   | || |   | |     | |   |   \ | || (__    | |   | |
| | ____ | |   | |( (   ) )     | |   | (\ \) ||  __)   | |   | |
| | \_  )| |   | | \ \_/ /      | |   | | \   || (      | |   | |
| (___) || (___) |  \   /    ___) (___| )  \  || )      | (___) |
(_______)(_______)   \_/     \_______/|/    )_)|/       (_______)

```

[![CircleCI](https://camo.githubusercontent.com/715a9246f11bf80614f9554ee57fee77b05dcecba330ad0224ff5fb712988fee/68747470733a2f2f636972636c6563692e636f6d2f67682f636e697a7a617264696e692f676f762d696e666f2f747265652f6d61737465722e7376673f7374796c653d737667)](https://circleci.com/gh/cnizzardini/gov-info/tree/master)[![Maintainability](https://camo.githubusercontent.com/28aa9fbaa189802b1bb3a8b3f620a4b6cc11c14c25b71fae590bb3fff6bb754c/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f35353733343835386233623935343262346266662f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/cnizzardini/gov-info/maintainability)[![Test Coverage](https://camo.githubusercontent.com/e43c20a87f02a44fce8a919d7fb390a7bb485b3d58630da5d57faec93730569b/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f35353733343835386233623935343262346266662f746573745f636f766572616765)](https://codeclimate.com/github/cnizzardini/gov-info/test_coverage)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

This alpha stage package provides a very simple way to access [api.govinfo.gov](https://api.govinfo.gov/docs/)

[See console demo](#Console)

Install
-------

[](#install)

You can install this package via composer.

```
composer require cnizzardini/gov-info
```

Usage
-----

[](#usage)

Retrieve an index of all collections available

```
use GovInfo\Api;
use GovInfo\Collection;

$api = new Api(
    new \GuzzleHttp\Client(),
    'DEMO_KEY'
);
$collection = new Collection($api);
$result = $collection->index();
```

After running this code `$result` will contain a non-truncated version of collections:

```
Array
(
    [collections] => Array
        [
            [0] => Array
                [
                    [collectionCode] => USCOURTS
                    [collectionName] => United States Courts Opinions
                    [packageCount] => 1134933
                    [granuleCount] => 2525240
                ]
        ...
)

```

Retrieve all packages in a collection

```
use GovInfo\Api;
use GovInfo\Collection;
use GovInfo\Requestor\CollectionAbstractRequestor;

$api = new Api(
    new \GuzzleHttp\Client(),
    'DEMO_KEY'
);
$collection = new Collection($api);
$requestor = new CollectionAbstractRequestor();

$requestor
    ->setStrCollectionCode('BILLS')
    ->setObjStartDate(new DateTime('2019-01-01'));

$result = $collection->item($requestor);
```

After running this code `$result` will contain a non-truncated version of packages:

```
Array
(
    [count] => 202767
    [message] =>
    [nextPage] => https://api.govinfo.gov/collections/BILLS/2018-01-01T00:00:00Z/?offset=100&pageSize=100
    [previousPage] =>
    [packages] => Array
        [
            [0] => Array
                [
                    [packageId] => BILLS-115hr2740rfs
                    [lastModified] => 2018-11-16T00:33:17Z
                    [packageLink] => https://api.govinfo.gov/packages/BILLS-115hr2740rfs/summary
                    [docClass] => hr
                    [title] => Rabbi Michoel Ber Weissmandl Congressional Gold Medal Act of 2017
                ]
        ...

```

Retrieve a specific package in a collection.

```
use GovInfo\Api;
use GovInfo\Collection;
use GovInfo\Requestor\CollectionAbstractRequestor;

$api = new Api(
    new \GuzzleHttp\Client(),
    'DEMO_KEY'
);
$collection = new Collection($api);
$requestor = new CollectionAbstractRequestor();

$requestor
    ->setStrCollectionCode('BILLS')
    ->setObjStartDate(new \DateTime('2018-01-01 12:00:00'))
    ->setObjEndDate(new \DateTime('2018-02-01 12:00:00'))
    ->setStrDocClass('hr')
    ->setStrPackageId('BILLS-115hr4033rfs')
    ->setStrTitle('Geologic Mapping Act');

$result = $collection->item($requestor);
```

After running this code `$result` will contain the requested package

```
Array
(
    [count] => 202767
    [message] =>
    [nextPage] => https://api.govinfo.gov/collections/BILLS/2018-01-01T00:00:00Z/?offset=100&pageSize=100
    [previousPage] =>
    [packages] => Array
        [
            [2] => Array
                [
                    [packageId] => BILLS-115hr4033rfs
                    [lastModified] => 2018-11-16T00:33:00Z
                    [packageLink] => https://api.govinfo.gov/packages/BILLS-115hr4033rfs/summary
                    [docClass] => hr
                    [title] => National Geologic Mapping Act Reauthorization Act
                ]
        ]
)

```

Retrieve a summary of a package.

```
use GovInfo\Package;
use GovInfo\Requestor\PackageAbstractRequestor;

$package = new Package($api);
$requestor = new PackageAbstractRequestor();

$result = $package->summary($requestor->setStrPackageId('BILLS-115hr4033rfs'));
```

After running this code `$result` will contain a non-truncated version of the package summary

```
Array
(
    [title] => An Act To reauthorize the National Geologic Mapping Act of 1992.
    [shortTitle] => Array
        [
            [0] => Array
                [
                    [type] => measure
                    [title] => National Geologic Mapping Act Reauthorization Act
                ]

        ]
    ...

```

Retrieve a package as a specified content-type

```
use GovInfo\Package;
use GovInfo\Requestor\PackageAbstractRequestor;

$package = new Package($api);
$requestor = new PackageAbstractRequestor();
$requestor
    ->setStrPackageId('BILLS-115hr4033rfs')
    ->setStrContentType('xml');

$result = $package->contentType($requestor);
```

After running this code `$result` will be an instance of GuzzleHttp\\Psr7\\Response

For additional usage examples, please look at `src/Console` and `tests`.

Console
-------

[](#console)

There is a minimalist console application that *can* be used, but its not designed for production use. I built this so I could easily regression test the library against the production API. Each command will prompt you for an API key. To avoid this prompt you can create a local `apiKey.txt` file with your API key in there.

[![Example](./docs/console-demo.svg)](./docs/console-demo.svg)

```
# displays collections
php console.php collection:index

# display packages for a given collection
php console.php collection:packages

# writes to csv file
php console.php collection:packages --file

# writes to csv file in a specific folder
php console.php collection:packages --file --path=/home/username/Desktop

# retrieves a package summary as a GuzzleHttp\Psr7\Response instance
php console.php package:summary

# retrieves a package summary and writes to file
php console.php package:summary --file

# writes to file in a specific folder
php console.php collection:packages --file --path=/home/username/Desktop
```

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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 ~0 days

Total

6

Last Release

2306d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/171294?v=4)[Chris Nizzardini](/maintainers/cnizzardini)[@cnizzardini](https://github.com/cnizzardini)

---

Top Contributors

[![cnizzardini](https://avatars.githubusercontent.com/u/171294?v=4)](https://github.com/cnizzardini "cnizzardini (162 commits)")

---

Tags

govgovinfophpgovgovinfogovinfo.govapi.govinfo.gov

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cnizzardini-gov-info/health.svg)

```
[![Health](https://phpackages.com/badges/cnizzardini-gov-info/health.svg)](https://phpackages.com/packages/cnizzardini-gov-info)
```

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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