Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@haraki
Last active June 13, 2017 08:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haraki/8256f6edbe73ccaae98e to your computer and use it in GitHub Desktop.
Save haraki/8256f6edbe73ccaae98e to your computer and use it in GitHub Desktop.
#!/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;
@haraki
Copy link
Author

haraki commented Sep 13, 2014

東京メトロが開催している、「オープンデータ活用コンテスト」用の公共交通データAPIを、Perl で使ってみました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment