/sandhog

Interact with the New York City MTA's API

Primary LanguagePHP

sandhog

Sandhog allows developers to easily use some of the MTA’s webservices by abstracting the interaction through the Sandhog object.

For example, you can get the status of the L train with the following code.

$status = new Sandhog();
echo $status->service->status('l');

You can query Sandhog for every subway, major bridge, tunnel, bus, LIRR line, and MetroNorth line. Check out example.php.

Features

  • Don’t worry about navigating unruly XML. Just use $data = new Sandhog(); and you’re good to go.
    • Furthermore, you don’t have to worry about bridges vs tunnels vs subway. Just use service->whatever().
  • Don’t worry about bad/dirty data. Sandhog automatically strips away any HTML because it likes to make your life easier.

Sandhog API

service->
    status()                // returns the status of a subway line, Metro North Train, bridge, or tunnel
    name()                  // returns the name of a subway line, Metro North Train, bridge, or tunnel
    text()                  // returns any text explaining the status. this usually occurs when the status() != good service
    plannedworkheadline()   // returns the headline summarizing any planned work (protip: this only works with subways)
    date()                  // not exactly sure what this is referring to since the feed is allegedly updated every 60 seconds
    time()                  // see above

What’s a Sandhog?