GithubHelp home page GithubHelp logo

node-phli's Introduction

Build Status

phli

A Node.js module for interacting with the City of Philadelphia's Licenses & Inspections data.

phli was built during the December 2012 Random Hacks of Kindness Philadelphia hackathon.

Getting Started

Install phli:

npm install phli

Require and instantiate phli:

var phli = require('phli')();

Example Usage

getAddressHistory

Get L & I history for a Philadelpia address:

phli.getAddressHistory('1500 market street', function (err, data) {
  console.log(data);
});

getPermits

Get permits data related to a certain filter criteria, such as zipcode:

phli.getPermits({zip: '19143'}, function (err, data) {
  console.log(data);
});

Available filters example:

{
  zip: '19143', // pass an array of zipcodes to filter on multiple zips
  ward: '44', // 1 - 66; pass an array of wards to filter on multiple wards
  contractor_name: 'John Doe'; pass an array of contractors to filter on multiple contractors
  council_district: '1', // 1 - 10; pass an array of districts to filter on multiple districts
  census_tract: '1', // 1 - 300-and-something; pass an array of tracts to filter on multiple tracts
  start_date: '2011-12-01',
  end_date: '2012-12-01',
  top: '2'
}

getLicenses

Get licenses data related to a certain filter criteria, such as zipcode:

phli.getLicenses({zip: '19143'}, function (err, data) {
  console.log(data);
});

Available filters example:

{
  zip: '19143', // pass an array of zipcodes to filter on multiple zips
  ward: '44', // 1 - 66; pass an array of wards to filter on multiple wards
  council_district: '1', // 1 - 10; pass an array of districts to filter on multiple districts
  census_tract: '1', // 1 - 300-and-something; pass an array of tracts to filter on multiple tracts
  start_date: '2011-12-01',
  end_date: '2012-12-01',
  top: '2'
}

getCases

Get cases data related to a certain filter criteria, such as zipcode:

phli.getLicenses({zip: '19143'}, function (err, data) {
  console.log(data);
});

Available filters example:

{
  zip: '19143', // pass an array of zipcodes to filter on multiple zips
  ward: '44', // 1 - 66; pass an array of wards to filter on multiple wards
  council_district: '1', // 1 - 10; pass an array of districts to filter on multiple districts
  census_tract: '1', // 1 - 300-and-something; pass an array of tracts to filter on multiple tracts
  start_date: '2011-12-01',
  end_date: '2012-12-01'
}

getPermitInfo

Get permit details surrounding a specific permit ID, such as 33333:

phli.getPermitInfo('33333', function (err, data) {
  console.log(data);
});

node-phli's People

Contributors

mdb avatar mheadd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

mheadd

node-phli's Issues

Drop underscore dependency

Currently we are only using _.defaults, which we can accomplish by doing something like this:

function applyDefaults(params, defaults) {
  var settings = params || {};

  for(var setting in defaults) {
    if(defaults.hasOwnProperty(setting) && !settings[setting]) {
      settings[setting] = defaults[setting];
    }
  }

  return settings;
}

What do you think?

Return count along with collection

Especially for preview it would be great to have the total count of permits, cases, etc. returned on a query. So the collection array (see #1) shouldn't be the top-level thing. For example:

{
  "count": 457,
  "results": [
     { blah blah },
     ...
  ]
}

When is the presence of $top and $inlinecount permitted in API URLs?

This does not work:
http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/permits?$format=json&$filter=startswith(locations/zip,%20'19143')&$expand=locations&$top=$inlincount=

And this does work:
http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/permits?$format=json&$filter=startswith(locations/zip,%20'19143')&$expand=locations

Is this a defect in phli or the API? If the API is behaving as expected, then phli's getType method will need to be modified to account for this, as the library currently makes the first of the above-listed API calls.

Inconsistent API behavior surrounding ?filter= and ?$filter=

I'm seeing inconsistent API response surrounding the $filter param.

For example:

This URL contains a $filter param and does not yield results:
http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/permits?%24format=json&%24filter=substringof(%27williams%27%2C%20contractor_name)&%24expand=locations&%24top=&%24inlinecount=

This URL is the same as the above but contains a filter param (no '$') and does yield results:
http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/permits?%24format=json&filter=substringof(%27williams%27%2C%20contractor_name)&%24expand=locations&%24top=&%24inlinecount=

And this URL also queries permits but responds to a $filter param:
http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/permits?$format=json&$filter=startswith(locations/zip,%20'19143')&$expand=locations&$top=$inlincount=

Is this a defect in phli or in the API? Is there a pattern I'm missing?

OData Library

Doh! OData provides Client Libraries for Javascript and Node.js...that probably would have made things easier. Take a look, maybe it's better to use it?

Clean up date values

Date values come back looking like this:

/Date(1072328400000)/

Could we convert these to ISO8601 or something like it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.