Learn Python with Talk Python's 270 hours of courses

#125: Django REST framework and a new API star is born Transcript

Recorded on Thursday, Jun 8, 2017.

00:00 APIs were once the new and enabling thing in technology.

00:02 Today, they're table stakes, and getting them right is important.

00:06 Today, we'll talk about one of the most popular and mature frameworks in Django REST framework.

00:11 You'll meet the creator, Tom Christie, and talk about the framework, API design,

00:15 and even his successful take on funding open source projects.

00:19 But Tom is not done here.

00:20 He's also creating the next-generation API framework that fully embraces Python 3's features called API Star.

00:27 It's all about frameworks on Talk Python to me.

00:30 Episode 125, recorded June 8, 2017.

00:57 Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.

01:04 This is your host, Michael Kennedy.

01:06 Follow me on Twitter, where I'm @mkennedy.

01:08 Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.

01:15 This episode is brought to you by Linode and Rollbar.

01:19 That's right.

01:20 Welcome to Linode, who has joined Talk Python to me as a major sponsor.

01:25 Be sure to check out what both of them are offering during their segments.

01:28 It really helps support the show.

01:29 Tom, welcome to Talk Python.

01:32 Hi.

01:32 Hey, it's great to see you again, and great to have you on the show finally.

01:36 I've been admiring Django REST framework for a long time, and really a fan of your new work that we're going to get into.

01:42 So I'm happy to have you here to talk about it.

01:44 Cheers, Mike.

01:44 Good to see you again.

01:45 Yeah, yeah.

01:45 How are you doing, anyway?

01:46 I'm doing super well, super well.

01:48 So I want to hear how you got into programming and Python and all that, but how was PyCon?

01:53 We were both there the last time I saw you.

01:55 Even though right now we're like 6,000 miles apart, we were in the same room just a little

02:01 while ago.

02:01 How did you enjoy it?

02:02 It was hectic.

02:05 You had a booth, right?

02:08 Yeah, we had a booth.

02:10 So I haven't done PyCon before, mostly because with it being over in the States, in the past

02:17 it's been hard for me to justify taking the time and the cost of the transatlantic flight

02:23 and so on.

02:24 Since I've been, and I guess we'll talk about this later, but since I've been doing open

02:29 source for a living, all of a sudden, okay, I really better step up and get across there.

02:35 And I kind of realized slightly later on in the day, oh, wait a minute, they have this

02:39 thing where they offer booths to open source projects.

02:43 We better do that.

02:45 That sounds like a good idea.

02:46 And yeah, just about managed to organize getting one of those with a lot of help from Anna,

02:53 who I also work with.

02:56 And I didn't know what to expect, but it was just nonstop, basically.

03:01 That's really good, right?

03:02 People are dropping in to talk to you about your project.

03:04 Yeah.

03:05 And there's so much kind of positive reinforcement coming from people at the stage, but it was

03:10 just nonstop talking for about three days together with the poster session as well.

03:16 So I have no idea how many, felt like hundreds, but...

03:21 Yeah, that's really cool.

03:22 We had a booth as well for all the podcasters that we had gotten grouped together and had

03:28 the five podcasts all put together in the one booth.

03:31 And it was a real similar experience.

03:32 Like the positive vibes and the feedback was amazing.

03:34 Some of the other guys who hadn't been there before, they were like, wow, this kind of makes

03:40 it so real with all these people.

03:42 Did you have that similar experience?

03:43 Like, you know, there's a number of stars on GitHub and you get a message and stuff,

03:47 but like when hundreds of people come up to you and talk to how you've like enabled something,

03:51 did that strike you pretty strongly?

03:53 I kind of had this odd mixed feelings about, not mixed feelings exactly, but just this strange

04:00 sensation because being at the booth and you've got, like you say, all these people coming

04:05 up and, you know, saying thanks for the work that you do on the project and all of these

04:12 kind of good vibes.

04:13 But then at the same time, I'm standing there at the booth and I'm looking over at all the

04:17 big, real professional companies that know what they're doing and thinking, hmm, that's

04:24 where I'd really like us to get to, you know?

04:27 Yeah.

04:27 Yeah.

04:28 That was interesting.

04:29 But what was also nice as well was having a good excuse to only talk to people at the

04:36 conference.

04:37 You know, the only time that I managed to get upstairs into the talk spaces was for

04:43 the talk that I gave and the rest of all of the talk session time, I was just talking to

04:49 different people and I really enjoyed that.

04:51 I got a lot out of that.

04:53 Yeah.

04:54 I felt the same way.

04:55 I only went to the keynotes and the open spaces.

04:58 And other than that, I really just was at the booth talking to people.

05:02 It was really, really amazing.

05:03 And, you know, thanks to everyone who stopped by my booth and I'm sure you feel the same

05:07 way.

05:07 It was quite cool.

05:08 By the end of the second day, I had basically lost my voice from talking.

05:12 Yes.

05:13 I should also say that we got a bunch of help from other volunteers who offered to step up

05:19 and give us some of their time on the booth, which was awesome as well.

05:23 Yeah, that's cool.

05:25 Thank you to them.

05:25 So, yeah, one positive experience from PyCon and people who are out there listening, be sure

05:31 to get your PyCon tickets early because, as always, it sells out.

05:35 And then I get messages like, hey, can you get me a ticket?

05:37 It's sold out.

05:38 Like, nope, no secret tickets.

05:40 All right.

05:41 So let's get into your story first before we talk about your restful things.

05:46 How do you get into programming in Python?

05:48 Oh, yeah.

05:49 Okay.

05:49 Well, let's start with how do I get into programming, I suppose.

05:53 So ZX Spectrum 128.

05:58 So when I was a little kid, I did a little bit of programming from magazines and stuff.

06:07 You know, when it was in the days when they came with a tape on the cover back then.

06:14 And my dad bought me a ZX Spectrum and I did a little bit of noodling around then.

06:20 Just silly little game stuff.

06:23 Well, not even that, really.

06:24 At that point, that was just copying stuff out of magazines or trying to figure out little

06:29 bits and pieces.

06:30 And then I kind of dropped it for a while.

06:33 And later on, when I was a teenager, I started getting into QBasic and programming games together

06:43 with a friend.

06:43 And we had like a little thing going when we did that.

06:47 And that got me into it enough to decide to do it for a university course.

06:52 And then I've had a big old windy road since then.

06:56 So I started out working in speech recognition, stayed in that field for several years.

07:02 I then moved into networking and worked with a content distribution network who did a peer-to-peer

07:11 content distribution network.

07:12 Peer-to-peer, huh?

07:13 That's pretty cool.

07:14 Yeah.

07:14 Yeah.

07:15 Well, what they started out with initially was providing BitTorrent caches to ISPs so that

07:25 ISPs wouldn't have to pay for the upstream costs to the internet and could instead just cache

07:31 the really popular streams, right?

07:34 Do you feel like BitTorrent was ruined by people using it too much for piracy?

07:42 Like BitTorrent, I think, would have been a really fantastic for all sorts of web content

07:48 delivery, video streaming, so many things.

07:52 But since it got so associated with pirating MP3s and videos, it's kind of a black mark.

07:59 I don't know.

07:59 I think if it had been the right solution technically, then it would have won out on its own merits

08:06 anyway.

08:07 And the legal side of it, I don't think was really the main influencer of that necessarily.

08:17 Oh, and really, I guess the reason why I say that is because I was there busy working at

08:22 a company which was using BitTorrent and was trying to provide a, here's how you do a CDN

08:32 using PID's PIT.

08:34 I don't know.

08:34 It's too long ago for me to give you a code here.

08:38 I'm going to just stop now.

08:41 All right.

08:41 Sounds good.

08:42 All right.

08:43 So you did that for a while.

08:44 Was that in Python or something else?

08:45 So that, see, I can't remember at what point things stepped into Python.

08:51 It was either when I was working in speech recognition and at some point all of the sorts of the build

09:02 tools that you need for doing things like building the language models, right?

09:07 The sorts of things that we were doing when I started there was writing shell scripts and

09:12 pull scripts.

09:13 And I can't quite remember whether I moved into Python then because it's been long enough

09:18 now or whether it was when I then later started doing networking.

09:23 But whenever it was, all of a sudden, it was like, oh, wow.

09:28 This is so, you know.

09:30 This is different.

09:31 Having been used to working in C and C++ and either Pearl or Bash for scripting, it was,

09:40 yes, such a breath of fresh air.

09:43 And it's quite surprising almost to be here after all this time and still be so infused by

09:53 the language and not feel like that's really changed.

09:56 Yeah, that's really an interesting point.

09:58 I've kind of marveled at that myself as well.

10:01 So, you know, even if you just look at like some of the growth curves, popularity curves

10:06 of Python and the ecosystem, it's been around for over 25 years now, but it's still growing

10:13 and growing more quickly now than it did 10 years ago or when it was brand new.

10:17 It's really interesting.

10:18 Right.

10:19 And we're just coming up to potentially a new kind of slice of stuff that it can break into

10:26 as well.

10:27 You know, now that Python's readoption has finally really started to hit that tipping

10:33 point and the asyncio primitives that are in there, all of a sudden there's this new slice

10:41 of stuff that Python could be really, really good at that it historically hasn't particularly

10:46 been.

10:47 Yeah, it's definitely an exciting time.

10:49 Yeah, for sure.

10:50 All right.

10:51 So thanks for the story.

10:52 What do you do day to day?

10:54 You said you're a professional open source developer.

10:56 How awesome is that?

10:57 Yes, that's quite a rare, a rare thing, isn't it?

11:02 Really?

11:03 I love to share these stories.

11:04 I've been, you know, been really lucky with the way things have worked out just with timing

11:13 and so on.

11:14 So, yes, I, as of about 12 months ago, I now work on open source for my living full

11:25 time.

11:25 So let's approach it this way.

11:28 So I started on Rest Framework about five years ago and all of that was as a side project

11:33 as it is with most people.

11:35 And when we came up to the point where I was thinking about all the things we'd need to do

11:40 for Rest Framework 2, I figured that I was going to need some full time on it.

11:45 And in order to do that, we launched a Kickstarter project for it.

11:49 And that was really successful.

11:51 And I managed to get...

11:54 What year was that?

11:54 Do you remember?

11:55 That must have been either 2014 or 2015.

11:58 2015.

11:59 Okay.

11:59 So pretty recently.

12:01 Yeah.

12:01 Yeah.

12:02 Not so long ago.

12:03 It probably, it was probably started in 2014 and I was probably working on it up until

12:08 2015.

12:09 How'd the Kickstarter go, by the way?

12:11 Oh, it was awesome.

12:12 Yeah.

12:12 We were, we got about 35,000 pounds, which I think was about $50,000.

12:20 The way that I organized it, I was with a very small web consultancy or very, very into supporting

12:30 open source.

12:31 The person who's the CTO of the company runs the local Python meetup group and so on.

12:37 And we figured out a way that I would be able to take a slice of time out of my working day

12:45 in exchange for us doing the Kickstarter through the company.

12:48 And I was able to work on the project for, I don't know, maybe about nine months or so as

12:54 a result of the Kickstarter, with most of my time being dedicated to it, or about 50% time.

13:00 So that was great and was much more successful than my highest estimate would have been for it.

13:07 What goal were you asking for?

13:09 I guess our starting point was probably something like 5,000 pounds.

13:13 And maybe I was hoping for 10,000 and flew way past all of that.

13:20 Cool.

13:20 Congrats.

13:21 Yeah, it was great.

13:22 Yeah.

13:23 And then more recently, when I was thinking about the next chunk of functionality that I wanted to be able to deliver, I was trying to figure out how to do it.

13:33 And launching another Kickstarter was one of the options.

13:37 But trying to find a way that we could do it that would remain sustainable rather than just being a big one-off thing.

13:46 Yeah.

13:46 Kickstarters are nice, but they're very much one-off.

13:50 Like, here's a boost.

13:51 Now what?

13:51 Yeah.

13:52 You can't just keep doing Kickstarters.

13:53 Yeah, and it has to be – you have to have a really nicely wrapped up bit of functionality.

14:00 It's difficult to kind of sell it as triage on the project or open-ended bits of work.

14:08 And there's a lot of work as well.

14:11 You can't hit go until you're completely confident that you've really nailed the pitch that you want to make, which can make it quite difficult.

14:21 Because even if you've got something you think, we really need to do a Kickstarter for this, until you feel that you're at the point that, okay, we've got it just right.

14:31 Let's do this.

14:32 You keep on wanting to hold off, hold off, and try and – anyway.

14:37 But this time around, I started thinking about launching an ongoing funding model instead.

14:46 We were really fortunate because it tied in at the same time with when Mozilla launched their MOS awards, so the Mozilla Open Source Awards, where they give awards to projects that they're using in order to help them develop further functionality.

15:07 I mean, that comes with some sort of funding, right?

15:09 It does.

15:09 It does indeed.

15:10 So we put forward an application for the project.

15:15 And when we were told that we'd been successful, and I can't remember exactly how much it was right now.

15:26 It was probably about $35,000, I think, that we'd requested.

15:31 When we found out that we'd been successful, that was the point at which I said, okay, well, I better give this a shot now.

15:38 I told my company that I was going to go and try working on open source full-time, and we launched the collaborative funding model, is what I tend to call it.

15:48 That's cool.

15:49 How long ago was that?

15:50 How long have you been doing it in this path?

15:52 So, yeah, just over a year.

15:53 We literally just passed over the year milestone now.

15:57 So, yeah.

15:59 Are you enjoying it?

16:00 Oh, it's great.

16:01 It's great.

16:02 It's great.

16:02 It's not, you know, being entirely self-driven and being in such an atypical business model, quite an amorphous set of constraints, you know, that can be odd at times.

16:17 But I try to spend most of my working time out of co-working space rather than just working from home.

16:26 So that helps give things structure, and it's been amazing how much you can push things forward when businesses actually have that relationship of trust to invest a little bit of their money in you in order to give you that space to do that.

16:50 So, yeah.

16:50 Yeah, I feel like there should be way more of this.

16:53 There are businesses, there are billion-dollar businesses whose primary product is built on layer upon layer of these super important open source things, and they contribute nothing to it.

17:04 Right.

17:05 And at best, they'll do a PR back to it.

17:08 But even, you know, maybe not even that, right?

17:11 And they would probably get a net benefit financially just by supporting the people to tweak it just a little bit to suit their needs better, you know?

17:21 Right.

17:21 So, yeah.

17:22 And the responsibility of people like myself who are fortunate enough to have managed to find themselves in this position is to prove the business model.

17:31 And so there's two sides to it.

17:33 One's the marketing angle of it, which is important.

17:39 But in a way, it's something that I'm less interested in.

17:42 The thing that I really want to demonstrate is when you take a collaborative approach to investing in infrastructure, if it's shared infrastructure, then the rewards that you get for your investment are so outsized to the rewards that you can get by solely investing only within your own company.

18:06 Because you've got all of these other companies that are also pitching in at the same time.

18:11 So the way that I tend to talk to potential sponsors is I say, hey, I want to work for your business full time for $50 a month or $100 a month or $150 a month.

18:25 And they're like, amazing.

18:26 How do we do this?

18:27 Well, I have a figure I tell them.

18:29 You know, how is that not a reasonable business proposition?

18:34 Okay, I'm not working on exactly day to day what they tell me, but I am working on trying to support their businesses.

18:41 You know, it's not eye in the sky stuff.

18:44 Yeah, I'm not coming to your meetings, but I'm going to be working on your business.

18:48 Yeah.

18:50 Yeah, I think it's a super, super straightforward story.

18:56 And I think you're right.

18:57 There's people sort of blazing that trail.

18:59 And how well it works in the future is going to depend on how well, like the first few successful ones blaze that trail.

19:09 Right?

19:09 Yeah.

19:09 Yeah.

19:10 Yeah.

19:10 We need to build stuff that makes those companies more successful.

19:14 And we also need to sing and dance about the companies that are supporting open source financially.

19:22 And do things like try to get the community into a mindset of when you're looking for your next job, look to companies that are supporting open source financially as your first port of call.

19:36 And try to drive things that way around as well.

19:39 Yeah, I feel like it's something of an awareness thing as well, right?

19:44 Like, it's a pretty straightforward sell to go to pick a random company, Fidelity Investments or whatever, and say, look, if you guys paid like 200 bucks or a thousand bucks a month to these five open source projects to keep them going.

19:58 And everyone did this.

19:59 Like, you would have a much more stable platform.

20:02 Your scalability would be better.

20:04 And you would be able to, you know, trade half a microsecond or millisecond faster or whatever, right?

20:09 That's a really simple story to tell to the business owners.

20:12 But it's, I don't know.

20:13 It's, I'm not sure how much it's happening yet.

20:16 It's step by step, right?

20:18 You know, we need to be able to have really great examples where we can point to whether it's frameworks or platforms or projects that have really succeeded because they have been financially successful and say, look, this is what can happen when you do support these projects.

20:36 This is what the people who supported it and anyone who's using it actually got out of this experience.

20:41 And now we can do it over here and we can do it here and we can do it here.

20:43 And also to do things like look retrospectively and say, how much did that cost each business?

20:49 When you go and you look at all these bits of, well, anyway.

20:52 Yeah, no, I think it's, I think it's really great.

20:54 And we should probably talk about your projects in particular as well.

20:58 Yeah, I know.

20:58 But I really, but I think that this is super interesting to people.

21:03 It's very powerful.

21:05 And for everyone who's doing it, there's probably a thousand people who wish they could.

21:09 And so, like, just the awareness of us talking about it, I think, serves a good purpose.

21:14 I think it's going to change.

21:15 I'm really optimistic.

21:16 I see things have been moving forward.

21:21 And I feel like we're on the start of a wave.

21:24 I mean, that's easy for me to say because I'm fortunate enough to actually be in that position.

21:29 But I do feel like it's starting to change.

21:33 Sure.

21:33 I definitely think it's something that 15 years ago would have been really, really unexpected.

21:39 And now it seems pretty, pretty normal.

21:42 It's just something that's got to get moving.

21:43 Yeah.

21:43 This portion of Talk Python to Me is brought to you by Linode.

21:48 Are you looking for bulletproof hosting that is fast, simple, and incredibly affordable?

21:52 Look past that bookstore and check out Linode at talkpython.fm/Linode.

21:57 That's L-I-N-O-D-E.

21:59 Plans start at just $5 a month for a dedicated server with a gig of RAM.

22:03 They have 10 data centers across the globe.

22:06 So no matter where you are, there's a data center near you.

22:08 Whether you want to run your Python web app, host a private Git server, or even a file server,

22:13 you'll get native SSDs on all the machines.

22:16 It's a 40 gigabit network, 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.

22:23 Want a dedicated server for free for the next four months?

22:26 Use the coupon code python17 at talkpython.fm/Linode.

22:32 You've got a couple of projects that are amazing.

22:34 And so let's take them, I guess, from the beginning.

22:38 So the first one, which we've mostly been talking about, is Django REST framework.

22:43 All right.

22:44 This is the thing you started back in 2010 or so?

22:47 Yes.

22:47 Yeah.

22:48 All right.

22:48 So, you know, everyone knows what Django is.

22:51 They probably know what REST is.

22:53 What's Django REST framework?

22:55 What is this project?

22:57 Django REST framework is, unsurprisingly, an API framework for Django.

23:02 And it tries to fill in all of the gaps of where Django was historically designed as a web framework.

23:13 What are all the extra bits?

23:16 Right.

23:16 Here's HTML.

23:17 Go into browsers.

23:19 You wanted to make a talk to machines, not people, right?

23:21 What are all the various bits and pieces that you would want to provide additionally if you wanted to use Django primarily as an API framework?

23:31 So, for instance, approaching authentication differently, providing things like throttling and permissioning in a way that it's really easy to use them in different slices of your API in different ways, handling things like HTTP content negotiation,

23:54 and all sorts of bits and pieces, providing generic classes of views that give you default functionality for the CRUD case.

24:05 So, if you've got an API where you want to provide a set of different URLs and methods on those URLs that are useful, creating records, retrieving records, updating and deleting records, giving you all of those sorts of bits of tools at the bottom.

24:20 So, maybe you have like slash API slash users, and then you can do a get to get all the users, a get slash ID to get a particular user, a post to create a user, things like that?

24:30 Yes.

24:31 And also dealing with the, if you've got some data that you want to present to the user, or rather if you've got some objects that you want to present to the user, what do you want the representation of those objects to look like?

24:46 If we're dealing with relationships between the objects, are you presenting those as the plain primary keys, or should they be presented as hyperlinks?

24:56 All of those sorts of that.

24:58 Do you want to return big nested sets of data where you've got all sorts of interlinked objects all being returned in bulk, or do you want flat data structures?

25:10 All of those sorts of things.

25:12 Okay, cool.

25:12 So, if I'm working with Django ORM, or even SQLAlchemy, or MongoDB, something like this, and I'm getting sort of ORM objects back, does it handle like the serialization of those types of things?

25:25 So, being Django-based, it works primarily with the Django ORM.

25:30 There's stuff that you could do to integrate it with other backends as well.

25:35 The question is, suppose in my web method, I do a query and I get a list of users back from Django ORM.

25:44 Can I just return that list and have it magically JSONify it, or XMLify it, or whatever?

25:50 Yes and no.

25:51 So, yes, you can.

25:53 No, you probably don't want to do that.

25:54 I shouldn't.

25:55 You can, but don't do it.

25:58 So, you can ask it to give you the default representation and just say, return all of the fields on this model.

26:07 So, give it a model serializer, tell it which model it's pointed at, and say, and I just want all of the fields on that.

26:15 And that will give you a default representation that, depending on which class you use, just uses either primary keys or hyperlinks for relationships that that model happens to have.

26:27 What you would want to do more typically is be a little bit more precise about the representation.

26:34 So, declare the fields that you want returned explicitly and independently of the model itself.

26:42 So, list them all out.

26:43 So, yeah.

26:44 Yeah.

26:45 And going the other way, maybe it's even more important.

26:47 Like, if I post a JSON body to a method, is there serialization on that side?

26:52 Or do I, like, read it?

26:54 There's two different aspects to this.

26:55 So, there's the taking the ORM object and turning that into plain Python data types that are ready to be serialized, that are ready to be rendered.

27:10 That we call the serialization, going between the plain Python data types and ORM objects.

27:17 Then there's the parsing or rendering, which is, on the parsing side, taking request data that's coming in and turning that into Python data types.

27:28 So, JSON.load.

27:31 And on the other side, the rendering, which is taking the data types and turning those into the response body.

27:38 So, JSON.done typically.

27:40 Yeah.

27:40 So, it looks like you have a lot of control over all those different things.

27:43 Yes.

27:43 So, you can, for instance, you control the serialization style, which is what information do you want in the representation.

27:51 But separately to that, you can also control the renderings of that.

27:56 So, you could, for instance, have both a JSON and a YAML output for the same data.

28:04 Sure.

28:05 Did I notice somewhere in your docs that you can basically use, like, a fake or false extension to control that?

28:14 So, like, a slash user slash one dot JSON versus slash user slash one dot XML and things like that?

28:21 Yeah.

28:21 So, there's different ways that you can control which rendering you get.

28:27 By default, REST Framework will use content negotiation, where the client sets an accept header in the request, which informs the server which response type it would like,

28:45 which content type it would like in the response, or you can have URLs that specifically are for one particular type of rendering using suffix.

28:58 So, yes, dot JSON or dot YAML.

29:00 Yeah, yeah.

29:01 So, the most popular API that I know that does that is the Basecamp API.

29:05 Right.

29:06 They do, like, thing dot JSON, even though it's entirely not needed.

29:10 That's just, like, their style, right?

29:11 Some people like that.

29:12 Some people don't.

29:13 Yeah.

29:13 But the thing that's actually drove all of that side of the rendering in the first place anyway was the browsable API.

29:22 So, when you go to a URL in REST Framework, if you make that request with curl or a command line client, you will typically get back,

29:33 depending on exactly what you configure, but you'll typically get back plain JSON.

29:37 When you go to it in the browser and the browser sends an accept header that says, I would prefer HTML, then we're able to return an HTML rendering of the view with the data in line on the page,

29:53 but also a whole bunch of extra information around the outside and controls to allow the user to interact with that API endpoint.

30:01 That's awesome.

30:02 So, it's like self-documenting APIs out of the box?

30:06 Yes, exactly.

30:07 That's really cool.

30:08 Yeah, that's one of the things that I think often gets forgotten on APIs or gets out of date, right?

30:13 Like, either there's basically almost no API, like here's an example and it's incomplete or whatever, or here's the documentation, but our API has evolved and it's no longer.

30:24 Yeah.

30:25 Well, I'm still surprised that there aren't more frameworks that are starting to provide this.

30:32 I mean, the browsable API stuff, that was the entire reason that REST Framework came into existence in the first place,

30:41 because I was thinking about what, you know, why are APIs not, why can't we interact with them using the web browser?

30:50 This is a bit weird.

30:51 Yeah.

30:51 And that was the entire driver for, okay, well, how would you do that?

30:56 Oh, you'd do it like this.

30:58 Oh, wait a minute.

30:59 This is a framework.

31:01 Oh, if I think this is a good idea, then I'd better make it a good framework.

31:05 My prototype is almost the thing.

31:08 You know, that's awesome.

31:08 Yeah.

31:09 Yeah.

31:10 I feel like that's always been a weak point, or traditionally it's been a weak point of HTTP frameworks or APIs is that they're really easy to interact with,

31:19 but it's hard to see the documentation unless somebody's taking the time to do that separate.

31:24 Yeah.

31:24 So can you give us just like a quick sense, not too much in code, but just like the conceptual steps of like,

31:33 how would I create a project and like set it up and add an API method using Django REST framework?

31:40 It slightly depends on whether you are building a project that is primarily a CRUD style API or not,

31:50 because REST framework gives you an awful lot of tools for building those sorts of APIs with a minimal amount of code if you are,

31:58 and that's the most common use case, really.

32:01 Do you point that out like your ORM objects and say, here's an ORM object, give it the various operations?

32:07 The way around that I would approach a new project with REST framework, I would start by taking REST framework entirely out of the picture and not think about what tool is this API being built with anyway,

32:22 and instead think about the basic, the fundamentals of the API.

32:27 So which endpoints do I want to expose?

32:29 What do I want the representations of those endpoints to look like?

32:33 How do I want relationships between different objects to look?

32:39 And try to get that side of design figured out in my head first independently.

32:46 Then you've also got the data models as well and thinking about the storage side of things,

32:53 which is very closely tied to the representation, but isn't necessarily the same thing exactly.

32:58 So once you've got the start of those things in your head, then it's a case of blocking out the Django models,

33:08 blocking out corresponding serializers for those models.

33:17 So REST framework gives you a lot of different levels of tooling that you can work at.

33:22 If you want, you can work at a very high level of abstraction where we provide things called view sets

33:29 that bundle up a whole lot of different interactions into a single class

33:36 and provide, mostly automatically provide the routing of URLs onto all of those points of interaction.

33:47 Now I tend to not work at that level of extraction.

33:51 I would usually go down and work at the level of per URL, write either a function-based or a class-based view for that URL,

34:08 and write out the methods on each of those individually.

34:12 And again, there's still another different couple of layers of abstraction that you can be working at there,

34:19 because you can either be using the built-in functionality of give me the automatic create an object function,

34:29 or you can go and write that code yourself.

34:32 When I'm building an API with REST framework, I tend to prefer the explicit approach.

34:38 So if it happens that a listing view or an update view or a delete view is exactly already provided by the framework in the right way,

34:49 then I'll use that.

34:50 But if it's not, rather than trying to override it at particular hook points within those class-based views,

35:00 I'll just override the get or the post or the put or the delete method entirely and write it out explicitly,

35:06 because that really keeps everything surfaced up to the top.

35:11 I find makes it quite a maintainable approach to building the API.

35:16 That's cool.

35:17 I really like that you approach it from the outside.

35:21 Like, how should this look to the people consuming this API?

35:24 Forget the implementation.

35:25 And then let's make that happen with Django REST framework, right?

35:28 Because really, in the end, that's what's going to determine whether people are happy with the API you've delivered them, right?

35:36 Yes.

35:37 Yeah, absolutely.

35:38 Yeah.

35:38 It's not like, well, you do it this way because it was easier.

35:40 It was automatic in Django REST framework.

35:42 But it should have been this other way, right?

35:44 I mean, it started off maybe when the API frameworks and the landscape were younger.

35:53 Maybe it was a bit different then because there's also the aspect of it's useful if the frameworks guide you towards what set of design choices should you be making there.

36:05 Yeah.

36:06 Yeah, but, you know, in 2017, we have more experience building APIs and more examples of good APIs than long ago.

36:14 Yeah.

36:14 Nice.

36:15 So you want to tell us about some of the popular deployments?

36:19 Like, who's using it?

36:20 Do you know how they are?

36:21 Gosh, yeah.

36:22 I should probably open up things like the sponsor list to remind myself there.

36:26 So let's think.

36:27 No, I'm not going to do that.

36:29 I'm just going to.

36:29 So Mozilla are obviously a really big name.

36:34 We're a big sponsor of the Kickstarter.

36:37 I can't remember how much they're using it at the moment, but I think that they are.

36:41 I know that Red Hat are using it at least within a couple of places.

36:48 Heroku use it for something or other.

36:53 And, well, we've got about 60 corporate sponsors.

36:58 So stacks and stacks of different consultancies and product businesses of all types, really.

37:07 It's always interesting when you get a new sign up, finding out what the business is, because there's so many different surprising angles that it's being used from.

37:19 Yeah, can you think of one you're like, whoa, you're doing what with my framework?

37:22 Not off the top of my head, but that's probably like post-PyCon haze, because, you know, they all went in and then, yes, it all walked over me.

37:39 Yeah, excellent.

37:40 All right.

37:41 So it sounds like a really successful project.

37:43 And this is the one that basically let you, through the Kickstarter and the collaborative funding and these things, lets you become a professional open source developer.

37:52 Basically create a business around your framework.

37:55 And congratulations to you on that.

37:57 That is super, super cool.

37:59 I think it's so neat.

38:00 I'm happy to be able to, like, shine a light on it.

38:02 Thanks.

38:02 Yeah, it is.

38:03 It's wonderful.

38:04 Yeah.

38:04 So there's another thing that I came across that you just started working on as well that's very exciting.

38:11 And I don't know how it ties into the funding stuff, but I certainly think it's cool, is called API Star.

38:17 Tell people what API Star is.

38:19 This is a new API framework that I started working on.

38:24 Rest framework is still my main gig, I guess.

38:29 But there are a couple of different things that I think are important to explore at the moment.

38:37 And API Star is my start towards doing some of that.

38:40 It's an API framework that's not tied in to Django or the Django ORM and has a different approach to the fundamental interface that you use for building your code base.

38:57 So rather than having views, which are functions that take a request and return a response, instead you have views where you declare on the view function using type annotations,

39:16 the sorts of data and the sorts of components that that function is going to take.

39:21 And you also declare what type of data it's going to return as well.

39:28 And once you take that different approach, there's a lot of interesting things that you can start to do on top of that.

39:36 So to start with, because you've got a plain data interface rather than take a request and return a response,

39:44 you can layer on different types of network interface or different ways of interacting with that function on top of it.

39:53 So for example, as well as accepting HTTP requests, you could route a command line command onto your view.

40:03 Or you can potentially look at being able to build views that accept either HTTP requests or WebSocket connections and that provide a real-time subscription endpoint.

40:15 There are ways that you can start to think about doing that or even start to think about can we build views that we can share functionality being exposed both to GraphQL endpoints and regular HTTP calls.

40:31 Now, not all of those things are done, but I'm starting to think about how would we be able to do those.

40:38 So what we're going to do is do is do a type system that corresponds to the same capabilities as JSON schema.

40:51 So we have a type system that you can use to declare what your data structures look like, both for the inputs and for the outputs of these functions.

41:04 And once you've got that, you've suddenly got something really powerful where you're able to, for instance, build API documentation based on those type annotations that is guaranteed to always be in sync with your code base.

41:22 Not only can you build this API documentation, you can also build interactive API documentation because you've got enough information in those types

41:31 that you can build HTML form controls that you can build HTML form controls with appropriate controls given the shape of the data input.

41:40 You have this property all of a sudden that you have a really nice one-to-one mapping between your function declarations and an API schema language such as Swagger or Rammel.

41:53 So you can have a really clear way of generating Swagger or Rammel from your type declarations.

42:01 If you wanted, you could even go the other way and say, okay, I've got my Swagger blueprint.

42:06 Build me the stubbed out set of functions that I'm going to want for my project.

42:13 You've also, you've even got enough information that once you write out these declarations, even before you've implemented anything,

42:22 you could start running or you will be able to start running a mock API.

42:28 So you've got all the response types.

42:31 You know what the inputs look like and whether they're valid or they're not valid.

42:37 So that what you can do is have your team build up all the function declarations and present to your front-end team a mock API

42:49 that's already ready to start them build the front-end against, while your back-end team starts to fill in all the blanks of, oh, well, we better actually implement the behavior here.

43:05 Yeah.

43:06 So there's also some interesting things you can do.

43:08 Oh, and also, what else?

43:10 Dynamic client libraries that are able to interact with your functions.

43:16 They have enough information being exposed in the schemas that you're able to generate that you can present an interface on the client side

43:26 that corresponds to the same thing you have on the server side.

43:28 So all sorts of cool stuff once you've got this.

43:31 Yeah, that's actually been one of the weak points of HTTP APIs over, say, SOAP services, right?

43:38 SoAP services are dreadful.

43:39 But one of the things that they were good at is they had this WSDL thing that you could then generate basically clients that know all the methods,

43:47 all the types that are exchanged there.

43:49 I'm thinking of SUDs in Python or obviously like Java or .NET and their tooling.

43:54 But here you're kind of describing enough information.

43:57 This is the stuff that goes in.

43:59 This is the stuff that goes out that you could actually bring that back in a sense.

44:02 Yes.

44:03 What this is it's a way of – it's still a restful approach.

44:09 It's just a way of providing a better description to what the interface is.

44:14 And that also has an impact on what sort of APIs you build, actually, because given that we haven't had great client-side tooling or great ways of describing what those interfaces are,

44:27 the let's always build CRUD style interfaces is something that's kind of naturally happened

44:33 because it's been a bit of a constraint of we can't express very well different things that don't fit into that.

44:41 But having a really expressive way of being able to declare what those interfaces are lets you take a more,

44:49 okay, these are just different types of actions or different types of views onto the data.

44:55 They don't necessarily have to correspond to CRUD.

44:57 Yeah.

44:57 Yeah.

44:58 This portion of Talk Python to Me has been brought to you by Rollbar.

45:02 One of the frustrating things about being a developer is dealing with errors.

45:06 Relying on users to report errors, digging through log files, trying to debug issues,

45:11 or getting millions of alerts just flooding your inbox and ruining your day.

45:15 With Rollbar's full-stack error monitoring, you get the context, insight, and control you need to find and fix bugs faster.

45:22 Adding Rollbar to your Python app is as easy as pip install Rollbar.

45:26 You can start tracking production errors and deployments in eight minutes or less.

45:30 Are you considering self-hosting tools for security or compliance reasons?

45:34 Then you should really check out Rollbar's compliant SaaS option.

45:38 Get advanced security features and meet compliance without the hassle of self-hosting,

45:43 including HIPAA, ISO 27001, Privacy Shield, and more.

45:47 They'd love to give you a demo.

45:49 Give Rollbar a try today.

45:50 Go to talkpython.fm/Rollbar and check them out.

45:55 One of the things that struck me the most about looking at this API, is it Python 3 only?

46:00 It is, yes.

46:01 So because of the type annotation.

46:03 Right.

46:04 Yeah.

46:04 So the type annotations are the things that struck me the most when I look at it.

46:08 So you might have an API method and the method, say, if you want to have access to the request object,

46:16 you would say request colon then HTTP.request.

46:19 And you basically annotate like this variable is this type.

46:22 And your framework will go, oh, I have one of those types.

46:24 I'm going to inject it here.

46:26 There's all these different types of things that can be injected, right?

46:29 Yes.

46:30 So the different kinds of component that you can inject, they can either be, say, something

46:37 that's based on the incoming request, like you say request, or you could say, you could

46:43 have query params.

46:45 So the class query params, if you put that on, you'll get the dictionary of all the query

46:49 parameters.

46:49 But you can also do interesting things like there's a class, the singular query param.

46:55 And if you put on the name that you use for that variable and the class query param together,

47:02 it will say, okay, I'll give you this query parameter.

47:07 That is so awesome because I feel like all the time, I'm just, I'm not really excited to

47:12 see this thing come into existence.

47:13 So all the time, if you're taking a traditional HTML based framework, Django, Pyramid, Flask,

47:20 whatever, they're like, okay, here's the post dictionary.

47:24 Or here's the data that was submitted.

47:26 Or here's the query string.

47:27 And you can go dig into that dictionary and find the thing you want.

47:30 Here are the headers.

47:30 Dig into the headers and find the thing you want.

47:32 But on yours, you could actually say things like user underscore agent colon HTTP header.

47:37 And it will go into the headers, find the user agent, pull it out and set that value.

47:42 So you just, it's as if all the elements of the request become just function parameters,

47:48 which is glorious.

47:49 Yeah.

47:50 So it's really expressive.

47:51 It reads really nicely when you look at it.

47:54 Right.

47:54 It also means that it's really testable because the interface that you're exposing is exactly

48:00 the thing you want to be exposing.

48:01 You don't have to do things like build up a mock request object in order to test your functionality.

48:07 Right.

48:08 Because if you say it takes a query string and it's, the thing is called name, you just

48:14 pass in the value you want for name in your test and you're done.

48:16 Right.

48:16 You don't have to fake up a dictionary that holds things.

48:19 Right.

48:19 Yeah.

48:20 Yeah.

48:20 And the other thing that's interesting as well is because the way it works is when you

48:27 route all of your views with the application, at the point they get rooted, it inspects what

48:32 the function signature is, figures out, has to look at what all the different components

48:36 are and figures out exactly what's going to need to be run every time it needs to run that

48:42 view, which ends up meaning that it's really, really fast because you only pull in exactly

48:48 the things that you need to pull in.

48:49 So for instance, if you've got a database component, only views which declare that they're using

48:57 the database component will end up getting wrapped in a transaction and anything that doesn't,

49:03 that never gets seen at all.

49:05 That's fantastic.

49:06 Yeah.

49:06 The other thing that I really like about the type annotations is automatic type conversion.

49:10 So you could have like a user underscore ID colon int, and obviously everything comes into

49:16 the web as a string, but do you like parse that into an int?

49:19 Yes.

49:20 Yes.

49:20 That gets handled for you and the type validation on that.

49:25 So you can either use the native types for that, or you can use the type system for that,

49:31 which gives you the more expressive, everything that Jason Schema gives you stuff.

49:36 You know, here's a complex object.

49:39 Here's what it looks like.

49:40 Yeah.

49:40 Wow.

49:40 That's awesome.

49:41 All right.

49:42 Another thing that I found to be interesting was the performance story.

49:45 So like you already touched on it, this is a super lightweight framework, and I didn't

49:50 even realize the extent to which you were ensuring that it only does what it needs to do.

49:55 That's really cool.

49:57 So you ran some various tests with like G Unicorn and Mindheld, or even with like some

50:04 of the shiny new things like Sanic and UV loop, right?

50:09 And so the stuff that you had on the website, let's see, it says Flask.

50:12 You talk about scalability and just raw individual request performance.

50:16 Like, so Flask on your setup, you're getting 5,238 requests per second and about 40 millisecond

50:24 latency.

50:26 On Sanic, which is really an interesting framework as well, you're getting like 21,000 requests

50:32 per second and 10 milliseconds.

50:34 And with API stars, 25,008.

50:37 So you're like five times faster than Flask on both raw individual requests and overall, right?

50:45 That's awesome.

50:45 Yeah.

50:46 Well, keep in mind that that's a test type that is not really real world usage.

50:53 There's some really big provisos to make there.

50:56 We'll talk about that stuff in a bit more detail later, but I interrupted you.

50:59 Well, I was going to say, you have to be really super careful about these sorts of performance

51:05 comparisons because the way I'm using it and the way someone else using it could be super

51:10 different.

51:10 The way I've set up my machine could be really different, but you were running the tech and

51:13 power benchmark, which is a particular one, which is pretty well respected.

51:16 So at least in that sense, you're running the simple JSON serialization version.

51:22 Does that mean like if you use API star, your API is five times fast?

51:26 No, because you're still probably doing your same implementation stuff, right?

51:29 But it means how much overhead are you bringing in with the framework like that?

51:34 You could maybe consider, right?

51:35 Yes.

51:35 So that's what I was trying to demonstrate when I've included that section in the documentation

51:41 is not so much this is going to make things fast for you all the time, but the aspect of the

51:52 framework can get out of your way if you need it to.

51:55 Yes.

51:56 So being able to declare the response type on the view, you can actually have it just

52:03 return a WSGI response directly.

52:06 You end up with the server calling into your framework and a single function call gets made

52:13 and that gets returned directly back to the server.

52:16 So that's an interesting aspect of it.

52:18 Now, that doesn't mean for the different test types where different things like

52:23 asynchronicity come into play that it would perform in the same sort of way, wouldn't it?

52:28 Yeah, of course.

52:29 But I think it's still really important to highlight that aspect of once you take this

52:35 dynamic approach, you can work at whatever level is appropriate for the thing that you're

52:41 building.

52:41 Yeah, very cool.

52:42 Okay.

52:42 So I'm sure I've got you a bunch of email from pointing that out.

52:46 Oh, no.

52:49 Let me tell you how you could have optimized this in this setting.

52:51 Anyway, speaking of performance and asynchrony, there's another project called UVicorn.

52:57 Yeah, UVicorn.

52:58 Tell us what this is.

53:03 It's like the future version of G-Unicorn, right?

53:07 So in Python asynch.io land at the moment, there's a few frameworks that are existing.

53:17 Sanic being one, AIO HTTP being another.

53:23 Yep, Jepronto.

53:25 That's right.

53:26 A muffin.

53:27 Yeah.

53:28 They're very exciting.

53:29 Kaiowaki.

53:30 Is that right?

53:31 Kaiowaki.

53:32 Yeah.

53:32 So that's, and which is really cool.

53:34 And in particular, Sanic's been interesting because it's shown just how impressive these

53:43 two particular components that it uses are, which is UV loop, which is an event loop that is implemented

53:53 as a Python binding around either the same event loop that Node uses or something that was

53:59 originally built for Node.

54:01 And also an HTTP parsing library that is also a Python implementation, you know, a set of

54:09 Python wrappers around a super fast C implementation that, again, I think was built originally for Node.

54:15 And the performance of those two components is really impressive.

54:20 The only problem that we have in the Python landscape at the moment is that all of these

54:26 AsyncIO frameworks that we have are really still at the framework level.

54:31 There isn't this separation of, well, here's the server, here's the framework, and here's what the interface between those two is.

54:41 We've had that for a long time in our regular old happy synchronous land because we've had WSGI for ages.

54:49 And now you can't repurpose that for AsyncLand because you just can't.

54:56 And the thing that I would like to do is combine the fact that there happens to be an incredibly awesome implementation

55:06 that is super fast and the how do we figure out what the interface between the server and the framework ought to look like

55:16 and bridge that gap and have, okay, here's just the bare bones.

55:22 You know, you've got a single callable and it gets this set of data.

55:26 Now go and build your AsyncIO framework on top of that.

55:30 Okay?

55:31 Yeah, yeah, yeah.

55:32 That's really been the pinch point where we haven't been able to unlock the Async stuff on the server easily with existing frameworks.

55:41 Yes.

55:41 And I think once we've got that, that's really going to kind of set everybody free to start doing interesting things.

55:47 Where it's difficult is trying to figure out how it sits into the existing landscape.

55:52 So, for instance, one of the things that I would like Uvacorn to be able to do is to also be able to interface with Django projects using channels

56:02 and be able to provide WebSocket support.

56:06 But in a different deployment mode to channels has.

56:10 So deployment mode there at the moment is you have your servers and those sit in front of a channel layer,

56:18 which all the data gets passed over, probably Redis or something like that.

56:22 And then you have your workers running behind that and you have those three different components.

56:26 I would like to also be able to provide a different deployment style where you just have a single server process,

56:35 well, set of server processes that are running that interface with the application framework directly.

56:42 Yeah, that's awesome.

56:43 Instead of having one more hop and two sets of worker processes and separate implementations, all that stuff.

56:50 And there's different considerations to both different deployment styles.

56:54 And there's some reasons that tiered approach that channels takes can be preferable as well.

56:59 But I think it would be if you can do this, build a server framework that would be great for AsyncIO frameworks to be built against,

57:11 that is also able to power an existing really, really widely deployed synchronous framework as well and add WebSocket supports.

57:22 I mean, you know, Andrew Goswin's done all of the heavy lifting here.

57:25 I'm just gluing various bits and pieces together.

57:27 This wire goes to this wire, yeah.

57:30 Okay, I think there's like low-hanging fruit here.

57:33 If we take this good work from over here and that good work from over there, yeah, live wire them together.

57:38 Yeah, so that's where that is at the moment.

57:44 That's super exciting.

57:45 Yeah, and ultimately, you know, that is also a different slice of the puzzle for API star because I would like API star to primarily end up being an AsyncIO framework.

57:58 And in order to do that, I want to get a proper separation between the server and the framework for that.

58:05 Yeah, ideally, just make those methods all Async methods and just await on the things in the middle and let the server do all the magic, yeah.

58:15 Sounds easy.

58:15 Yeah, perfect.

58:16 What is that, next week?

58:18 We'll see.

58:20 So let me ask you a question.

58:21 So if I want to take API star and run it on UVicorn in production and send all my traffic and stuff there, is it ready?

58:30 It would be very enthusiastic.

58:32 How's the readiness of API star?

58:36 How's the readiness of this UVicorn?

58:37 So I know that API star is already being used in production by at least a couple of folks.

58:42 You certainly would have to not mind the fact that there will be breaking changes to the API that we provide.

58:49 So pin your dependencies in requirements.txt?

58:52 Yeah, that's one thing.

58:54 And, you know, be prepared to move forward as the framework moves forward.

58:58 The flip side of that is that I think, you know, once it's the reason that it's still slightly in flux is because of the Async side of the puzzle.

59:09 And get crossing that bridge.

59:11 Once that bridge is being crossed, then I think that's when it all starts to tie together really nicely.

59:18 The point at which I'd say, yeah, go and do interesting business things in it will be the point at which you see a proper set of docs available for API star.

59:28 At the moment, it's fairly comprehensively documented, but it's still all on the readme at the moment.

59:32 My big signal to everybody of, yeah, go primetime will be once I've finally got the docs live.

59:40 Because I'll only launch them when I'm really, really happy with how everything's looking.

59:44 Sure.

59:44 Sounds great.

59:44 And UVicorn?

59:46 Well, it's a different slice of stuff that you would use it for.

59:49 So at least at its current level, because it's so much lower level, give it a try.

59:54 Don't do anything with it in production now, for sure.

59:59 At the moment, that's an experimental stage.

01:00:02 But again, I think that's going to, there's not actually that much work that needs to be done on it.

01:00:09 So I think that that's going to become, and actually that will kind of land before API star is completely, completely like primetime ready because it's a smaller chunk of work.

01:00:22 Sure.

01:00:23 Sounds good.

01:00:23 So often people will write to me and say, hey, I'm really looking forward to get into open source.

01:00:29 What project would be good?

01:00:31 Are you looking for contributors for any of these projects?

01:00:33 Yeah, sure.

01:00:34 Best framework's quite hard to get involved with unless you have quite a unique quality, which is the quality of being happy to go in, watch the issues list, and as something comes in, just try and figure out if it makes sense.

01:00:54 Comment on the issue.

01:00:55 Does this make sense or not?

01:00:56 And figure out if you can reproduce it, if it looks like a bug.

01:01:00 And all of those sorts of bits of day-to-day triage work, and they're not terribly shiny or, you know, wildly exciting.

01:01:12 It's amazing when people do pick it up, and it's amazing when you see folks who do have the quality of being good at that because it's quite rare.

01:01:21 But that's more difficult typically for people to get into.

01:01:26 There's loads and loads of interesting feature work or surrounding stuff that can be done on both API Star and Yuvikon at the moment.

01:01:36 There's a discussion group for API Star, so shout out on there if you're interested in it,

01:01:44 and if there's anything in particular that you think you might be interested in working on.

01:01:48 And with Yuvikon, just raise an issue against the repo, and I'll chat about it there.

01:01:55 All right.

01:01:55 Yeah.

01:01:55 Sounds good.

01:01:56 Sounds good.

01:01:57 Well, Tom, I feel like we've covered a lot of ground in this episode.

01:02:01 It seems like it, yeah.

01:02:04 Yeah, yeah.

01:02:05 We could have almost done three shows out of this.

01:02:07 Maybe we'll come back someday and do that.

01:02:09 So maybe we'll leave it there for those topics, but let's get to the questions.

01:02:13 So if you're going to work on any of these projects, what editor do you open up?

01:02:17 Atom.

01:02:19 Always Atom.

01:02:20 I had a brain fail there.

01:02:22 I was like, wait a minute.

01:02:23 What is it even called?

01:02:26 Oh, yeah.

01:02:26 The title says Atom.

01:02:28 Awesome.

01:02:28 Cool, cool.

01:02:30 And we have over 100,000 packages on PyPI these days.

01:02:37 What's one that maybe you ran across recently that was awesome, but not everyone knows?

01:02:41 White Noise.

01:02:42 White Noise is a piece of whiskey middleware that serves static files for you.

01:02:54 That's all it does.

01:02:55 It serves static files for you.

01:02:57 And it does it so.

01:02:58 What is great about it is it's fast enough that you can just put in this bit of pure Python code

01:03:05 that handles being able to have your static files served from the same platform that the rest of your application is being served from.

01:03:14 You don't have to set up S3 and direct some of the stuff over there and make sure that you're uploading your images to S3 at the right time.

01:03:23 And it handles all of the right bits of getting the HTTP caching for that right.

01:03:32 So if you want to be really sad that you can deploy it behind a CDN and your application won't get any significant traffic hits

01:03:43 because as soon as the CDN got each asset, it'll just end up getting served from the CDN.

01:03:48 And what I love about White Noise is it's so perfectly scoped.

01:03:52 It's one of those projects where it's like, okay, yeah, you've got this right.

01:03:57 That's awesome.

01:03:58 That sounds really, really fun.

01:03:59 So thanks for that.

01:04:00 I hadn't heard of White Noise.

01:04:01 And I like the name too.

01:04:02 There you go.

01:04:03 Yeah, static files.

01:04:04 So it took me a while to get it.

01:04:06 Static files, right?

01:04:08 Yeah, yeah.

01:04:09 That's awesome.

01:04:10 Okay.

01:04:11 So final call to action.

01:04:13 People want to check out your projects.

01:04:15 They want to get involved.

01:04:15 What do they do?

01:04:16 Just jump in really.

01:04:17 So API start, that's jumping on the discussion group.

01:04:22 Even if it's just saying I'm interested, this is why I'm interested.

01:04:25 And that's a great thing to do.

01:04:27 Was that what your talk at PyCon was about?

01:04:29 It was.

01:04:29 Yes, it was.

01:04:30 Yeah.

01:04:30 Okay.

01:04:31 So you can check that out at youtube.com slash, what is it?

01:04:33 PyCon 2017 and then search for you.

01:04:36 Yeah.

01:04:37 Yeah.

01:04:37 With REST Framework, the thing that is a really good place to get into is going on to the discussion

01:04:44 group.

01:04:45 And if anybody's having problems trying to help there or getting stuck in on Stack Overflow,

01:04:51 those are all great things to do.

01:04:53 Or just say hi on Twitter or come and have a chat on IRC.

01:04:57 Anything like that is always welcome.

01:04:59 All right.

01:04:59 Beautiful.

01:05:00 Well, Tom, this has been a lot of fun to talk about all these API ideas and also the funding

01:05:05 stuff was really interesting.

01:05:06 Thanks for being on the show.

01:05:07 Great.

01:05:07 Thank you so much, Mike.

01:05:09 Have a great day.

01:05:10 You bet.

01:05:10 Yeah, you too.

01:05:11 Bye.

01:05:12 This has been another episode of Talk Python to Me.

01:05:15 Today's guest was Tom Christie.

01:05:17 And this episode was brought to you by Linode and Rollbar.

01:05:21 Linode is bulletproof hosting for whatever you're building with Python.

01:05:25 Get your four months free at talkpython.fm/Linode.

01:05:29 Just use the code Python17.

01:05:32 Rollbar takes the pain out of errors.

01:05:35 They give you the context and insight you need to quickly locate and fix errors that

01:05:40 might have gone unnoticed until your users complain, of course.

01:05:43 As Talk Python to Me listeners, track a ridiculous number of errors for free at rollbar.com slash

01:05:49 talkpythontome.

01:05:50 Are you or a colleague trying to learn Python?

01:05:53 Have you tried books and videos that just left you bored by covering topics point by point?

01:05:57 Well, check out my online course, Python Jumpstart by Building 10 Apps at talkpython.fm slash

01:06:03 course to experience a more engaging way to learn Python.

01:06:06 And if you're looking for something a little more advanced, try my Write Pythonic Code course

01:06:11 at talkpython.fm/pythonic.

01:06:13 Be sure to subscribe to the show.

01:06:16 Open your favorite podcatcher and search for Python.

01:06:18 We should be right at the top.

01:06:19 You can also find the iTunes feed at /itunes, Google Play feed at /play, and

01:06:25 direct RSS feed at /rss on talkpython.fm.

01:06:29 Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.

01:06:34 Corey just recently started selling his tracks on iTunes, so I recommend you check it out at

01:06:38 talkpython.fm/music.

01:06:40 You can browse his tracks he has for sale on iTunes and listen to the full-length version

01:06:45 of the theme song.

01:06:47 This is your host, Michael Kennedy.

01:06:49 Thanks so much for listening.

01:06:50 I really appreciate it.

01:06:51 Smix, let's get out of here.

01:06:53 Smix, let's get out of here.

01:06:53 Outro Music.

01:07:14 you Bye.

01:07:15 you you

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon