Go to Metro.net
 

Trip Planner Information Feed

Carriers


Script Name: Carriers.php

Supports GET and POST. Output formats: XML, JSON, and PHP.

 

Description

Return all carrier names and ID’s.

 

Input

None.

 

Returns

Carriers will return a list consisting of all carrier names and associated carrier ids will be returned.

 

JSON format

Special characters in the output will be encoded. An index attribute will be returned for any ‘arrayed’ objects.

[{'code': 'AS', 'id': '2', 'text': 'Airport Shuttle'}, {'code': 'AT', 'id': '3', 'text': 'Alhambra Community Transit'}, {'code': 'AM', 'id': '1', 'text': 'Amtrak'}, {'code': 'AV', 'id': '4', 'text': 'Antelope Valley'}, {'code': 'BP', 'id': '7', 'text': 'Baldwin Park Shuttle'}, {'code': 'CN', 'id': '15', 'text': 'Beach Cities'}, {'code': 'BG', 'id': '6', 'text': 'Bell Gardens Town Trolley'}, {'code': 'BF', 'id': '5', 'text': 'Bellflower Bus'}, {'code': 'BU', 'id': '8', 'text': 'Burbank Media Shuttle'}, {'code': 'CL', 'id': '13', 'text': 'Camarillo Area Transit'}, {'code': 'CA', 'id': '9', 'text': 'Carson Circuit'}, {'code': 'CW', 'id': '18', 'text': 'Cerritos On Wheels'}, {'code': 'CM', 'id': '14', 'text': 'Commerce'}, {'code': 'CX', 'id': '19', 'text': 'Commuter Express'}, {'code': 'CR', 'id': '17', 'text': 'Compton Renaissance'}, {'code': 'CK', 'id': '12', 'text': 'Corona Cruiser'}, {'code': 'CH', 'id': '11', 'text': 'Cudahy Transit'}, {'code': 'CC', 'id': '10', 'text': 'Culver City Bus'}, {'code': 'DA', 'id': '20', 'text': 'Dash (Community Lines)'}, {'code': 'DT', 'id': '21', 'text': 'Duarte Transit'}, {'code': 'EM', 'id': '22', 'text': 'El Monte Trolley'}, {'code': 'FA', 'id': '63', 'text': 'Flyaway'}, {'code': 'FZ', 'id': '23', 'text': 'Foothill Transit '}, {'code': 'GA', 'id': '24', 'text': 'Gardena Transit'}, {'code': 'GB', 'id': '25', 'text': 'Glendale Beeline'}, {'code': 'IN', 'id': '26', 'text': 'Inglewood I-Line'}, {'code': 'LT', 'id': '28', 'text': 'Lawndale Trolley'}, {'code': 'LB', 'id': '27', 'text': 'Long Beach Transit'}, {'code': 'CO', 'id': '16', 'text': 'Los Angeles County Shuttles'}, {'code': 'LY', 'id': '29', 'text': 'Lynwood Trolley'}, {'code': 'MX', 'id': '35', 'text': 'Max'}, {'code': 'MT', 'id': '34', 'text': 'Metro '}, {'code': 'ML', 'id': '31', 'text': 'Metrolink'}, {'code': 'MB', 'id': '30', 'text': 'Montebello Transit'}, {'code': 'MP', 'id': '32', 'text': 'Monterey Park'}, {'code': 'MR', 'id': '33', 'text': 'Moorpark City Transit'}, {'code': 'RW', 'id': '45', 'text': 'Mountain Area Rapid Transit Ag'}, {'code': 'NT', 'id': '36', 'text': 'Norwalk Transit'}, {'code': 'OT', 'id': '39', 'text': 'Ojai Trolley'}, {'code': 'OM', 'id': '38', 'text': 'Omnitrans'}, {'code': 'OC', 'id': '37', 'text': 'Orange County Transit'}, {'code': 'PV', 'id': '42', 'text': 'Palo Verde Valley Transit Ag'}, {'code': 'PP', 'id': '64', 'text': 'Palos Verdes Peninsula Transit Auth'}, {'code': 'PL', 'id': '41', 'text': 'Parklink'}, {'code': 'PA', 'id': '40', 'text': 'Pasadena Arts'}, {'code': 'RA', 'id': '43', 'text': 'Riverside Transit Authority'}, {'code': 'RS', 'id': '44', 'text': 'Rosemead Shuttle'}, {'code': 'SC', 'id': '47', 'text': 'Santa Clarita'}, {'code': 'SF', 'id': '48', 'text': 'Santa Fe Springs'}, {'code': 'SM', 'id': '50', 'text': 'Santa Monica'}, {'code': 'SA', 'id': '46', 'text': 'SCAT'}, {'code': 'SG', 'id': '49', 'text': 'Sierra Madre Gateway'}, {'code': 'SV', 'id': '53', 'text': 'Simi Valley Transit'}, {'code': 'SP', 'id': '51', 'text': 'So Pasadena Goldline Shuttle'}, {'code': 'SW', 'id': '61', 'text': 'South Whittier Shuttle Services'}, {'code': 'ST', 'id': '52', 'text': 'SunLine Transit'}, {'code': 'TH', 'id': '54', 'text': 'Thousand Oaks Transit '}, {'code': 'TO', 'id': '55', 'text': 'Torrance Transit'}, {'code': 'VV', 'id': '57', 'text': 'Victor Valley '}, {'code': 'VS', 'id': '56', 'text': 'Vista'}, {'code': 'WC', 'id': '58', 'text': 'West Covina'}, {'code': 'WH', 'id': '59', 'text': 'West Hollywood'}, {'code': 'WT', 'id': '60', 'text': 'Whittier Transit'}]

 

XML format

Special characters in the output will be encoded. An index attribute will be returned for any ‘arrayed’ objects.

<?xml version="1.0" encoding="ISO-8859-1"?> <root> <metadata> <request>Carriers</request> <records_found>63</records_found> <request_uri>/tm/carriers.php?format=xml</request_uri> <query_time>0.0026991367340088 seconds</query_time> </metadata> <carriers type="list"> <item> <id>2</id> <text>Airport Shuttle</text> <code>AS</code></item> <item> <id>3</id> <text>Alhambra Community Transit</text> <code>AT</code></item> <item> <id>1</id> <text>Amtrak</text> <code>AM</code></item> <item> <id>4</id> <text>Antelope Valley</text> <code>AV</code></item> <item> <id>7</id> <text>Baldwin Park Shuttle</text> <code>BP</code></item> <item> <id>15</id> <text>Beach Cities</text> <code>CN</code></item> <item> <id>6</id> <text>Bell Gardens Town Trolley</text> <code>BG</code></item> <item> <id>5</id> <text>Bellflower Bus</text> <code>BF</code></item> <item> <id>8</id> <text>Burbank Media Shuttle</text> <code>BU</code></item> <item> <id>13</id> <text>Camarillo Area Transit</text> <code>CL</code></item> <item> <id>9</id> <text>Carson Circuit</text> <code>CA</code></item> <item> <id>18</id> <text>Cerritos On Wheels</text> <code>CW</code></item> <item> <id>14</id> <text>Commerce</text> <code>CM</code></item> <item> <id>19</id> <text>Commuter Express</text> <code>CX</code></item> <item> <id>17</id> <text>Compton Renaissance</text> <code>CR</code></item> <item> <id>12</id> <text>Corona Cruiser</text> <code>CK</code></item> <item> <id>11</id> <text>Cudahy Transit</text> <code>CH</code></item> <item> <id>10</id> <text>Culver City Bus</text> <code>CC</code></item> <item> <id>20</id> <text>Dash (Community Lines)</text> <code>DA</code></item> <item> <id>21</id> <text>Duarte Transit</text> <code>DT</code></item> <item> <id>22</id> <text>El Monte Trolley</text> <code>EM</code></item> <item> <id>63</id> <text>Flyaway</text> <code>FA</code></item> <item> <id>23</id> <text>Foothill Transit</text> <code>FZ</code></item> <item> <id>24</id> <text>Gardena Transit</text> <code>GA</code></item> <item> <id>25</id> <text>Glendale Beeline</text> <code>GB</code></item> <item> <id>26</id> <text>Inglewood I-Line</text> <code>IN</code></item> <item> <id>28</id> <text>Lawndale Trolley</text> <code>LT</code></item> <item> <id>27</id> <text>Long Beach Transit</text> <code>LB</code></item> <item> <id>16</id> <text>Los Angeles County Shuttles</text> <code>CO</code></item> <item> <id>29</id> <text>Lynwood Trolley</text> <code>LY</code></item> <item> <id>35</id> <text>Max</text> <code>MX</code></item> <item> <id>34</id> <text>Metro</text> <code>MT</code></item> <item> <id>31</id> <text>Metrolink</text> <code>ML</code></item> <item> <id>30</id> <text>Montebello Transit</text> <code>MB</code></item> <item> <id>32</id> <text>Monterey Park</text> <code>MP</code></item> <item> <id>33</id> <text>Moorpark City Transit</text> <code>MR</code></item> <item> <id>45</id> <text>Mountain Area Rapid Transit Ag</text> <code>RW</code></item> <item> <id>36</id> <text>Norwalk Transit</text> <code>NT</code></item> <item> <id>39</id> <text>Ojai Trolley</text> <code>OT</code></item> <item> <id>38</id> <text>Omnitrans</text> <code>OM</code></item> <item> <id>37</id> <text>Orange County Transit</text> <code>OC</code></item> <item> <id>42</id> <text>Palo Verde Valley Transit Ag</text> <code>PV</code></item> <item> <id>64</id> <text>Palos Verdes Peninsula Transit Auth</text> <code>PP</code></item> <item> <id>41</id> <text>Parklink</text> <code>PL</code></item> <item> <id>40</id> <text>Pasadena Arts</text> <code>PA</code></item> <item> <id>43</id> <text>Riverside Transit Authority</text> <code>RA</code></item> <item> <id>44</id> <text>Rosemead Shuttle</text> <code>RS</code></item> <item> <id>47</id> <text>Santa Clarita</text> <code>SC</code></item> <item> <id>48</id> <text>Santa Fe Springs</text> <code>SF</code></item> <item> <id>50</id> <text>Santa Monica</text> <code>SM</code></item> <item> <id>46</id> <text>SCAT</text> <code>SA</code></item> <item> <id>49</id> <text>Sierra Madre Gateway</text> <code>SG</code></item> <item> <id>53</id> <text>Simi Valley Transit</text> <code>SV</code></item> <item> <id>51</id> <text>So Pasadena Goldline Shuttle</text> <code>SP</code></item> <item> <id>61</id> <text>South Whittier Shuttle Services</text> <code>SW</code></item> <item> <id>52</id> <text>SunLine Transit</text> <code>ST</code></item> <item> <id>54</id> <text>Thousand Oaks Transit</text> <code>TH</code></item> <item> <id>55</id> <text>Torrance Transit</text> <code>TO</code></item> <item> <id>57</id> <text>Victor Valley</text> <code>VV</code></item> <item> <id>56</id> <text>Vista</text> <code>VS</code></item> <item> <id>58</id> <text>West Covina</text> <code>WC</code></item> <item> <id>59</id> <text>West Hollywood</text> <code>WH</code></item> <item> <id>60</id> <text>Whittier Transit</text> <code>WT</code></item> </carriers> </root>

 

Usage

# REQUIRED: apikey
http://developer.metro.net/tm/carriers.php?apikey=1-2-3-4-5
# OPTIONAL 
http://developer.metro.net/tm/carriers.php?apikey=1-2-3-4-5&format=xml 
http://developer.metro.net/tm/carriers.php?apikey=1-2-3-4-5&format=json 
http://developer.metro.net/tm/carriers.php?apikey=1-2-3-4-5&format=phpCarriers


User Contributed Notes

  • June 21, 2009

    Is this service avaialble now?

    The hostname mtaweb.metro.net does not resolve from several locations.

    =m

  •  
  • June 22, 2009

    correct! somehow our internal URL was substituted into the documentation. The example URLs have been fixed--please try again.

    -Doug

  •  
  • June 25, 2009

    The JSON sample you posted is not valid[1], and won't be parsed by most JSON parsers. Since you're using PHP, consider re-using an existing library rather than trying to write a custom one.

    PHP 5.2 comes with a JSON library included[2], and the library is also available in stand-alone form for previous versions[3]. I notice you've mentioned on your blog that the developer site may transition to Django -- in this case, you can use the "simplejson" library bundled with Django[4].

    Also, while not a matter of validity, consider making the "id" attribute a number rather than a string. For example: {"code": "AS", "id": 2, "text": "Airport Shuttle"}

    [1] http://www.jsonlint.com/
    [2] http://www.php.net/releases/5_2_0.php
    [3] http://pecl.php.net/package/json
    [4] http://code.djangoproject.com/browser/django/trunk/django/utils/simplejson

  •  
  • July 4, 2009

    It seems I am unable to get one carrier by attaching an id={carrier #} parameter. It might be efficient to do so in some scenarios.

  •  

Please Login (or Sign Up) to leave a comment