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 1mo ago

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

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

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

2109d 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

[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[akamai-open/edgegrid-client

Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client\_Auth.html

482.5M6](/packages/akamai-open-edgegrid-client)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98239.8k1](/packages/muhammadhuzaifa-telescope-guzzle-watcher)[ory/hydra-client-php

Documentation for all of Ory Hydra's APIs.

1710.8k](/packages/ory-hydra-client-php)[meteocontrol/vcom-api-client

HTTP Client for meteocontrol's VCOM API - The VCOM API enables you to directly access your data on the meteocontrol platform.

175.7k1](/packages/meteocontrol-vcom-api-client)

PHPackages © 2026

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