SlideShare une entreprise Scribd logo
1  sur  43
Télécharger pour lire hors ligne
Open Data
and Web API
Sammy Fung
Technology Sharing (28/1/2016)
at Hong Kong Polytechnic University COMP
Sammy Fung
• President, Open Source Hong Kong.
• Conference Chair, Hong Kong Open Source Conference.
• Tags: Freelancer, Developer, Open Source, Open Data, Startup.
• Contacts:
• sammy@sammy.hk
• @sammyfung
• https://github.com/sammyfung
• The presentation slide will be public on SlideShare in CC license.
• Creative Commons BY-NC-SA (Attribution, Non-Commerical, Sharealike)
Open Data
What is Data ?
1. What is current Air
Quality Health Index
(AQHI) of Causeway Bay ?
AQHI
• Environment Protection Department (EPD)
• Find it out from AQHI website run by EPD.
• http://www.aqhi.gov.hk/en.html
• How about details of air quality in Causeway Bay
? Look into Pollutant Concentration of CWB.
So, we just found the
“data” by human.
How does software program
read the AQHI and Pollutant
Concentration of CWB (“data”) ?
Software and Data
• We need values of data for software program.
• an integer or a float: eg. 2016, 6.89
• a character string: eg. “Causeway Bay”
• Retrieve data through “Interface” for data.
• Application Programming Interface (API)
• Computer/Software/Program Readable Data Format.
• Human communicates in a common language, eg. English,
Cantonese, Mandarin.
• Data Formats: eg. XML, JSON.
XML Example
<developers>
<developer>
<firstName>Richard</firstName> <lastName>Stallman</lastName>
</developer>
<developer>
<firstName>Linus</firstName> <lastName>Torvalds</lastName>
</developer>
<developer>
<firstName>Eric</firstName> <lastName>Raymond</lastName>
</developer>
</developers>
JSON Example
{"developers":[
{"firstName":"Richard", "lastName":"Stallman"},
{"firstName":"Linus", "lastName":"Torvalds"},
{"firstName":"Eric", "lastName":"Raymond"}
]}
Software and Data
• Web Scraping: Retrieve documents from website.
• Information Extraction & Transformation:
• Extract and Transform data from common data format
into data objects (variables) in software program.
• eg. JSON -> Float(s)
• “Clean Data” is needed for “non-good” data formats.
• eg. HTML -> Float(s)
Software and Data
• Programming Language: eg. Python
• Web Scraping library: import scrapy
• JSON library: import json
• Regular Expression library: import re
• Other libraries (eg. database): import mysql
Installing Scrapy
• Scrapy is a web scraping framework written in
ptyhon.
• virtualenv ~/env/scrapy
• source ~/env/scrapy/bin/activate
• pip install scrapy
Try in Scrapy Shell
• Try in Scrapy Shell:
• scrapy startproject demo1
• scrapy shell http://www.aqhi.gov.hk/epd/ddata/html/out/
24aqhi_Eng.xml
• a =response.xpath("//item[contains(.//StationName/text(),
'Causeway Bay’)]/aqhi/text()").extract()
• b = a[len(a)-1] # b is string
• c = int(a[len(a)-1]) # c is integer
• print (b, c) # show the difference
AQHI
• Phase 1: EPD provided AQHI in XML format.
• Phase 2: EPD provided both AQHI and Pollutant
Concentration in XML format.
2. What is the current
temperature of Shatin ?
Weather
• Hong Kong Observatory (HKO)
• http://www.weather.gov.hk
• Top Hobbyist Website: Weather Underground
http://www.weather.org.hk/
So, we just found another
“data” again by human.
How does software program
read the current temperature
of Shatin (“data”) ?
Sorry! You need to subscribe to commercial
paid data feed services provided by HKO.
XD
But……
We can do it by scraping
from HTML document
(a harder method)
Try in Scrapy
• scrapy shell http://www.weather.gov.hk/wxinfo/ts/
text_readings_e.htm
• a = response.xpath(“//pre").extract()[0]
• import re
• b = re.split("n", a)
Clean Data with RE
c = ‘’
for i in b:
if re.search("^Sha Tin", i) and c=‘’:
c = re.sub("^Sha Tin *”,"",i)
c = re.sub(" .*”,”",c)
print c # c is string
print float(c) # c is float
Open Data
Open Data
• Discoverable
• Available and Searchable on Internet.
• Structured
• Open and Machine-readable Format.
• Unconditional
• Legal Framework allows to reproduce and
repurpose the data.
5-star Open Data
DeploymentScheme
• Tim Berners-Lee, the inventor of the Web.
• 5stardata.info
• 1 Star: make your stuff available on the Web (whatever format) under an open
license.
• 2 Star: make it available as structured data
• eg. Excel instead of image scan of a table
• 3 Star: use non-proprietary formats
• eg. CSV instead of Excel
• 4 Star: use URIs to denote things, so that people can point at your stuff
• 5 Star: link your data to other data to provide context.
Open Data in Hong Kong
• OGCIO
• DATA.ONE in 2011.
• data.gov.hk in 2015.
• JSON/XML, RSS, XLS, CSV, JPEG/PNG,….
• Define workflow for other government department to release open
data.
• OGCIO could not decide which data and format can be
released
• Decision made by data owner of each government departments.
Open Data in Hong Kong
• LegCo
• http://www.legco.gov.hk
• Voting results of LegCo meetings and some
committee meetings in XML in Oct 2013.
• API is available in Fall 2014.
• Not part of DATA.ONE / DATA.GOV.HK.
HK Air Quality Data
• AQHI, old API and Pollutant Concentration
• XML Data for past 24 hours.
• CSV Data for all past records.
• EPD released AQHI and old API at phase 1 few
years ago.
• EPD also released Pollutant Concentration data in
machine-readable format at phase 2 one year ago.
Weather in DATA.GOV.HK
• I posted a blog 'Progress of Open Government Data in Hong Kong' on 2013/01/17.
• Weather at Data.One released 7 datasets only.
• All datasets are in RSS (XML) format which includes items with title and
description only.
• Hourly weather reports, weather forecasts and special reports in 3 languages.
• Examples of missing data:
• Regional Weather Data updates from stations in every 10 minutes.
• One word: Useless.
• RSS Datasets on DATA.GOV.HK is completely different with HKO paid service
(XML data feed).
Web API
API
• API = Application Programming Interface
• Retrieve data through “Interface”.
• C API, Python API, Objective-C API, Java
API……
Web API
• API for Web Server or Web Browser/Client.
• Usually Web APIs are used for connecting to 3rd party
web services.
• Request and Response messaging interface via Web
(HTTP) defined by service providers.
• Request URI example: https://api.twitter.com/1.1/
statuses/user_timeline.json
• Data are exchanged in JSON or XML format.
Web API Examples
• Payments: Paypal, MasterPass,…
• Online Services: Google, GitHub,…
• Social Networks: Twitter, Facebook,…
REST
• Representational state transfer
• One of reference styles of data exchange for Web 2.0.
• Web API design are usually in REST style.
• Systems communicates using HTTP verbs over HTTP communication.
• HTTP Verbs: GET, POST, PUT, DELETE,…
• GET: list or retrieve data
• POST: create data
• PUT: update or replace data
• DELETE: delete data
Communication Flow
with API
• Authorization
• to retrieve a token for your web/mobile/backend apps to use the 3rd party API
services.
• Re-direct users to 3rd party services for one-time auth (eg. Username,
Password), and token will be used for future access until token is expired.
• For Application or Application-User Authorisation.
• eg. OAuth, XAuth.
• Do your any web API calls.
• API Rate Limits
Tweepy
• a 3rd party twitter library for python.
• pip install tweepy
• http://tweepy.readthedocs.org
Open Data and Web API
• Structure of Open Data and Syntax of Web API
will be changed by service / data providers from
time to time.
• You should subscribe to developer blog of those
API and data services if possible.
• Use existing open source software tools to use
web API, otherwise build your own tools (and
consider to make it open source)
Open Source Software
(Very Quick Version)
Open Source Software
• Open Source = Source Codes are available to public.
• License: Licensed in one of Open Source Licenses.
• Freedom: Freely (re-)distribute
• You can charge for distribution costs but almost no
one will do so.
• GitHub: Rich open source software library
• Git: a distributed version control software tool.
References
• Free Software Codes: www.github.com
• Community: opensource.hk
• Conference: 2016.opensource.hk
• 6/24-25 Cyberport
• This Slide: slideshare.com/sammyfung
• Contact: sammy@sammy.hk / @sammyfung

Contenu connexe

Tendances

GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL IntroductionSerge Huber
 
GraphQL Advanced
GraphQL AdvancedGraphQL Advanced
GraphQL AdvancedLeanIX GmbH
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsSashko Stubailo
 
End of Term Harvest User Interface
End of Term Harvest User Interface End of Term Harvest User Interface
End of Term Harvest User Interface misstracyjo
 
MuseoTorino, first italian project using a GraphDB, RDFa, Linked Open Data
MuseoTorino, first italian project using a GraphDB, RDFa, Linked Open DataMuseoTorino, first italian project using a GraphDB, RDFa, Linked Open Data
MuseoTorino, first italian project using a GraphDB, RDFa, Linked Open Data21Style
 
GraphQL London January 2018: Graphql tooling
GraphQL London January 2018: Graphql toolingGraphQL London January 2018: Graphql tooling
GraphQL London January 2018: Graphql toolingSøren Bramer Schmidt
 
Open PHACTS API Walkthrough
Open PHACTS API WalkthroughOpen PHACTS API Walkthrough
Open PHACTS API WalkthroughPaul Groth
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQLvaluebound
 
Standard Web APIs for Multidisciplinary Collaboration
Standard Web APIs for Multidisciplinary CollaborationStandard Web APIs for Multidisciplinary Collaboration
Standard Web APIs for Multidisciplinary CollaborationAxel Reichwein
 
Achieving the digital thread through PLM and ALM integration using oslc
Achieving the digital thread through PLM and ALM integration using oslcAchieving the digital thread through PLM and ALM integration using oslc
Achieving the digital thread through PLM and ALM integration using oslcAxel Reichwein
 
Koneksys Presentation March 2021
Koneksys Presentation March 2021Koneksys Presentation March 2021
Koneksys Presentation March 2021Axel Reichwein
 
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open WebKafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open WebHostedbyConfluent
 
Distributed Affordance
Distributed AffordanceDistributed Affordance
Distributed AffordanceRuben Verborgh
 
This Week in Neo4j - 24th November 2018
This Week in Neo4j - 24th November 2018This Week in Neo4j - 24th November 2018
This Week in Neo4j - 24th November 2018Neo4j
 
Ajaxworld Opensocial Presentation
Ajaxworld Opensocial PresentationAjaxworld Opensocial Presentation
Ajaxworld Opensocial PresentationChris Schalk
 
Introduction to Open Services for Lifecycle Collaboration (OSLC)
Introduction to Open Services for Lifecycle Collaboration (OSLC)Introduction to Open Services for Lifecycle Collaboration (OSLC)
Introduction to Open Services for Lifecycle Collaboration (OSLC)Axel Reichwein
 
Overview of OSLC - INCOSE IW 2018 MBSE Workshop
Overview of OSLC - INCOSE IW 2018 MBSE Workshop Overview of OSLC - INCOSE IW 2018 MBSE Workshop
Overview of OSLC - INCOSE IW 2018 MBSE Workshop Axel Reichwein
 

Tendances (20)

GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL Introduction
 
GraphQL Advanced
GraphQL AdvancedGraphQL Advanced
GraphQL Advanced
 
IIIF: Shared Canvas 2.0
IIIF: Shared Canvas 2.0IIIF: Shared Canvas 2.0
IIIF: Shared Canvas 2.0
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
 
End of Term Harvest User Interface
End of Term Harvest User Interface End of Term Harvest User Interface
End of Term Harvest User Interface
 
MuseoTorino, first italian project using a GraphDB, RDFa, Linked Open Data
MuseoTorino, first italian project using a GraphDB, RDFa, Linked Open DataMuseoTorino, first italian project using a GraphDB, RDFa, Linked Open Data
MuseoTorino, first italian project using a GraphDB, RDFa, Linked Open Data
 
GraphQL London January 2018: Graphql tooling
GraphQL London January 2018: Graphql toolingGraphQL London January 2018: Graphql tooling
GraphQL London January 2018: Graphql tooling
 
Open PHACTS API Walkthrough
Open PHACTS API WalkthroughOpen PHACTS API Walkthrough
Open PHACTS API Walkthrough
 
An intro to GraphQL
An intro to GraphQLAn intro to GraphQL
An intro to GraphQL
 
Standard Web APIs for Multidisciplinary Collaboration
Standard Web APIs for Multidisciplinary CollaborationStandard Web APIs for Multidisciplinary Collaboration
Standard Web APIs for Multidisciplinary Collaboration
 
Achieving the digital thread through PLM and ALM integration using oslc
Achieving the digital thread through PLM and ALM integration using oslcAchieving the digital thread through PLM and ALM integration using oslc
Achieving the digital thread through PLM and ALM integration using oslc
 
Koneksys Presentation March 2021
Koneksys Presentation March 2021Koneksys Presentation March 2021
Koneksys Presentation March 2021
 
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open WebKafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web
Kafka and GraphQL: Misconceptions and Connections | Gerard Klijs, Open Web
 
PyOSLC SDK - OSLCFEST
PyOSLC SDK - OSLCFESTPyOSLC SDK - OSLCFEST
PyOSLC SDK - OSLCFEST
 
Distributed Affordance
Distributed AffordanceDistributed Affordance
Distributed Affordance
 
This Week in Neo4j - 24th November 2018
This Week in Neo4j - 24th November 2018This Week in Neo4j - 24th November 2018
This Week in Neo4j - 24th November 2018
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Ajaxworld Opensocial Presentation
Ajaxworld Opensocial PresentationAjaxworld Opensocial Presentation
Ajaxworld Opensocial Presentation
 
Introduction to Open Services for Lifecycle Collaboration (OSLC)
Introduction to Open Services for Lifecycle Collaboration (OSLC)Introduction to Open Services for Lifecycle Collaboration (OSLC)
Introduction to Open Services for Lifecycle Collaboration (OSLC)
 
Overview of OSLC - INCOSE IW 2018 MBSE Workshop
Overview of OSLC - INCOSE IW 2018 MBSE Workshop Overview of OSLC - INCOSE IW 2018 MBSE Workshop
Overview of OSLC - INCOSE IW 2018 MBSE Workshop
 

En vedette

Use of Open Data in Hong Kong
Use of Open Data in Hong KongUse of Open Data in Hong Kong
Use of Open Data in Hong KongSammy Fung
 
Mozilla - Openness of the Web
Mozilla - Openness of the WebMozilla - Openness of the Web
Mozilla - Openness of the WebSammy Fung
 
Open API - 웹 플랫폼 생태계를 만드는 기술 (2011)
Open API - 웹 플랫폼 생태계를 만드는 기술 (2011)Open API - 웹 플랫폼 생태계를 만드는 기술 (2011)
Open API - 웹 플랫폼 생태계를 만드는 기술 (2011)Channy Yun
 
The Swagger Format becomes the Open API Specification: Standardizing descript...
The Swagger Format becomes the Open API Specification: Standardizing descript...The Swagger Format becomes the Open API Specification: Standardizing descript...
The Swagger Format becomes the Open API Specification: Standardizing descript...3scale
 
Build and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API GatewayBuild and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API GatewayAmazon Web Services
 

En vedette (7)

Use of Open Data in Hong Kong
Use of Open Data in Hong KongUse of Open Data in Hong Kong
Use of Open Data in Hong Kong
 
Mozilla - Openness of the Web
Mozilla - Openness of the WebMozilla - Openness of the Web
Mozilla - Openness of the Web
 
Kong API
Kong APIKong API
Kong API
 
Kong
KongKong
Kong
 
Open API - 웹 플랫폼 생태계를 만드는 기술 (2011)
Open API - 웹 플랫폼 생태계를 만드는 기술 (2011)Open API - 웹 플랫폼 생태계를 만드는 기술 (2011)
Open API - 웹 플랫폼 생태계를 만드는 기술 (2011)
 
The Swagger Format becomes the Open API Specification: Standardizing descript...
The Swagger Format becomes the Open API Specification: Standardizing descript...The Swagger Format becomes the Open API Specification: Standardizing descript...
The Swagger Format becomes the Open API Specification: Standardizing descript...
 
Build and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API GatewayBuild and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API Gateway
 

Similaire à Open Data and Web API

Creating Open Data with Open Source (beta2)
Creating Open Data with Open Source (beta2)Creating Open Data with Open Source (beta2)
Creating Open Data with Open Source (beta2)Sammy Fung
 
How do we develop open source software to help open data ? (MOSC 2013)
How do we develop open source software to help open data ? (MOSC 2013)How do we develop open source software to help open data ? (MOSC 2013)
How do we develop open source software to help open data ? (MOSC 2013)Sammy Fung
 
ResourceSync - Overview and Real-World Use Cases for Discovery, Harvesting, a...
ResourceSync - Overview and Real-World Use Cases for Discovery, Harvesting, a...ResourceSync - Overview and Real-World Use Cases for Discovery, Harvesting, a...
ResourceSync - Overview and Real-World Use Cases for Discovery, Harvesting, a...Martin Klein
 
Resource sync overview and real-world use cases for discovery, harvesting, an...
Resource sync overview and real-world use cases for discovery, harvesting, an...Resource sync overview and real-world use cases for discovery, harvesting, an...
Resource sync overview and real-world use cases for discovery, harvesting, an...openminted_eu
 
aip_developer_overview_icar_2014
aip_developer_overview_icar_2014aip_developer_overview_icar_2014
aip_developer_overview_icar_2014Matthew Vaughn
 
Global Open Source Development 2011-2014 Review and 2015 Forecast
Global Open Source Development 2011-2014 Review and 2015 ForecastGlobal Open Source Development 2011-2014 Review and 2015 Forecast
Global Open Source Development 2011-2014 Review and 2015 ForecastSammy Fung
 
Drupal and Apache Stanbol
Drupal and Apache StanbolDrupal and Apache Stanbol
Drupal and Apache StanbolAlkuvoima
 
Intro to Machine Learning with H2O and AWS
Intro to Machine Learning with H2O and AWSIntro to Machine Learning with H2O and AWS
Intro to Machine Learning with H2O and AWSSri Ambati
 
Session 03 acquiring data
Session 03 acquiring dataSession 03 acquiring data
Session 03 acquiring databodaceacat
 
Session 03 acquiring data
Session 03 acquiring dataSession 03 acquiring data
Session 03 acquiring dataSara-Jayne Terp
 
The original vision of Nutch, 14 years later: Building an open source search ...
The original vision of Nutch, 14 years later: Building an open source search ...The original vision of Nutch, 14 years later: Building an open source search ...
The original vision of Nutch, 14 years later: Building an open source search ...Sylvain Zimmer
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service BIOVIA
 
CKAN - the open source data portal platform
CKAN - the open source data portal platformCKAN - the open source data portal platform
CKAN - the open source data portal platformMaurizio Napolitano
 
No need to leave Connections. Bring your Domino applications into the Activit...
No need to leave Connections. Bring your Domino applications into the Activit...No need to leave Connections. Bring your Domino applications into the Activit...
No need to leave Connections. Bring your Domino applications into the Activit...LetsConnect
 
Developing Apps: Exposing Your Data Through Araport
Developing Apps: Exposing Your Data Through AraportDeveloping Apps: Exposing Your Data Through Araport
Developing Apps: Exposing Your Data Through AraportMatthew Vaughn
 
ICAR 2015 Workshop - Matt Vaughn
ICAR 2015 Workshop - Matt VaughnICAR 2015 Workshop - Matt Vaughn
ICAR 2015 Workshop - Matt VaughnAraport
 

Similaire à Open Data and Web API (20)

Ice dec04-04-sammy
Ice dec04-04-sammyIce dec04-04-sammy
Ice dec04-04-sammy
 
Creating Open Data with Open Source (beta2)
Creating Open Data with Open Source (beta2)Creating Open Data with Open Source (beta2)
Creating Open Data with Open Source (beta2)
 
How do we develop open source software to help open data ? (MOSC 2013)
How do we develop open source software to help open data ? (MOSC 2013)How do we develop open source software to help open data ? (MOSC 2013)
How do we develop open source software to help open data ? (MOSC 2013)
 
ResourceSync - Overview and Real-World Use Cases for Discovery, Harvesting, a...
ResourceSync - Overview and Real-World Use Cases for Discovery, Harvesting, a...ResourceSync - Overview and Real-World Use Cases for Discovery, Harvesting, a...
ResourceSync - Overview and Real-World Use Cases for Discovery, Harvesting, a...
 
Resource sync overview and real-world use cases for discovery, harvesting, an...
Resource sync overview and real-world use cases for discovery, harvesting, an...Resource sync overview and real-world use cases for discovery, harvesting, an...
Resource sync overview and real-world use cases for discovery, harvesting, an...
 
aip_developer_overview_icar_2014
aip_developer_overview_icar_2014aip_developer_overview_icar_2014
aip_developer_overview_icar_2014
 
Global Open Source Development 2011-2014 Review and 2015 Forecast
Global Open Source Development 2011-2014 Review and 2015 ForecastGlobal Open Source Development 2011-2014 Review and 2015 Forecast
Global Open Source Development 2011-2014 Review and 2015 Forecast
 
Drupal and Apache Stanbol
Drupal and Apache StanbolDrupal and Apache Stanbol
Drupal and Apache Stanbol
 
Intro to Machine Learning with H2O and AWS
Intro to Machine Learning with H2O and AWSIntro to Machine Learning with H2O and AWS
Intro to Machine Learning with H2O and AWS
 
Session 03 acquiring data
Session 03 acquiring dataSession 03 acquiring data
Session 03 acquiring data
 
Session 03 acquiring data
Session 03 acquiring dataSession 03 acquiring data
Session 03 acquiring data
 
The original vision of Nutch, 14 years later: Building an open source search ...
The original vision of Nutch, 14 years later: Building an open source search ...The original vision of Nutch, 14 years later: Building an open source search ...
The original vision of Nutch, 14 years later: Building an open source search ...
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Dnug2012 yellow and blue stream
Dnug2012 yellow and blue streamDnug2012 yellow and blue stream
Dnug2012 yellow and blue stream
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service
 
CKAN - the open source data portal platform
CKAN - the open source data portal platformCKAN - the open source data portal platform
CKAN - the open source data portal platform
 
No need to leave Connections. Bring your Domino applications into the Activit...
No need to leave Connections. Bring your Domino applications into the Activit...No need to leave Connections. Bring your Domino applications into the Activit...
No need to leave Connections. Bring your Domino applications into the Activit...
 
Developing Apps: Exposing Your Data Through Araport
Developing Apps: Exposing Your Data Through AraportDeveloping Apps: Exposing Your Data Through Araport
Developing Apps: Exposing Your Data Through Araport
 
ICAR 2015 Workshop - Matt Vaughn
ICAR 2015 Workshop - Matt VaughnICAR 2015 Workshop - Matt Vaughn
ICAR 2015 Workshop - Matt Vaughn
 
Butler - Security Lessons Learned from an Ezproxy Admin
Butler - Security Lessons Learned from an Ezproxy AdminButler - Security Lessons Learned from an Ezproxy Admin
Butler - Security Lessons Learned from an Ezproxy Admin
 

Plus de Sammy Fung

Python 爬網⾴工具 - Scrapy 介紹
Python 爬網⾴工具 - Scrapy 介紹Python 爬網⾴工具 - Scrapy 介紹
Python 爬網⾴工具 - Scrapy 介紹Sammy Fung
 
DevRel - Transform article writing from printing to online
DevRel - Transform article writing from printing to onlineDevRel - Transform article writing from printing to online
DevRel - Transform article writing from printing to onlineSammy Fung
 
Introduction to Open Source by opensource.hk (2019 Edition)
Introduction to Open Source by opensource.hk (2019 Edition)Introduction to Open Source by opensource.hk (2019 Edition)
Introduction to Open Source by opensource.hk (2019 Edition)Sammy Fung
 
My Open Source Journey - Developer and Community
My Open Source Journey - Developer and CommunityMy Open Source Journey - Developer and Community
My Open Source Journey - Developer and CommunitySammy Fung
 
Introduction to development with Django web framework
Introduction to development with Django web frameworkIntroduction to development with Django web framework
Introduction to development with Django web frameworkSammy Fung
 
香港中文開源軟件翻譯
香港中文開源軟件翻譯香港中文開源軟件翻譯
香港中文開源軟件翻譯Sammy Fung
 
Open Source Technology and Community
Open Source Technology and CommunityOpen Source Technology and Community
Open Source Technology and CommunitySammy Fung
 
Access Open Data with Open Source Software Tools
Access Open Data with Open Source Software ToolsAccess Open Data with Open Source Software Tools
Access Open Data with Open Source Software ToolsSammy Fung
 
Installation of LAMP Server with Ubuntu 14.10 Server Edition
Installation of LAMP Server with Ubuntu 14.10 Server EditionInstallation of LAMP Server with Ubuntu 14.10 Server Edition
Installation of LAMP Server with Ubuntu 14.10 Server EditionSammy Fung
 
Software Freedom and Open Source Community
Software Freedom and Open Source CommunitySoftware Freedom and Open Source Community
Software Freedom and Open Source CommunitySammy Fung
 
Building your own job site with Drupal
Building your own job site with DrupalBuilding your own job site with Drupal
Building your own job site with DrupalSammy Fung
 
Use open source software to develop ideas at work
Use open source software to develop ideas at workUse open source software to develop ideas at work
Use open source software to develop ideas at workSammy Fung
 
Software Freedom and Community
Software Freedom and CommunitySoftware Freedom and Community
Software Freedom and CommunitySammy Fung
 
Open Source Job Board
Open Source Job BoardOpen Source Job Board
Open Source Job BoardSammy Fung
 
Introduction of Mozilla Hong Kong (COSCUP 2014)
Introduction of Mozilla Hong Kong (COSCUP 2014)Introduction of Mozilla Hong Kong (COSCUP 2014)
Introduction of Mozilla Hong Kong (COSCUP 2014)Sammy Fung
 
Introduction of Open Source Job Board with Drupal CMS
Introduction of Open Source Job Board with Drupal CMSIntroduction of Open Source Job Board with Drupal CMS
Introduction of Open Source Job Board with Drupal CMSSammy Fung
 
Python, web scraping and content management: Scrapy and Django
Python, web scraping and content management: Scrapy and DjangoPython, web scraping and content management: Scrapy and Django
Python, web scraping and content management: Scrapy and DjangoSammy Fung
 
Local Weather Information and GNOME Shell Extension
Local Weather Information and GNOME Shell ExtensionLocal Weather Information and GNOME Shell Extension
Local Weather Information and GNOME Shell ExtensionSammy Fung
 
Mozilla Community and Hong Kong
Mozilla Community and Hong KongMozilla Community and Hong Kong
Mozilla Community and Hong KongSammy Fung
 
ITFest 2014 - Open Source Marketing
ITFest 2014 - Open Source MarketingITFest 2014 - Open Source Marketing
ITFest 2014 - Open Source MarketingSammy Fung
 

Plus de Sammy Fung (20)

Python 爬網⾴工具 - Scrapy 介紹
Python 爬網⾴工具 - Scrapy 介紹Python 爬網⾴工具 - Scrapy 介紹
Python 爬網⾴工具 - Scrapy 介紹
 
DevRel - Transform article writing from printing to online
DevRel - Transform article writing from printing to onlineDevRel - Transform article writing from printing to online
DevRel - Transform article writing from printing to online
 
Introduction to Open Source by opensource.hk (2019 Edition)
Introduction to Open Source by opensource.hk (2019 Edition)Introduction to Open Source by opensource.hk (2019 Edition)
Introduction to Open Source by opensource.hk (2019 Edition)
 
My Open Source Journey - Developer and Community
My Open Source Journey - Developer and CommunityMy Open Source Journey - Developer and Community
My Open Source Journey - Developer and Community
 
Introduction to development with Django web framework
Introduction to development with Django web frameworkIntroduction to development with Django web framework
Introduction to development with Django web framework
 
香港中文開源軟件翻譯
香港中文開源軟件翻譯香港中文開源軟件翻譯
香港中文開源軟件翻譯
 
Open Source Technology and Community
Open Source Technology and CommunityOpen Source Technology and Community
Open Source Technology and Community
 
Access Open Data with Open Source Software Tools
Access Open Data with Open Source Software ToolsAccess Open Data with Open Source Software Tools
Access Open Data with Open Source Software Tools
 
Installation of LAMP Server with Ubuntu 14.10 Server Edition
Installation of LAMP Server with Ubuntu 14.10 Server EditionInstallation of LAMP Server with Ubuntu 14.10 Server Edition
Installation of LAMP Server with Ubuntu 14.10 Server Edition
 
Software Freedom and Open Source Community
Software Freedom and Open Source CommunitySoftware Freedom and Open Source Community
Software Freedom and Open Source Community
 
Building your own job site with Drupal
Building your own job site with DrupalBuilding your own job site with Drupal
Building your own job site with Drupal
 
Use open source software to develop ideas at work
Use open source software to develop ideas at workUse open source software to develop ideas at work
Use open source software to develop ideas at work
 
Software Freedom and Community
Software Freedom and CommunitySoftware Freedom and Community
Software Freedom and Community
 
Open Source Job Board
Open Source Job BoardOpen Source Job Board
Open Source Job Board
 
Introduction of Mozilla Hong Kong (COSCUP 2014)
Introduction of Mozilla Hong Kong (COSCUP 2014)Introduction of Mozilla Hong Kong (COSCUP 2014)
Introduction of Mozilla Hong Kong (COSCUP 2014)
 
Introduction of Open Source Job Board with Drupal CMS
Introduction of Open Source Job Board with Drupal CMSIntroduction of Open Source Job Board with Drupal CMS
Introduction of Open Source Job Board with Drupal CMS
 
Python, web scraping and content management: Scrapy and Django
Python, web scraping and content management: Scrapy and DjangoPython, web scraping and content management: Scrapy and Django
Python, web scraping and content management: Scrapy and Django
 
Local Weather Information and GNOME Shell Extension
Local Weather Information and GNOME Shell ExtensionLocal Weather Information and GNOME Shell Extension
Local Weather Information and GNOME Shell Extension
 
Mozilla Community and Hong Kong
Mozilla Community and Hong KongMozilla Community and Hong Kong
Mozilla Community and Hong Kong
 
ITFest 2014 - Open Source Marketing
ITFest 2014 - Open Source MarketingITFest 2014 - Open Source Marketing
ITFest 2014 - Open Source Marketing
 

Dernier

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 

Dernier (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Open Data and Web API

  • 1. Open Data and Web API Sammy Fung Technology Sharing (28/1/2016) at Hong Kong Polytechnic University COMP
  • 2. Sammy Fung • President, Open Source Hong Kong. • Conference Chair, Hong Kong Open Source Conference. • Tags: Freelancer, Developer, Open Source, Open Data, Startup. • Contacts: • sammy@sammy.hk • @sammyfung • https://github.com/sammyfung • The presentation slide will be public on SlideShare in CC license. • Creative Commons BY-NC-SA (Attribution, Non-Commerical, Sharealike)
  • 5. 1. What is current Air Quality Health Index (AQHI) of Causeway Bay ?
  • 6. AQHI • Environment Protection Department (EPD) • Find it out from AQHI website run by EPD. • http://www.aqhi.gov.hk/en.html • How about details of air quality in Causeway Bay ? Look into Pollutant Concentration of CWB.
  • 7. So, we just found the “data” by human.
  • 8. How does software program read the AQHI and Pollutant Concentration of CWB (“data”) ?
  • 9. Software and Data • We need values of data for software program. • an integer or a float: eg. 2016, 6.89 • a character string: eg. “Causeway Bay” • Retrieve data through “Interface” for data. • Application Programming Interface (API) • Computer/Software/Program Readable Data Format. • Human communicates in a common language, eg. English, Cantonese, Mandarin. • Data Formats: eg. XML, JSON.
  • 10. XML Example <developers> <developer> <firstName>Richard</firstName> <lastName>Stallman</lastName> </developer> <developer> <firstName>Linus</firstName> <lastName>Torvalds</lastName> </developer> <developer> <firstName>Eric</firstName> <lastName>Raymond</lastName> </developer> </developers>
  • 11. JSON Example {"developers":[ {"firstName":"Richard", "lastName":"Stallman"}, {"firstName":"Linus", "lastName":"Torvalds"}, {"firstName":"Eric", "lastName":"Raymond"} ]}
  • 12. Software and Data • Web Scraping: Retrieve documents from website. • Information Extraction & Transformation: • Extract and Transform data from common data format into data objects (variables) in software program. • eg. JSON -> Float(s) • “Clean Data” is needed for “non-good” data formats. • eg. HTML -> Float(s)
  • 13. Software and Data • Programming Language: eg. Python • Web Scraping library: import scrapy • JSON library: import json • Regular Expression library: import re • Other libraries (eg. database): import mysql
  • 14. Installing Scrapy • Scrapy is a web scraping framework written in ptyhon. • virtualenv ~/env/scrapy • source ~/env/scrapy/bin/activate • pip install scrapy
  • 15. Try in Scrapy Shell • Try in Scrapy Shell: • scrapy startproject demo1 • scrapy shell http://www.aqhi.gov.hk/epd/ddata/html/out/ 24aqhi_Eng.xml • a =response.xpath("//item[contains(.//StationName/text(), 'Causeway Bay’)]/aqhi/text()").extract() • b = a[len(a)-1] # b is string • c = int(a[len(a)-1]) # c is integer • print (b, c) # show the difference
  • 16. AQHI • Phase 1: EPD provided AQHI in XML format. • Phase 2: EPD provided both AQHI and Pollutant Concentration in XML format.
  • 17. 2. What is the current temperature of Shatin ?
  • 18. Weather • Hong Kong Observatory (HKO) • http://www.weather.gov.hk • Top Hobbyist Website: Weather Underground http://www.weather.org.hk/
  • 19. So, we just found another “data” again by human.
  • 20. How does software program read the current temperature of Shatin (“data”) ?
  • 21. Sorry! You need to subscribe to commercial paid data feed services provided by HKO. XD
  • 23. We can do it by scraping from HTML document (a harder method)
  • 24. Try in Scrapy • scrapy shell http://www.weather.gov.hk/wxinfo/ts/ text_readings_e.htm • a = response.xpath(“//pre").extract()[0] • import re • b = re.split("n", a)
  • 25. Clean Data with RE c = ‘’ for i in b: if re.search("^Sha Tin", i) and c=‘’: c = re.sub("^Sha Tin *”,"",i) c = re.sub(" .*”,”",c) print c # c is string print float(c) # c is float
  • 27. Open Data • Discoverable • Available and Searchable on Internet. • Structured • Open and Machine-readable Format. • Unconditional • Legal Framework allows to reproduce and repurpose the data.
  • 28. 5-star Open Data DeploymentScheme • Tim Berners-Lee, the inventor of the Web. • 5stardata.info • 1 Star: make your stuff available on the Web (whatever format) under an open license. • 2 Star: make it available as structured data • eg. Excel instead of image scan of a table • 3 Star: use non-proprietary formats • eg. CSV instead of Excel • 4 Star: use URIs to denote things, so that people can point at your stuff • 5 Star: link your data to other data to provide context.
  • 29. Open Data in Hong Kong • OGCIO • DATA.ONE in 2011. • data.gov.hk in 2015. • JSON/XML, RSS, XLS, CSV, JPEG/PNG,…. • Define workflow for other government department to release open data. • OGCIO could not decide which data and format can be released • Decision made by data owner of each government departments.
  • 30. Open Data in Hong Kong • LegCo • http://www.legco.gov.hk • Voting results of LegCo meetings and some committee meetings in XML in Oct 2013. • API is available in Fall 2014. • Not part of DATA.ONE / DATA.GOV.HK.
  • 31. HK Air Quality Data • AQHI, old API and Pollutant Concentration • XML Data for past 24 hours. • CSV Data for all past records. • EPD released AQHI and old API at phase 1 few years ago. • EPD also released Pollutant Concentration data in machine-readable format at phase 2 one year ago.
  • 32. Weather in DATA.GOV.HK • I posted a blog 'Progress of Open Government Data in Hong Kong' on 2013/01/17. • Weather at Data.One released 7 datasets only. • All datasets are in RSS (XML) format which includes items with title and description only. • Hourly weather reports, weather forecasts and special reports in 3 languages. • Examples of missing data: • Regional Weather Data updates from stations in every 10 minutes. • One word: Useless. • RSS Datasets on DATA.GOV.HK is completely different with HKO paid service (XML data feed).
  • 34. API • API = Application Programming Interface • Retrieve data through “Interface”. • C API, Python API, Objective-C API, Java API……
  • 35. Web API • API for Web Server or Web Browser/Client. • Usually Web APIs are used for connecting to 3rd party web services. • Request and Response messaging interface via Web (HTTP) defined by service providers. • Request URI example: https://api.twitter.com/1.1/ statuses/user_timeline.json • Data are exchanged in JSON or XML format.
  • 36. Web API Examples • Payments: Paypal, MasterPass,… • Online Services: Google, GitHub,… • Social Networks: Twitter, Facebook,…
  • 37. REST • Representational state transfer • One of reference styles of data exchange for Web 2.0. • Web API design are usually in REST style. • Systems communicates using HTTP verbs over HTTP communication. • HTTP Verbs: GET, POST, PUT, DELETE,… • GET: list or retrieve data • POST: create data • PUT: update or replace data • DELETE: delete data
  • 38. Communication Flow with API • Authorization • to retrieve a token for your web/mobile/backend apps to use the 3rd party API services. • Re-direct users to 3rd party services for one-time auth (eg. Username, Password), and token will be used for future access until token is expired. • For Application or Application-User Authorisation. • eg. OAuth, XAuth. • Do your any web API calls. • API Rate Limits
  • 39. Tweepy • a 3rd party twitter library for python. • pip install tweepy • http://tweepy.readthedocs.org
  • 40. Open Data and Web API • Structure of Open Data and Syntax of Web API will be changed by service / data providers from time to time. • You should subscribe to developer blog of those API and data services if possible. • Use existing open source software tools to use web API, otherwise build your own tools (and consider to make it open source)
  • 41. Open Source Software (Very Quick Version)
  • 42. Open Source Software • Open Source = Source Codes are available to public. • License: Licensed in one of Open Source Licenses. • Freedom: Freely (re-)distribute • You can charge for distribution costs but almost no one will do so. • GitHub: Rich open source software library • Git: a distributed version control software tool.
  • 43. References • Free Software Codes: www.github.com • Community: opensource.hk • Conference: 2016.opensource.hk • 6/24-25 Cyberport • This Slide: slideshare.com/sammyfung • Contact: sammy@sammy.hk / @sammyfung