PHPackages                             311archive/http-client - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. 311archive/http-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

311archive/http-client
======================

PHP client for the 311.report API.

0.1.0(5y ago)09[4 issues](https://github.com/311archive/http-client/issues)GPL-2.0-or-laterPHPPHP ^7.4

Since Jul 29Pushed 4y agoCompare

[ Source](https://github.com/311archive/http-client)[ Packagist](https://packagist.org/packages/311archive/http-client)[ RSS](/packages/311archive-http-client/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (4)Used By (0)

Boston 311 PHP HTTP Client
==========================

[](#boston-311-php-http-client)

PHP client to aid in fetching and processing Boston 311 reports from [Boston 311 Archive](https://311.report) API.

Example usage
-------------

[](#example-usage)

See the `example-scripts` folder for examples.

### Create a CSV of the number of 311 Reports about fireworks per day over the last few years.

[](#create-a-csv-of-the-number-of-311-reports-about-fireworks-per-day-over-the-last-few-years)

1. Clone this repo or include it in your PHP project.
2. Instantiate a new Client:

```
// Instantiate a new Client.
$client = new Balsama\Client();

// Find all Reports that contain the word "fireworks" or a common alternative spelling "fire works" in the description.
$client->filterDescription(['fireworks', 'fire works']);

// Group the results by day
$client->groupResultsByDay();

// Fetch the reports and store them in `$reports`.
$client->fetchReports();
$reports = $client->getReports();

// Format the number of reports per day into a simple `date` and `count` csv suitible for graphing.
\Balsama\Helpers::convertDateValArrayToCsv($reports, 'fireworks.csv');

```

Documentation
-------------

[](#documentation)

### class `Client`

[](#class-client)

#### Public methods

[](#public-methods)

NameDescriptionParametersReturns`fetchReports`Fetches all reports from the API.`$this``getReports`Gets al of the fetched reports.`array``getReportsFields`Gets specific fields from the fetched Reports`array``setLimit`Limit the number of records returned per request. Note that this does not limit the total number of records returned. It just splits them up over more pages/requests.`@param int $limit`$this`limitRequests`Limits the number of requests/pages, even if there are more results to be fetched.`@param int $numberOfRequests``$this``setOffset`Offset the start of the records returned by a given number.`@param int $offset``$this``dateFilterAfterDate`Filters reports that come before the provided "after" date.`@param string $afterDate`: Any readable PHP date format.`$this``dateFilterBeforeDate`Filters reports that come after the provided "before" date.`@param string $beforeDate`: Any readable PHP date format.`$this``filterCategory`Filters reports to only include reports in the given category.`@param string $category``$this``filterNeighborhood`Filters reports to only include reports from the given neighborhood.`@param string $neighborhood``$this``filterDescription`An array of strings of which at least one must be present in the Description field.`@param string[] $description``$this``filterStatusOpen`Filter on whether the report is open or not. True for open, False for closed. Do not use this method to return all.`$this``filterStatusNotes`An array of strings which much be present in the Status Notes field. Note: The Status Notes field is populated by the city when a report is closed. It is generally empty for open reports. As such, using this will only return closed reports.`@param string\[\] $terms`$this``groupResultsByDay`Groups the results into arrays keyed by day on which they were opened.`$this``groupResultsByWeek`Groups the results into arrays keyed by Month in which they were opened.`$this``groupResultsByMonth`Groups the results into arrays keyed by Year in which they were opened.`$this`### class `Helpers`

[](#class-helpers)

#### Methods (all methods in the Helpers class are static)

[](#methods-all-methods-in-the-helpers-class-are-static)

NameDescriptionParametersReturns`convertDateValArrayToCsv`For a typical array of `[$date => $value]`'s, converts it into a CSV of the given name.`@param array $array`array`includeArrayKeysInArray`Shifts each top level key of an array of arrays into the row's contained array while preserving top-level keys.`@param array[]`array\[\]`csv`Writes an array of arrays to a CSV file.`@param string[] $headers`, `@param array[] $data`, `@param string $filename`, `@param bool $append`, `@param string $path`void`fillMissingDateArrayKeys`Given an array keyed by dates, returns an array with any missing date keys filled.`@param array $array`array`arrayValuesToCounts`Given an array of arrays, returns the count of each second level array while preserving top-level array keys.`@param array $arrayarray`fillLowerLevelDates`Given an array of arrays keyed by dates, fills each of the arrays with any missing date keys and values based on the earliest start and latest end of all the arrays.@param array\[\] $arrayarray\[\]`flattenMultitermDateCount`Given an array of arrays keyed by date (with identical numbers of items in each array and the same start and enddate), flattens the array into `[date, val1, val2, ...]`.@param array\[\] $arraysarray\[\]About
-----

[](#about)

[Boston 311 Archive](https://311.report) is a volunteer project to create a searchable archive of Boston 311 reports. See [Boston 311 Archive: About](https://311.report/about) for more information.

Boston 311 Archive also provides an easily discoverable read-only API that conforms to the JSON:API standard. You can browse the API directly at .

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

2158d ago

### Community

Maintainers

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

---

Top Contributors

[![balsama](https://avatars.githubusercontent.com/u/1536654?v=4)](https://github.com/balsama "balsama (14 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/311archive-http-client/health.svg)

```
[![Health](https://phpackages.com/badges/311archive-http-client/health.svg)](https://phpackages.com/packages/311archive-http-client)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.6M971](/packages/statamic-cms)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k40](/packages/civicrm-civicrm-core)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[oat-sa/tao-core

TAO core extension

66143.7k120](/packages/oat-sa-tao-core)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

5.1k5.2k](/packages/shlinkio-shlink)

PHPackages © 2026

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