#100DaysOfCode in Python Transcripts
Chapter: Days 97-99: Building JSON APIs
Lecture: Making the client self-validating

Login or purchase this course to watch this video and the rest of the course contents.
0:00 So we're over here, and we're calling service all_rolls,
0:04 and then we have to, remember you have to basically say,
0:07 service.all_rolls. Store that," and another thing
0:11 you have to say, raise_for_status
0:15 and then call JSON if that worked.
0:17 So that was really cumbersome.
0:20 So we created this thing called The uplink_helpers,
0:26 which had this basically uplink response handler
0:30 raise_for_status.
0:32 So if we go over here to our game,
0:34 oh sorry, api, excuse me, and we say this,
0:38 then it won't let any code through that fails.
0:42 So we know that it's safe to say .json right here,
0:45 'cause it's already tested it.
0:47 We can do better though.
0:48 We make it all of these methods return the dot.
0:50 JSON will response a result by adding one other thing.
0:55 This response to data.
0:56 So given a response, we just call response.json.
0:59 Otherwise, they throw a format error.
1:02 If we also put this at the top,
1:06 on the outside, not the inside.
1:08 The outside; That's important.
1:10 And this one goes on the inside.
1:11 Then we can come down here, and just print this.
1:15 And we should be our little devil, all the various pieces.
1:19 We do. Very nice. So I feel like our game service is in place,
1:23 and that really makes working with it nice and easy.