311archive/http-client

PHP client for the 311.report API.

0.1.0 2020-08-04 03:23 UTC

This package is auto-updated.

Last update: 2024-10-29 06:11:55 UTC


README

PHP client to aid in fetching and processing Boston 311 reports from Boston 311 Archive API.

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.

  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

class Client

Public methods

class Helpers

Methods (all methods in the Helpers class are static)

About

Boston 311 Archive is a volunteer project to create a searchable archive of Boston 311 reports. See Boston 311 Archive: 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 https://311.report/jsonapi.