Introd u ction to APIs and JSONs IN TE R ME D IATE IMP OR TIN G - - PowerPoint PPT Presentation

introd u ction to apis and jsons
SMART_READER_LITE
LIVE PREVIEW

Introd u ction to APIs and JSONs IN TE R ME D IATE IMP OR TIN G - - PowerPoint PPT Presentation

Introd u ction to APIs and JSONs IN TE R ME D IATE IMP OR TIN G DATA IN P YTH ON H u go Bo w ne - Anderson Data Scientist at DataCamp APIs Application Programming Interface Protocols and ro u tines B u ilding and interacting w ith so w


slide-1
SLIDE 1

Introduction to APIs and JSONs

IN TE R ME D IATE IMP OR TIN G DATA IN P YTH ON

Hugo Bowne-Anderson

Data Scientist at DataCamp

slide-2
SLIDE 2

INTERMEDIATE IMPORTING DATA IN PYTHON

APIs

Application Programming Interface Protocols and routines Building and interacting with soware applications

slide-3
SLIDE 3

INTERMEDIATE IMPORTING DATA IN PYTHON

APIs

Application Programming Interface Protocols and routines Building and interacting with soware applications

slide-4
SLIDE 4

INTERMEDIATE IMPORTING DATA IN PYTHON

JSONs

JavaScript Object Notation Real-time server-to-browser communication Douglas Crockford Human readable

slide-5
SLIDE 5

INTERMEDIATE IMPORTING DATA IN PYTHON

JSONs

slide-6
SLIDE 6

INTERMEDIATE IMPORTING DATA IN PYTHON

JSONs

slide-7
SLIDE 7

INTERMEDIATE IMPORTING DATA IN PYTHON

JSONs

slide-8
SLIDE 8

INTERMEDIATE IMPORTING DATA IN PYTHON

Loading JSONs in Python

import json with open('snakes.json', 'r') as json_file: json_data = json.load(json_file) type(json_data) dict

slide-9
SLIDE 9

INTERMEDIATE IMPORTING DATA IN PYTHON

Exploring JSONs in Python

for key, value in json_data.items(): print(key + ':', value) Title: Snakes on a Plane Country: Germany, USA, Canada Response: True Language: English Awards: 3 wins & 7 nominations. Year: 2006 Actors: Samuel L. Jackson, Julianna Margulies Runtime: 105 min Genre: Action, Adventure, Crime imdbID: tt0417148 Director: David R. Ellis imdbRating: 5.6 Rated: R Released: 18 Aug 2006

slide-10
SLIDE 10

Let's practice!

IN TE R ME D IATE IMP OR TIN G DATA IN P YTH ON

slide-11
SLIDE 11

APIs and interacting with the world wide web

IN TE R ME D IATE IMP OR TIN G DATA IN P YTH ON

Hugo Bowne-Anderson

Data Scientist at DataCamp

slide-12
SLIDE 12

INTERMEDIATE IMPORTING DATA IN PYTHON

Herein, you’ll learn

What APIs are Why APIs are important In the exercises: Connecting to APIs Pulling data from APIs Parsing data from APIs

slide-13
SLIDE 13

INTERMEDIATE IMPORTING DATA IN PYTHON

What is an API?

Set of protocols and routines Bunch of code Allows two soware programs to communicate with each

  • ther
slide-14
SLIDE 14

INTERMEDIATE IMPORTING DATA IN PYTHON

What is an API?

Set of protocols and routines Bunch of code Allows two soware programs to communicate with each

  • ther
slide-15
SLIDE 15

INTERMEDIATE IMPORTING DATA IN PYTHON

APIs are everywhere

slide-16
SLIDE 16

INTERMEDIATE IMPORTING DATA IN PYTHON

APIs are everywhere

slide-17
SLIDE 17

INTERMEDIATE IMPORTING DATA IN PYTHON

APIs are everywhere

slide-18
SLIDE 18

INTERMEDIATE IMPORTING DATA IN PYTHON

APIs are everywhere

slide-19
SLIDE 19

INTERMEDIATE IMPORTING DATA IN PYTHON

Connecting to an API in Python

import requests url = 'http://www.omdbapi.com/?t=hackers' r = requests.get(url) json_data = r.json() for key, value in json_data.items(): print(key + ':', value)

slide-20
SLIDE 20

INTERMEDIATE IMPORTING DATA IN PYTHON

What was that URL?

hp - making an HTTP request www.omdbapi.com - querying the OMDB API

?t=hackers

Query string Return data for a movie with title (t) ‘Hackers’

'http://www.omdbapi.com/?t=hackers'

slide-21
SLIDE 21

INTERMEDIATE IMPORTING DATA IN PYTHON

OMDb API

slide-22
SLIDE 22

INTERMEDIATE IMPORTING DATA IN PYTHON

OMDb API

slide-23
SLIDE 23

INTERMEDIATE IMPORTING DATA IN PYTHON

It’s a regular URL!

slide-24
SLIDE 24

Let's practice!

IN TE R ME D IATE IMP OR TIN G DATA IN P YTH ON