Slide 1

Slide 1 text

FAST SECURE FAST SECURE USABLE APIS: USABLE APIS: BUILD BUILD APIS THAT PEOPLE USE APIS THAT PEOPLE USE WITH WITH NODE.JS AND NODE.JS AND HACKS THAT WIN HACKS THAT WIN WITH WITH OPEN DATA OPEN DATA #nodejs #api #opendata #hackthenorth codx.ca/hackthenorth ahmadnassri.com 1

Slide 2

Slide 2 text

HELLO! HELLO! 2 . 1

Slide 3

Slide 3 text

GET /who HTTP/1.1 Host: www.ahmadnassri.com Accept: application/json HTTP/1.1 200 OK Date: Sat, 17 Sep 2016 12:00:00 GMT Content­Type: application/json { "name": "Ahmad Nassri", "website": "http://www.ahmadnassri.com/", "twitter": "@AhmadNassri", "email": "[email protected]", "bio": "Technologist, Entrepreneur, Dog Lover" } AHMAD NASSRI AHMAD NASSRI 2 . 2

Slide 4

Slide 4 text

GET /who HTTP/1.1 Host: joseph.by Accept: application/json HTTP/1.1 200 OK Date: Sat, 17 Sep 2016 12:00:00 GMT Content­Type: application/json { "name": "Joseph Bou­Younes", "website": "http://joseph.by/", "twitter": "@josephby", "email": "[email protected]", "bio": "Business, Tech, Data, Diapers" } JOSEPH BOU YOUNES JOSEPH BOU YOUNES 2 . 3

Slide 5

Slide 5 text

WHAT EXACTLY IS WHAT EXACTLY IS AN "API" ? AN "API" ? 3 . 1

Slide 6

Slide 6 text

“ In Egyptian mythology, Apis, is a bull-deity that was worshipped in the Memphis region. Apis served as an intermediary between humans and an all-powerful god. EGYPTOLOGY?! EGYPTOLOGY?! 3 . 2

Slide 7

Slide 7 text

“ an application programming interface (API) is a set of routines, protocols, and tools for building software applications. COMPUTER PROGRAMMING COMPUTER PROGRAMMING 3 . 3

Slide 8

Slide 8 text

WEB SERVICES WEB SERVICES “ A Web service is a method of communication between two electronic devices over a network. It is a software function provided at a network address over the web with the service always on. 3 . 4

Slide 9

Slide 9 text

RESTful Web APIs RESTful Web APIs REST (REpresentational State Transfer) is a simple stateless architecture style that generally runs over HTTP. 3 . 5

Slide 10

Slide 10 text

BEST PRACTICES BEST PRACTICES 4 . 1

Slide 11

Slide 11 text

BE BE FRIENDLY FRIENDLY TO THE TO THE DEVELOPER AND BE DEVELOPER AND BE EXPLORABLE EXPLORABLE VIA A VIA A BROWSER ADDRESS BAR BROWSER ADDRESS BAR 4 . 2

Slide 12

Slide 12 text

KEEP IT SIMPLE, KEEP IT SIMPLE, INTUITIVE INTUITIVE AND AND CONSISTENT CONSISTENT TO MAKE TO MAKE ADOPTION EASY & ADOPTION EASY & PLEASANT PLEASANT 4 . 3

Slide 13

Slide 13 text

PROVIDE ENOUGH PROVIDE ENOUGH FLEXIBILITY FLEXIBILITY TO POWER TO POWER THE MAJORITY OF USE THE MAJORITY OF USE CASES CASES 4 . 4

Slide 14

Slide 14 text

USE WEB USE WEB STANDARDS STANDARDS WHERE THEY MAKE WHERE THEY MAKE SENSE SENSE 4 . 5

Slide 15

Slide 15 text

STANDARDS STANDARDS 4 . 6

Slide 16

Slide 16 text

HYPERMEDIA HYPE HYPERMEDIA HYPE Collection+JSON Hypertext Application Language (HAL) ATOM 4 . 7

Slide 17

Slide 17 text

GET /player/1234567890 HTTP/1.1 { "@context": { "@vocab": "https://schema.org/", "image": { "@type": "@id" }, "friends": { "@type": "@id" } }, "@id": "https://api.example.com/player/1234567890", "playerId": "1234567890", "name": "Kevin Sookocheff", "alternateName": "soofaloofa", "image": "https://api.example.com/player/1234567890/avatar.png", "friends": "https://api.example.com/player/1234567890/friends" } JSON-LD JSON-LD 4 . 8

Slide 18

Slide 18 text

AUTHENTICATION AUTHENTICATION RFC 2617 4 . 9

Slide 19

Slide 19 text

# URL Versioning: GET /api/v2/foo HTTP/1.1 # Custom Header: GET /api/foo X-VERSION: 2 # Content Type GET: /api/foo Accept: application/vnd.github.v3.raw+json VERSIONING VERSIONING 4 . 10

Slide 20

Slide 20 text

NODEJS NODEJS STARTER KIT STARTER KIT 5 . 1

Slide 21

Slide 21 text

5 . 2

Slide 22

Slide 22 text

5 . 3

Slide 23

Slide 23 text

6 . 1

Slide 24

Slide 24 text

YOUR API IS YOUR API IS A A PRODUCT PRODUCT! ! 6 . 2

Slide 25

Slide 25 text

FLEXIBLE FLEXIBLE INTUITIVE INTUITIVE CONSISTENT CONSISTENT PLEASANT PLEASANT EXPLORABLE EXPLORABLE STANDARDS STANDARDS 6 . 3

Slide 26

Slide 26 text

#OPENDATA #OPENDATA 7 . 1

Slide 27

Slide 27 text

OPEN DATA? OPEN DATA? "Open [data] means anyone can freely access, use, modify, and share the data for any purpose (subject, at most, to requirements that preserve provenance and openness)." - the Open Definition project It's the fastest and easiest way to bring the outside world into your hack. codx.ca/hackthenorth 7 . 2

Slide 28

Slide 28 text

WHAT CAN YOU GET? WHAT CAN YOU GET? Useful Examples! Building Permits Car Travel Speed Corporate Registration Information (Company Names, Addresses & Director Names) Parking Tickets Weather Forecasts codx.ca/hackthenorth 7 . 3

Slide 29

Slide 29 text

WHAT CAN YOU GET? WHAT CAN YOU GET? Level of Gov't Responsibilities Example Data Federal Agriculture, Financial Services, Economic Data, Natural Resources, CRA, Census, Weather Agriculture, Financial Services, Economic Data, Natural Resources, CRA, Census, Weather Criminal Code Weather GIS and Imagery Economic Data Tax Code Provincial Courts, Education, Environment, Energy, Health Care K-12 Curriculum Court Rulings Municipal Water, Traffic, Parking, Property Tax Property Tax Traffic Flows codx.ca/hackthenorth 7 . 4

Slide 30

Slide 30 text

WHAT CAN YOU GET? WHAT CAN YOU GET? WARNING: Data is often old, out of date, or inconsistent. LOOK FIRST codx.ca/hackthenorth 7 . 5

Slide 31

Slide 31 text

FINDING OPEN DATA FINDING OPEN DATA 1. codx.ca/hackthenorth codx.ca/hackthenorth 7 . 6

Slide 32

Slide 32 text

FINDING OPEN DATA FINDING OPEN DATA 2. Google codx.ca/hackthenorth 7 . 7

Slide 33

Slide 33 text

FINDING OPEN DATA FINDING OPEN DATA 3. Portals codx.ca/hackthenorth 7 . 8

Slide 34

Slide 34 text

FINDING OPEN DATA FINDING OPEN DATA 4. Check Usability Text Text Text NO! codx.ca/hackthenorth 7 . 9

Slide 35

Slide 35 text

FINDING OPEN DATA FINDING OPEN DATA 5. Download! codx.ca/hackthenorth 7 . 10

Slide 36

Slide 36 text

THANK YOU THANK YOU Twitter @AhmadNassri Slack @AhmadNassri Website / Blog AhmadNassri.com Twitter @josephby Slack @josephby RFTM codx.ca/hackthenorth 8