Last active
June 13, 2017 08:50
-
-
Save haraki/8256f6edbe73ccaae98e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# Tokyo Metro Open Data API test code | |
# | |
# author : Masashi Haraki | |
# | |
use strict; | |
use warnings; | |
use utf8; | |
use open IO => ":utf8"; | |
use HTTP::Request; | |
use LWP::UserAgent; | |
use constant ACCESS_TOKEN => ''; # set your ACCESS TOKEN | |
use constant API_ENDPOINT => 'https://api.tokyometroapp.jp/api/v2/'; | |
my $url = | |
# All train data | |
API_ENDPOINT . "datapoints?rdf:type=odpt:Train&acl:consumerKey=" . ACCESS_TOKEN; | |
# All station data | |
# API_ENDPOINT . "datapoints?rdf:type=odpt:Station&acl:consumerKey=" . ACCESS_TOKEN; | |
# All railway data | |
# API_ENDPOINT . "datapoints?rdf:type=odpt:Railway&acl:consumerKey=" . ACCESS_TOKEN; | |
# Fukutoshin-line(from Shibuya to Wako-shi) geoJson data | |
# API_ENDPOINT . "places/urn:ucode:_00001C000000000000010000030C46B4.geojson?acl:consumerKey=" . ACCESS_TOKEN; | |
my $request = HTTP::Request->new(GET => $url); | |
my $ua = LWP::UserAgent->new(); | |
my $response = $ua->request($request); | |
print $response->content() . "\n"; | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
東京メトロが開催している、「オープンデータ活用コンテスト」用の公共交通データAPIを、Perl で使ってみました。