#100DaysOfCode in Python Transcripts
Chapter: Days 97-99: Building JSON APIs
Lecture: What API operations are required?

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now before we write some code and we're going to do
0:02 some pretty interesting things, I think,
0:04 in terms of organization and the way
0:05 we put this all together but let's just think
0:07 at a really high level, what operations
0:10 does our website need to support?
0:12 So we'll talk about how to build these.
0:14 But let's just sit back and think about,
0:16 if you can remember back to our 15-way persistent
0:20 Rock Paper Scissors, pretty recent,
0:22 we had a couple of things that were happening in that game.
0:26 Here's what I think we're going to need to do in order
0:29 to move all the logic and persistence to the server
0:32 and still let the client communicate with it.
0:35 So first of all, you're going to need to be able to
0:37 register a user or get an existing user
0:40 and I broke those apart you know, with a website,
0:42 it just kind of seemed like you should either
0:44 kind of login or register as two separate things.
0:47 You can put them separate or if you want to,
0:49 you can combine them back like we had get or create user.
0:52 We want to start a new game, now this is really important
0:55 because what we're going to do is we're going to create
0:57 basically an id for the game and all subsequent
1:00 operations will exchange that game id as part of
1:04 who they are and how they're interacting so if you ask
1:07 for, show me the history, who won, play a round,
1:10 you're going to pass around this id that
1:12 we get by starting a new game,
1:13 we will show the rolls and let the user pick
1:17 the rolls from an existing list.
1:19 Now we could just hard code the 15 rolls into the client
1:21 but what if we want to someday upgrade it?
1:24 Maybe around St. Paddy's Day, you could throw a leprechaun
1:27 and you want to make that a feature of the game,
1:28 you want to add it, it just automatically have everybody
1:30 pick those up or you want to convert it to 25-way
1:33 Rock Paper Scissors or something along those lines.
1:35 So we're going to get the rolls from the server
1:38 so that we're always consistent
1:39 with what the server expects.
1:41 We can ask, what is the game status?
1:43 Most importantly, is it over and who won and things
1:46 like that but this will kind of give us the history
1:49 and the status of whether it's over and so on
1:51 and finally one of the critical parts
1:54 is actually playing a round.
1:56 I want to roll the devil and see what happens, right.
1:58 We'll have a computer player on the other side
2:01 and they'll randomly choose something and you'll see
2:03 if they win, whether you win and so on.
2:05 But this is sort of the playing of the game
2:08 and we'll just play the rounds until
2:09 we find out that the game is over.
2:12 And finally, one of the fun things we had in the original
2:14 game, the persistent one, was when it started it showed
2:17 that the players with the top scores.
2:20 Of course, those were just the players on your machine
2:22 that you happened to have played previously.
2:24 We're going to add a top scores operation so basically
2:28 you get the global top scores and you can be ranked
2:31 in the top ten, in the entire world in 15way
2:34 Rock Paper Scissors demo app, wouldn't that be cool?
2:37 So you'll be able to see that here, as it comes along.
2:41 So these are the operations we're going to build in Flask.