Latest / Talk Python To Me / #125: Django REST framework and a new API star is born
Transcript
- 0:00APIs were once the new and enabling thing in technology.
- 0:02Today, they're table stakes, and getting them right is important.
- 0:06Today, we'll talk about one of the most popular and mature frameworks in Django REST framework.
- 0:11You'll meet the creator, Tom Christie, and talk about the framework, API design,
- 0:15and even his successful take on funding open source projects.
- 0:19But Tom is not done here.
- 0:20He's also creating the next-generation API framework
- 0:23that fully embraces Python 3's features called API Star.
- 0:27It's all about frameworks on Talk Python To Me.
- 0:30Episode 125, recorded June 8, 2017.
- 0:57Welcome to Talk Python To Me, a weekly podcast on Python,
- 1:01the language, the libraries, the ecosystem, and the personalities.
- 1:04This is your host, Michael Kennedy.
- 1:06Follow me on Twitter, where I'm @mkennedy.
- 1:08Keep up with the show and listen to past episodes at talkpython.fm,
- 1:12and follow the show on Twitter via at Talk Python.
- 1:15This episode is brought to you by Linode and Rollbar.
- 1:19That's right.
- 1:20Welcome to Linode, who has joined Talk Python To Me as a major sponsor.
- 1:25Be sure to check out what both of them are offering during their segments.
- 1:28It really helps support the show.
- 1:29Tom, welcome to Talk Python.
- 1:32Hi.
- 1:32Hey, it's great to see you again, and great to have you on the show finally.
- 1:36I've been admiring Django REST framework for a long time,
- 1:38and really a fan of your new work that we're going to get into.
- 1:42So I'm happy to have you here to talk about it.
- 1:44Cheers, Mike.
- 1:44Good to see you again.
- 1:45Yeah, yeah.
- 1:45How are you doing, anyway?
- 1:46I'm doing super well, super well.
- 1:48So I want to hear how you got into programming and Python and all that, but how was PyCon?
- 1:53We were both there the last time I saw you.
- 1:55Even though right now we're like 6,000 miles apart, we were in the same room just a little
- 2:01while ago.
- 2:01How did you enjoy it?
- 2:02It was hectic.
- 2:05You had a booth, right?
- 2:08Yeah, we had a booth.
- 2:10So I haven't done PyCon before, mostly because with it being over in the States, in the past
- 2:17it's been hard for me to justify taking the time and the cost of the transatlantic flight
- 2:23and so on.
- 2:24Since I've been, and I guess we'll talk about this later, but since I've been doing open
- 2:29source for a living, all of a sudden, okay, I really better step up and get across there.
- 2:35And I kind of realized slightly later on in the day, oh, wait a minute, they have this
- 2:39thing where they offer booths to open source projects.
- 2:43We better do that.
- 2:45That sounds like a good idea.
- 2:46And yeah, just about managed to organize getting one of those with a lot of help from Anna,
- 2:53who I also work with.
- 2:56And I didn't know what to expect, but it was just nonstop, basically.
- 3:01That's really good, right?
- 3:02People are dropping in to talk to you about your project.
- 3:04Yeah.
- 3:05And there's so much kind of positive reinforcement coming from people at the stage, but it was
- 3:10just nonstop talking for about three days together with the poster session as well.
- 3:16So I have no idea how many, felt like hundreds, but...
- 3:21Yeah, that's really cool.
- 3:22We had a booth as well for all the podcasters that we had gotten grouped together and had
- 3:28the five podcasts all put together in the one booth.
- 3:31And it was a real similar experience.
- 3:32Like the positive vibes and the feedback was amazing.
- 3:34Some of the other guys who hadn't been there before, they were like, wow, this kind of makes
- 3:40it so real with all these people.
- 3:42Did you have that similar experience?
- 3:43Like, you know, there's a number of stars on GitHub and you get a message and stuff,
- 3:47but like when hundreds of people come up to you and talk to how you've like enabled something,
- 3:51did that strike you pretty strongly?
- 3:53I kind of had this odd mixed feelings about, not mixed feelings exactly, but just this strange
- 4:00sensation because being at the booth and you've got, like you say, all these people coming
- 4:05up and, you know, saying thanks for the work that you do on the project and all of these
- 4:12kind of good vibes.
- 4:13But then at the same time, I'm standing there at the booth and I'm looking over at all the
- 4:17big, real professional companies that know what they're doing and thinking, hmm, that's
- 4:24where I'd really like us to get to, you know?
- 4:27Yeah.
- 4:27Yeah.
- 4:28That was interesting.
- 4:29But what was also nice as well was having a good excuse to only talk to people at the
- 4:36conference.
- 4:37You know, the only time that I managed to get upstairs into the talk spaces was for
- 4:43the talk that I gave and the rest of all of the talk session time, I was just talking to
- 4:49different people and I really enjoyed that.
- 4:51I got a lot out of that.
- 4:53Yeah.
- 4:54I felt the same way.
- 4:55I only went to the keynotes and the open spaces.
- 4:58And other than that, I really just was at the booth talking to people.
- 5:02It was really, really amazing.
- 5:03And, you know, thanks to everyone who stopped by my booth and I'm sure you feel the same
- 5:07way.
- 5:07It was quite cool.
- 5:08By the end of the second day, I had basically lost my voice from talking.
- 5:12Yes.
- 5:13I should also say that we got a bunch of help from other volunteers who offered to step up
- 5:19and give us some of their time on the booth, which was awesome as well.
- 5:23Yeah, that's cool.
- 5:25Thank you to them.
- 5:25So, yeah, one positive experience from PyCon and people who are out there listening, be sure
- 5:31to get your PyCon tickets early because, as always, it sells out.
- 5:35And then I get messages like, hey, can you get me a ticket?
- 5:37It's sold out.
- 5:38Like, nope, no secret tickets.
- 5:40All right.
- 5:41So let's get into your story first before we talk about your restful things.
- 5:46How do you get into programming in Python?
- 5:48Oh, yeah.
- 5:49Okay.
- 5:49Well, let's start with how do I get into programming, I suppose.
- 5:53So ZX Spectrum 128.
- 5:58So when I was a little kid, I did a little bit of programming from magazines and stuff.
- 6:07You know, when it was in the days when they came with a tape on the cover back then.
- 6:14And my dad bought me a ZX Spectrum and I did a little bit of noodling around then.
- 6:20Just silly little game stuff.
- 6:23Well, not even that, really.
- 6:24At that point, that was just copying stuff out of magazines or trying to figure out little
- 6:29bits and pieces.
- 6:30And then I kind of dropped it for a while.
- 6:33And later on, when I was a teenager, I started getting into QBasic and programming games together
- 6:43with a friend.
- 6:43And we had like a little thing going when we did that.
- 6:47And that got me into it enough to decide to do it for a university course.
- 6:52And then I've had a big old windy road since then.
- 6:56So I started out working in speech recognition, stayed in that field for several years.
- 7:02I then moved into networking and worked with a content distribution network who did a peer-to-peer
- 7:11content distribution network.
- 7:12Peer-to-peer, huh?
- 7:13That's pretty cool.
- 7:14Yeah.
- 7:14Yeah.
- 7:15Well, what they started out with initially was providing BitTorrent caches to ISPs so that
- 7:25ISPs wouldn't have to pay for the upstream costs to the internet and could instead just cache
- 7:31the really popular streams, right?
- 7:34Do you feel like BitTorrent was ruined by people using it too much for piracy?
- 7:42Like BitTorrent, I think, would have been a really fantastic for all sorts of web content
- 7:48delivery, video streaming, so many things.
- 7:52But since it got so associated with pirating MP3s and videos, it's kind of a black mark.
- 7:59I don't know.
- 7:59I think if it had been the right solution technically, then it would have won out on its own merits
- 8:06anyway.
- 8:07And the legal side of it, I don't think was really the main influencer of that necessarily.
- 8:17Oh, and really, I guess the reason why I say that is because I was there busy working at
- 8:22a company which was using BitTorrent and was trying to provide a, here's how you do a CDN
- 8:32using PID's PIT.
- 8:34I don't know.
- 8:34It's too long ago for me to give you a code here.
- 8:38I'm going to just stop now.
- 8:41All right.
- 8:41Sounds good.
- 8:42All right.
- 8:43So you did that for a while.
- 8:44Was that in Python or something else?
- 8:45So that, see, I can't remember at what point things stepped into Python.
- 8:51It was either when I was working in speech recognition and at some point all of the sorts of the build
- 9:02tools that you need for doing things like building the language models, right?
- 9:07The sorts of things that we were doing when I started there was writing shell scripts and
- 9:12pull scripts.
- 9:13And I can't quite remember whether I moved into Python then because it's been long enough
- 9:18now or whether it was when I then later started doing networking.
- 9:23But whenever it was, all of a sudden, it was like, oh, wow.
- 9:28This is so, you know.
- 9:30This is different.
- 9:31Having been used to working in C and C++ and either Pearl or Bash for scripting, it was,
- 9:40yes, such a breath of fresh air.
- 9:43And it's quite surprising almost to be here after all this time and still be so infused by
- 9:53the language and not feel like that's really changed.
- 9:56Yeah, that's really an interesting point.
- 9:58I've kind of marveled at that myself as well.
- 10:01So, you know, even if you just look at like some of the growth curves, popularity curves
- 10:06of Python and the ecosystem, it's been around for over 25 years now, but it's still growing
- 10:13and growing more quickly now than it did 10 years ago or when it was brand new.
- 10:17It's really interesting.
- 10:18Right.
- 10:19And we're just coming up to potentially a new kind of slice of stuff that it can break into
- 10:26as well.
- 10:27You know, now that Python's readoption has finally really started to hit that tipping
- 10:33point and the asyncio primitives that are in there, all of a sudden there's this new slice
- 10:41of stuff that Python could be really, really good at that it historically hasn't particularly
- 10:46been.
- 10:47Yeah, it's definitely an exciting time.
- 10:49Yeah, for sure.
- 10:50All right.
- 10:51So thanks for the story.
- 10:52What do you do day to day?
- 10:54You said you're a professional open source developer.
- 10:56How awesome is that?
- 10:57Yes, that's quite a rare, a rare thing, isn't it?
- 11:02Really?
- 11:03I love to share these stories.
- 11:04I've been, you know, been really lucky with the way things have worked out just with timing
- 11:13and so on.
- 11:14So, yes, I, as of about 12 months ago, I now work on open source for my living full
- 11:25time.
- 11:25So let's approach it this way.
- 11:28So I started on Rest Framework about five years ago and all of that was as a side project
- 11:33as it is with most people.
- 11:35And when we came up to the point where I was thinking about all the things we'd need to do
- 11:40for Rest Framework 2, I figured that I was going to need some full time on it.
- 11:45And in order to do that, we launched a Kickstarter project for it.
- 11:49And that was really successful.
- 11:51And I managed to get...
- 11:54What year was that?
- 11:54Do you remember?
- 11:55That must have been either 2014 or 2015.
- 11:582015.
- 11:59Okay.
- 11:59So pretty recently.
- 12:01Yeah.
- 12:01Yeah.
- 12:02Not so long ago.
- 12:03It probably, it was probably started in 2014 and I was probably working on it up until
- 12:082015.
- 12:09How'd the Kickstarter go, by the way?
- 12:11Oh, it was awesome.
- 12:12Yeah.
- 12:12We were, we got about 35,000 pounds, which I think was about $50,000.
- 12:20The way that I organized it, I was with a very small web consultancy or very, very into supporting
- 12:30open source.
- 12:31The person who's the CTO of the company runs the local Python meetup group and so on.
- 12:37And we figured out a way that I would be able to take a slice of time out of my working day
- 12:45in exchange for us doing the Kickstarter through the company.
- 12:48And I was able to work on the project for, I don't know, maybe about nine months or so as
- 12:54a result of the Kickstarter, with most of my time being dedicated to it, or about 50% time.
- 13:00So that was great and was much more successful than my highest estimate would have been for it.
- 13:07What goal were you asking for?
- 13:09I guess our starting point was probably something like 5,000 pounds.
- 13:13And maybe I was hoping for 10,000 and flew way past all of that.
- 13:20Cool.
- 13:20Congrats.
- 13:21Yeah, it was great.
- 13:22Yeah.
- 13:23And 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:33And launching another Kickstarter was one of the options.
- 13:37But trying to find a way that we could do it that would remain sustainable rather than just being a big one-off thing.
- 13:46Yeah.
- 13:46Kickstarters are nice, but they're very much one-off.
- 13:50Like, here's a boost.
- 13:51Now what?
- 13:51Yeah.
- 13:52You can't just keep doing Kickstarters.
- 13:53Yeah, and it has to be – you have to have a really nicely wrapped up bit of functionality.
- 14:00It's difficult to kind of sell it as triage on the project or open-ended bits of work.
- 14:08And there's a lot of work as well.
- 14:11You 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:21Because 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:31Let's do this.
- 14:32You keep on wanting to hold off, hold off, and try and – anyway.
- 14:37But this time around, I started thinking about launching an ongoing funding model instead.
- 14:46We 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:07I mean, that comes with some sort of funding, right?
- 15:09It does.
- 15:09It does indeed.
- 15:10So we put forward an application for the project.
- 15:15And when we were told that we'd been successful, and I can't remember exactly how much it was right now.
- 15:26It was probably about $35,000, I think, that we'd requested.
- 15:31When 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:38I 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:48That's cool.
- 15:49How long ago was that?
- 15:50How long have you been doing it in this path?
- 15:52So, yeah, just over a year.
- 15:53We literally just passed over the year milestone now.
- 15:57So, yeah.
- 15:59Are you enjoying it?
- 16:00Oh, it's great.
- 16:01It's great.
- 16:02It's great.
- 16:02It'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:17But I try to spend most of my working time out of co-working space rather than just working from home.
- 16:26So 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:50So, yeah.
- 16:50Yeah, I feel like there should be way more of this.
- 16:53There 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:04Right.
- 17:05And at best, they'll do a PR back to it.
- 17:08But even, you know, maybe not even that, right?
- 17:11And 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:21Right.
- 17:21So, yeah.
- 17:22And 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:31And so there's two sides to it.
- 17:33One's the marketing angle of it, which is important.
- 17:39But in a way, it's something that I'm less interested in.
- 17:42The 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:06Because you've got all of these other companies that are also pitching in at the same time.
- 18:11So 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:25And they're like, amazing.
- 18:26How do we do this?
- 18:27Well, I have a figure I tell them.
- 18:29You know, how is that not a reasonable business proposition?
- 18:34Okay, I'm not working on exactly day to day what they tell me, but I am working on trying to support their businesses.
- 18:41You know, it's not eye in the sky stuff.
- 18:44Yeah, I'm not coming to your meetings, but I'm going to be working on your business.
- 18:48Yeah.
- 18:50Yeah, I think it's a super, super straightforward story.
- 18:56And I think you're right.
- 18:57There's people sort of blazing that trail.
- 18:59And how well it works in the future is going to depend on how well, like the first few successful ones blaze that trail.
- 19:09Right?
- 19:09Yeah.
- 19:09Yeah.
- 19:10Yeah.
- 19:10We need to build stuff that makes those companies more successful.
- 19:14And we also need to sing and dance about the companies that are supporting open source financially.
- 19:22And 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:36And try to drive things that way around as well.
- 19:39Yeah, I feel like it's something of an awareness thing as well, right?
- 19:44Like, 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:58And everyone did this.
- 19:59Like, you would have a much more stable platform.
- 20:02Your scalability would be better.
- 20:04And you would be able to, you know, trade half a microsecond or millisecond faster or whatever, right?
- 20:09That's a really simple story to tell to the business owners.
- 20:12But it's, I don't know.
- 20:13It's, I'm not sure how much it's happening yet.
- 20:16It's step by step, right?
- 20:18You 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:36This is what the people who supported it and anyone who's using it actually got out of this experience.
- 20:41And now we can do it over here and we can do it here and we can do it here.
- 20:43And also to do things like look retrospectively and say, how much did that cost each business?
- 20:49When you go and you look at all these bits of, well, anyway.
- 20:52Yeah, no, I think it's, I think it's really great.
- 20:54And we should probably talk about your projects in particular as well.
- 20:58Yeah, I know.
- 20:58But I really, but I think that this is super interesting to people.
- 21:03It's very powerful.
- 21:05And for everyone who's doing it, there's probably a thousand people who wish they could.
- 21:09And so, like, just the awareness of us talking about it, I think, serves a good purpose.
- 21:14I think it's going to change.
- 21:15I'm really optimistic.
- 21:16I see things have been moving forward.
- 21:21And I feel like we're on the start of a wave.
- 21:24I mean, that's easy for me to say because I'm fortunate enough to actually be in that position.
- 21:29But I do feel like it's starting to change.
- 21:33Sure.
- 21:33I definitely think it's something that 15 years ago would have been really, really unexpected.
- 21:39And now it seems pretty, pretty normal.
- 21:42It's just something that's got to get moving.
- 21:43Yeah.
- 21:43This portion of Talk Python To Me is brought to you by Linode.
- 21:48Are you looking for bulletproof hosting that is fast, simple, and incredibly affordable?
- 21:52Look past that bookstore and check out Linode at talkpython.fm/Linode.
- 21:57That's L-I-N-O-D-E.
- 21:59Plans start at just $5 a month for a dedicated server with a gig of RAM.
- 22:03They have 10 data centers across the globe.
- 22:06So no matter where you are, there's a data center near you.
- 22:08Whether you want to run your Python web app, host a private Git server, or even a file server,
- 22:13you'll get native SSDs on all the machines.
- 22:16It's a 40 gigabit network, 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.
- 22:23Want a dedicated server for free for the next four months?
- 22:26Use the coupon code python17 at talkpython.fm/Linode.
- 22:32You've got a couple of projects that are amazing.
- 22:34And so let's take them, I guess, from the beginning.
- 22:38So the first one, which we've mostly been talking about, is Django REST framework.
- 22:43All right.
- 22:44This is the thing you started back in 2010 or so?
- 22:47Yes.
- 22:47Yeah.
- 22:48All right.
- 22:48So, you know, everyone knows what Django is.
- 22:51They probably know what REST is.
- 22:53What's Django REST framework?
- 22:55What is this project?
- 22:57Django REST framework is, unsurprisingly, an API framework for Django.
- 23:02And it tries to fill in all of the gaps of where Django was historically designed as a web framework.
- 23:13What are all the extra bits?
- 23:16Right.
- 23:16Here's HTML.
- 23:17Go into browsers.
- 23:19You wanted to make a talk to machines, not people, right?
- 23:21What 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:31So, 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:54and all sorts of bits and pieces, providing generic classes of views that give you default functionality for the CRUD case.
- 24:05So, 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:20So, 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:30Yes.
- 24:31And 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:46If 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:56All of those sorts of that.
- 24:58Do 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:10All of those sorts of things.
- 25:12Okay, cool.
- 25:12So, 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:25So, being Django-based, it works primarily with the Django ORM.
- 25:30There's stuff that you could do to integrate it with other backends as well.
- 25:35The question is, suppose in my web method, I do a query and I get a list of users back from Django ORM.
- 25:44Can I just return that list and have it magically JSONify it, or XMLify it, or whatever?
- 25:50Yes and no.
- 25:51So, yes, you can.
- 25:53No, you probably don't want to do that.
- 25:54I shouldn't.
- 25:55You can, but don't do it.
- 25:58So, you can ask it to give you the default representation and just say, return all of the fields on this model.
- 26:07So, 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:15And 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:27What you would want to do more typically is be a little bit more precise about the representation.
- 26:34So, declare the fields that you want returned explicitly and independently of the model itself.
- 26:42So, list them all out.
- 26:43So, yeah.
- 26:44Yeah.
- 26:45And going the other way, maybe it's even more important.
- 26:47Like, if I post a JSON body to a method, is there serialization on that side?
- 26:52Or do I, like, read it?
- 26:54There's two different aspects to this.
- 26:55So, 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:10That we call the serialization, going between the plain Python data types and ORM objects.
- 27:17Then 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:28So, JSON.load.
- 27:31And on the other side, the rendering, which is taking the data types and turning those into the response body.
- 27:38So, JSON.done typically.
- 27:40Yeah.
- 27:40So, it looks like you have a lot of control over all those different things.
- 27:43Yes.
- 27:43So, you can, for instance, you control the serialization style, which is what information do you want in the representation.
- 27:51But separately to that, you can also control the renderings of that.
- 27:56So, you could, for instance, have both a JSON and a YAML output for the same data.
- 28:04Sure.
- 28:05Did I notice somewhere in your docs that you can basically use, like, a fake or false extension to control that?
- 28:14So, like, a slash user slash one dot JSON versus slash user slash one dot XML and things like that?
- 28:21Yeah.
- 28:21So, there's different ways that you can control which rendering you get.
- 28:27By 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:45which 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:58So, yes, dot JSON or dot YAML.
- 29:00Yeah, yeah.
- 29:01So, the most popular API that I know that does that is the Basecamp API.
- 29:05Right.
- 29:06They do, like, thing dot JSON, even though it's entirely not needed.
- 29:10That's just, like, their style, right?
- 29:11Some people like that.
- 29:12Some people don't.
- 29:13Yeah.
- 29:13But the thing that's actually drove all of that side of the rendering in the first place anyway was the browsable API.
- 29:22So, 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:33depending on exactly what you configure, but you'll typically get back plain JSON.
- 29:37When 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:53but also a whole bunch of extra information around the outside and controls to allow the user to interact with that API endpoint.
- 30:01That's awesome.
- 30:02So, it's like self-documenting APIs out of the box?
- 30:06Yes, exactly.
- 30:07That's really cool.
- 30:08Yeah, that's one of the things that I think often gets forgotten on APIs or gets out of date, right?
- 30:13Like, 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:24Yeah.
- 30:25Well, I'm still surprised that there aren't more frameworks that are starting to provide this.
- 30:32I mean, the browsable API stuff, that was the entire reason that REST Framework came into existence in the first place,
- 30:41because I was thinking about what, you know, why are APIs not, why can't we interact with them using the web browser?
- 30:50This is a bit weird.
- 30:51Yeah.
- 30:51And that was the entire driver for, okay, well, how would you do that?
- 30:56Oh, you'd do it like this.
- 30:58Oh, wait a minute.
- 30:59This is a framework.
- 31:01Oh, if I think this is a good idea, then I'd better make it a good framework.
- 31:05My prototype is almost the thing.
- 31:08You know, that's awesome.
- 31:08Yeah.
- 31:09Yeah.
- 31:10I 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:19but it's hard to see the documentation unless somebody's taking the time to do that separate.
- 31:24Yeah.
- 31:24So can you give us just like a quick sense, not too much in code, but just like the conceptual steps of like,
- 31:33how would I create a project and like set it up and add an API method using Django REST framework?
- 31:40It slightly depends on whether you are building a project that is primarily a CRUD style API or not,
- 31:50because 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:58and that's the most common use case, really.
- 32:01Do you point that out like your ORM objects and say, here's an ORM object, give it the various operations?
- 32:07The way around that I would approach a new project with REST framework,
- 32:12I 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:22and instead think about the basic, the fundamentals of the API.
- 32:27So which endpoints do I want to expose?
- 32:29What do I want the representations of those endpoints to look like?
- 32:33How do I want relationships between different objects to look?
- 32:39And try to get that side of design figured out in my head first independently.
- 32:46Then you've also got the data models as well and thinking about the storage side of things,
- 32:53which is very closely tied to the representation, but isn't necessarily the same thing exactly.
- 32:58So once you've got the start of those things in your head, then it's a case of blocking out the Django models,
- 33:08blocking out corresponding serializers for those models.
- 33:17So REST framework gives you a lot of different levels of tooling that you can work at.
- 33:22If you want, you can work at a very high level of abstraction where we provide things called view sets
- 33:29that bundle up a whole lot of different interactions into a single class
- 33:36and provide, mostly automatically provide the routing of URLs onto all of those points of interaction.
- 33:47Now I tend to not work at that level of extraction.
- 33:51I 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:08and write out the methods on each of those individually.
- 34:12And again, there's still another different couple of layers of abstraction that you can be working at there,
- 34:19because you can either be using the built-in functionality of give me the automatic create an object function,
- 34:29or you can go and write that code yourself.
- 34:32When I'm building an API with REST framework, I tend to prefer the explicit approach.
- 34:38So 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:49then I'll use that.
- 34:50But if it's not, rather than trying to override it at particular hook points within those class-based views,
- 35:00I'll just override the get or the post or the put or the delete method entirely and write it out explicitly,
- 35:06because that really keeps everything surfaced up to the top.
- 35:11I find makes it quite a maintainable approach to building the API.
- 35:16That's cool.
- 35:17I really like that you approach it from the outside.
- 35:21Like, how should this look to the people consuming this API?
- 35:24Forget the implementation.
- 35:25And then let's make that happen with Django REST framework, right?
- 35:28Because really, in the end, that's what's going to determine whether people are happy with the API you've delivered them, right?
- 35:36Yes.
- 35:37Yeah, absolutely.
- 35:38Yeah.
- 35:38It's not like, well, you do it this way because it was easier.
- 35:40It was automatic in Django REST framework.
- 35:42But it should have been this other way, right?
- 35:44I mean, it started off maybe when the API frameworks and the landscape were younger.
- 35:53Maybe 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:05Yeah.
- 36:06Yeah, but, you know, in 2017, we have more experience building APIs and more examples of good APIs than long ago.
- 36:14Yeah.
- 36:14Nice.
- 36:15So you want to tell us about some of the popular deployments?
- 36:19Like, who's using it?
- 36:20Do you know how they are?
- 36:21Gosh, yeah.
- 36:22I should probably open up things like the sponsor list to remind myself there.
- 36:26So let's think.
- 36:27No, I'm not going to do that.
- 36:29I'm just going to.
- 36:29So Mozilla are obviously a really big name.
- 36:34We're a big sponsor of the Kickstarter.
- 36:37I can't remember how much they're using it at the moment, but I think that they are.
- 36:41I know that Red Hat are using it at least within a couple of places.
- 36:48Heroku use it for something or other.
- 36:53And, well, we've got about 60 corporate sponsors.
- 36:58So stacks and stacks of different consultancies and product businesses of all types, really.
- 37:07It'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:19Yeah, can you think of one you're like, whoa, you're doing what with my framework?
- 37:22Not 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:39Yeah, excellent.
- 37:40All right.
- 37:41So it sounds like a really successful project.
- 37:43And 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:52Basically create a business around your framework.
- 37:55And congratulations to you on that.
- 37:57That is super, super cool.
- 37:59I think it's so neat.
- 38:00I'm happy to be able to, like, shine a light on it.
- 38:02Thanks.
- 38:02Yeah, it is.
- 38:03It's wonderful.
- 38:04Yeah.
- 38:04So there's another thing that I came across that you just started working on as well that's very exciting.
- 38:11And I don't know how it ties into the funding stuff, but I certainly think it's cool, is called API Star.
- 38:17Tell people what API Star is.
- 38:19This is a new API framework that I started working on.
- 38:24Rest framework is still my main gig, I guess.
- 38:29But there are a couple of different things that I think are important to explore at the moment.
- 38:37And API Star is my start towards doing some of that.
- 38:40It'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:57So 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:16the sorts of data and the sorts of components that that function is going to take.
- 39:21And you also declare what type of data it's going to return as well.
- 39:28And once you take that different approach, there's a lot of interesting things that you can start to do on top of that.
- 39:36So to start with, because you've got a plain data interface rather than take a request and return a response,
- 39:44you can layer on different types of network interface or different ways of interacting with that function on top of it.
- 39:53So for example, as well as accepting HTTP requests, you could route a command line command onto your view.
- 40:03Or 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:15There 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:31Now, not all of those things are done, but I'm starting to think about how would we be able to do those.
- 40:38So what we're going to do is do is do a type system that corresponds to the same capabilities as JSON schema.
- 40:51So 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:04And 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:22Not only can you build this API documentation, you can also build interactive API documentation because you've got enough information in those types
- 41:31that you can build HTML form controls that you can build HTML form controls with appropriate controls given the shape of the data input.
- 41:40You 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:53So you can have a really clear way of generating Swagger or Rammel from your type declarations.
- 42:01If you wanted, you could even go the other way and say, okay, I've got my Swagger blueprint.
- 42:06Build me the stubbed out set of functions that I'm going to want for my project.
- 42:13You've also, you've even got enough information that once you write out these declarations, even before you've implemented anything,
- 42:22you could start running or you will be able to start running a mock API.
- 42:28So you've got all the response types.
- 42:31You know what the inputs look like and whether they're valid or they're not valid.
- 42:37So 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:49that's already ready to start them build the front-end against,
- 42:57while your back-end team starts to fill in all the blanks of, oh, well, we better actually implement the behavior here.
- 43:05Yeah.
- 43:06So there's also some interesting things you can do.
- 43:08Oh, and also, what else?
- 43:10Dynamic client libraries that are able to interact with your functions.
- 43:16They 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:26that corresponds to the same thing you have on the server side.
- 43:28So all sorts of cool stuff once you've got this.
- 43:31Yeah, that's actually been one of the weak points of HTTP APIs over, say, SOAP services, right?
- 43:38SoAP services are dreadful.
- 43:39But 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:47all the types that are exchanged there.
- 43:49I'm thinking of SUDs in Python or obviously like Java or .NET and their tooling.
- 43:54But here you're kind of describing enough information.
- 43:57This is the stuff that goes in.
- 43:59This is the stuff that goes out that you could actually bring that back in a sense.
- 44:02Yes.
- 44:03What this is it's a way of – it's still a restful approach.
- 44:09It's just a way of providing a better description to what the interface is.
- 44:14And that also has an impact on what sort of APIs you build, actually,
- 44:18because given that we haven't had great client-side tooling or great ways of describing what those interfaces are,
- 44:27the let's always build CRUD style interfaces is something that's kind of naturally happened
- 44:33because it's been a bit of a constraint of we can't express very well different things that don't fit into that.
- 44:41But having a really expressive way of being able to declare what those interfaces are lets you take a more,
- 44:49okay, these are just different types of actions or different types of views onto the data.
- 44:55They don't necessarily have to correspond to CRUD.
- 44:57Yeah.
- 44:57Yeah.
- 44:58This portion of Talk Python To Me has been brought to you by Rollbar.
- 45:02One of the frustrating things about being a developer is dealing with errors.
- 45:06Relying on users to report errors, digging through log files, trying to debug issues,
- 45:11or getting millions of alerts just flooding your inbox and ruining your day.
- 45:15With Rollbar's full-stack error monitoring, you get the context, insight, and control you need to find and fix bugs faster.
- 45:22Adding Rollbar to your Python app is as easy as pip install Rollbar.
- 45:26You can start tracking production errors and deployments in eight minutes or less.
- 45:30Are you considering self-hosting tools for security or compliance reasons?
- 45:34Then you should really check out Rollbar's compliant SaaS option.
- 45:38Get advanced security features and meet compliance without the hassle of self-hosting,
- 45:43including HIPAA, ISO 27001, Privacy Shield, and more.
- 45:47They'd love to give you a demo.
- 45:49Give Rollbar a try today.
- 45:50Go to talkpython.fm/Rollbar and check them out.
- 45:55One of the things that struck me the most about looking at this API, is it Python 3 only?
- 46:00It is, yes.
- 46:01So because of the type annotation.
- 46:03Right.
- 46:04Yeah.
- 46:04So the type annotations are the things that struck me the most when I look at it.
- 46:08So you might have an API method and the method, say, if you want to have access to the request object,
- 46:16you would say request colon then HTTP.request.
- 46:19And you basically annotate like this variable is this type.
- 46:22And your framework will go, oh, I have one of those types.
- 46:24I'm going to inject it here.
- 46:26There's all these different types of things that can be injected, right?
- 46:29Yes.
- 46:30So the different kinds of component that you can inject, they can either be, say, something
- 46:37that's based on the incoming request, like you say request, or you could say, you could
- 46:43have query params.
- 46:45So the class query params, if you put that on, you'll get the dictionary of all the query
- 46:49parameters.
- 46:49But you can also do interesting things like there's a class, the singular query param.
- 46:55And if you put on the name that you use for that variable and the class query param together,
- 47:02it will say, okay, I'll give you this query parameter.
- 47:07That is so awesome because I feel like all the time, I'm just, I'm not really excited to
- 47:12see this thing come into existence.
- 47:13So all the time, if you're taking a traditional HTML based framework, Django, Pyramid, Flask,
- 47:20whatever, they're like, okay, here's the post dictionary.
- 47:24Or here's the data that was submitted.
- 47:26Or here's the query string.
- 47:27And you can go dig into that dictionary and find the thing you want.
- 47:30Here are the headers.
- 47:30Dig into the headers and find the thing you want.
- 47:32But on yours, you could actually say things like user underscore agent colon HTTP header.
- 47:37And it will go into the headers, find the user agent, pull it out and set that value.
- 47:42So you just, it's as if all the elements of the request become just function parameters,
- 47:48which is glorious.
- 47:49Yeah.
- 47:50So it's really expressive.
- 47:51It reads really nicely when you look at it.
- 47:54Right.
- 47:54It also means that it's really testable because the interface that you're exposing is exactly
- 48:00the thing you want to be exposing.
- 48:01You don't have to do things like build up a mock request object in order to test your functionality.
- 48:07Right.
- 48:08Because if you say it takes a query string and it's, the thing is called name, you just
- 48:14pass in the value you want for name in your test and you're done.
- 48:16Right.
- 48:16You don't have to fake up a dictionary that holds things.
- 48:19Right.
- 48:19Yeah.
- 48:20Yeah.
- 48:20And the other thing that's interesting as well is because the way it works is when you
- 48:27route all of your views with the application, at the point they get rooted, it inspects what
- 48:32the function signature is, figures out, has to look at what all the different components
- 48:36are and figures out exactly what's going to need to be run every time it needs to run that
- 48:42view, which ends up meaning that it's really, really fast because you only pull in exactly
- 48:48the things that you need to pull in.
- 48:49So for instance, if you've got a database component, only views which declare that they're using
- 48:57the database component will end up getting wrapped in a transaction and anything that doesn't,
- 49:03that never gets seen at all.
- 49:05That's fantastic.
- 49:06Yeah.
- 49:06The other thing that I really like about the type annotations is automatic type conversion.
- 49:10So you could have like a user underscore ID colon int, and obviously everything comes into
- 49:16the web as a string, but do you like parse that into an int?
- 49:19Yes.
- 49:20Yes.
- 49:20That gets handled for you and the type validation on that.
- 49:25So you can either use the native types for that, or you can use the type system for that,
- 49:31which gives you the more expressive, everything that Jason Schema gives you stuff.
- 49:36You know, here's a complex object.
- 49:39Here's what it looks like.
- 49:40Yeah.
- 49:40Wow.
- 49:40That's awesome.
- 49:41All right.
- 49:42Another thing that I found to be interesting was the performance story.
- 49:45So like you already touched on it, this is a super lightweight framework, and I didn't
- 49:50even realize the extent to which you were ensuring that it only does what it needs to do.
- 49:55That's really cool.
- 49:57So you ran some various tests with like Gunicorn and Mindheld, or even with like some
- 50:04of the shiny new things like Sanic and uvloop, right?
- 50:09And so the stuff that you had on the website, let's see, it says Flask.
- 50:12You talk about scalability and just raw individual request performance.
- 50:16Like, so Flask on your setup, you're getting 5,238 requests per second and about 40 millisecond
- 50:24latency.
- 50:26On Sanic, which is really an interesting framework as well, you're getting like 21,000 requests
- 50:32per second and 10 milliseconds.
- 50:34And with API stars, 25,008.
- 50:37So you're like five times faster than Flask on both raw individual requests and overall, right?
- 50:45That's awesome.
- 50:45Yeah.
- 50:46Well, keep in mind that that's a test type that is not really real world usage.
- 50:53There's some really big provisos to make there.
- 50:56We'll talk about that stuff in a bit more detail later, but I interrupted you.
- 50:59Well, I was going to say, you have to be really super careful about these sorts of performance
- 51:05comparisons because the way I'm using it and the way someone else using it could be super
- 51:10different.
- 51:10The way I've set up my machine could be really different, but you were running the tech and
- 51:13power benchmark, which is a particular one, which is pretty well respected.
- 51:16So at least in that sense, you're running the simple JSON serialization version.
- 51:22Does that mean like if you use API star, your API is five times fast?
- 51:26No, because you're still probably doing your same implementation stuff, right?
- 51:29But it means how much overhead are you bringing in with the framework like that?
- 51:34You could maybe consider, right?
- 51:35Yes.
- 51:35So that's what I was trying to demonstrate when I've included that section in the documentation
- 51:41is not so much this is going to make things fast for you all the time, but the aspect of the
- 51:52framework can get out of your way if you need it to.
- 51:55Yes.
- 51:56So being able to declare the response type on the view, you can actually have it just
- 52:03return a WSGI response directly.
- 52:06You end up with the server calling into your framework and a single function call gets made
- 52:13and that gets returned directly back to the server.
- 52:16So that's an interesting aspect of it.
- 52:18Now, that doesn't mean for the different test types where different things like
- 52:23asynchronicity come into play that it would perform in the same sort of way, wouldn't it?
- 52:28Yeah, of course.
- 52:29But I think it's still really important to highlight that aspect of once you take this
- 52:35dynamic approach, you can work at whatever level is appropriate for the thing that you're
- 52:41building.
- 52:41Yeah, very cool.
- 52:42Okay.
- 52:42So I'm sure I've got you a bunch of email from pointing that out.
- 52:46Oh, no.
- 52:49Let me tell you how you could have optimized this in this setting.
- 52:51Anyway, speaking of performance and asynchrony, there's another project called uvicorn.
- 52:57Yeah, uvicorn.
- 52:58Tell us what this is.
- 53:03It's like the future version of GUnicorn, right?
- 53:07So in Python asynch.io land at the moment, there's a few frameworks that are existing.
- 53:17Sanic being one, aiohttp being another.
- 53:23Yep, Jepronto.
- 53:25That's right.
- 53:26A muffin.
- 53:27Yeah.
- 53:28They're very exciting.
- 53:29Kaiowaki.
- 53:30Is that right?
- 53:31Kaiowaki.
- 53:32Yeah.
- 53:32So that's, and which is really cool.
- 53:34And in particular, Sanic's been interesting because it's shown just how impressive these
- 53:43two particular components that it uses are, which is uvloop, which is an event loop that is implemented
- 53:53as a Python binding around either the same event loop that Node uses or something that was
- 53:59originally built for Node.
- 54:01And also an HTTP parsing library that is also a Python implementation, you know, a set of
- 54:09Python wrappers around a super fast C implementation that, again, I think was built originally for Node.
- 54:15And the performance of those two components is really impressive.
- 54:20The only problem that we have in the Python landscape at the moment is that all of these
- 54:26AsyncIO frameworks that we have are really still at the framework level.
- 54:31There 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:41We've had that for a long time in our regular old happy synchronous land because we've had WSGI for ages.
- 54:49And now you can't repurpose that for AsyncLand because you just can't.
- 54:56And the thing that I would like to do is combine the fact that there happens to be an incredibly awesome implementation
- 55:06that is super fast and the how do we figure out what the interface between the server and the framework ought to look like
- 55:16and bridge that gap and have, okay, here's just the bare bones.
- 55:22You know, you've got a single callable and it gets this set of data.
- 55:26Now go and build your AsyncIO framework on top of that.
- 55:30Okay?
- 55:31Yeah, yeah, yeah.
- 55:32That'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:41Yes.
- 55:41And I think once we've got that, that's really going to kind of set everybody free to start doing interesting things.
- 55:47Where it's difficult is trying to figure out how it sits into the existing landscape.
- 55:52So, for instance, one of the things that I would like Uvicorn to be able to do is to also be able to interface with Django projects using channels
- 56:02and be able to provide WebSocket support.
- 56:06But in a different deployment mode to channels has.
- 56:10So deployment mode there at the moment is you have your servers and those sit in front of a channel layer,
- 56:18which all the data gets passed over, probably Redis or something like that.
- 56:22And then you have your workers running behind that and you have those three different components.
- 56:26I would like to also be able to provide a different deployment style where you just have a single server process,
- 56:35well, set of server processes that are running that interface with the application framework directly.
- 56:42Yeah, that's awesome.
- 56:43Instead of having one more hop and two sets of worker processes and separate implementations, all that stuff.
- 56:50And there's different considerations to both different deployment styles.
- 56:54And there's some reasons that tiered approach that channels takes can be preferable as well.
- 56:59But 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:11that is also able to power an existing really, really widely deployed synchronous framework as well and add WebSocket supports.
- 57:22I mean, you know, Andrew Goswin's done all of the heavy lifting here.
- 57:25I'm just gluing various bits and pieces together.
- 57:27This wire goes to this wire, yeah.
- 57:30Okay, I think there's like low-hanging fruit here.
- 57:33If we take this good work from over here and that good work from over there, yeah, live wire them together.
- 57:38Yeah, so that's where that is at the moment.
- 57:44That's super exciting.
- 57:45Yeah, 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:58And in order to do that, I want to get a proper separation between the server and the framework for that.
- 58:05Yeah, 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:15Sounds easy.
- 58:15Yeah, perfect.
- 58:16What is that, next week?
- 58:18We'll see.
- 58:20So let me ask you a question.
- 58:21So 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:30It would be very enthusiastic.
- 58:32How's the readiness of API star?
- 58:36How's the readiness of this uvicorn?
- 58:37So I know that API star is already being used in production by at least a couple of folks.
- 58:42You certainly would have to not mind the fact that there will be breaking changes to the API that we provide.
- 58:49So pin your dependencies in requirements.txt?
- 58:52Yeah, that's one thing.
- 58:54And, you know, be prepared to move forward as the framework moves forward.
- 58:58The 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:09And get crossing that bridge.
- 59:11Once that bridge is being crossed, then I think that's when it all starts to tie together really nicely.
- 59:18The 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:28At the moment, it's fairly comprehensively documented, but it's still all on the readme at the moment.
- 59:32My big signal to everybody of, yeah, go primetime will be once I've finally got the docs live.
- 59:40Because I'll only launch them when I'm really, really happy with how everything's looking.
- 59:44Sure.
- 59:44Sounds great.
- 59:44And uvicorn?
- 59:46Well, it's a different slice of stuff that you would use it for.
- 59:49So at least at its current level, because it's so much lower level, give it a try.
- 59:54Don't do anything with it in production now, for sure.
- 59:59At the moment, that's an experimental stage.
- 1:00:02But again, I think that's going to, there's not actually that much work that needs to be done on it.
- 1:00:09So 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.
- 1:00:22Sure.
- 1:00:23Sounds good.
- 1:00:23So often people will write to me and say, hey, I'm really looking forward to get into open source.
- 1:00:29What project would be good?
- 1:00:31Are you looking for contributors for any of these projects?
- 1:00:33Yeah, sure.
- 1:00:34Best 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.
- 1:00:54Comment on the issue.
- 1:00:55Does this make sense or not?
- 1:00:56And figure out if you can reproduce it, if it looks like a bug.
- 1:01:00And all of those sorts of bits of day-to-day triage work, and they're not terribly shiny or, you know, wildly exciting.
- 1:01:12It'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.
- 1:01:21But that's more difficult typically for people to get into.
- 1:01:26There's loads and loads of interesting feature work or surrounding stuff that can be done on both API Star and Yuvikon at the moment.
- 1:01:36There's a discussion group for API Star, so shout out on there if you're interested in it,
- 1:01:44and if there's anything in particular that you think you might be interested in working on.
- 1:01:48And with Yuvikon, just raise an issue against the repo, and I'll chat about it there.
- 1:01:55All right.
- 1:01:55Yeah.
- 1:01:55Sounds good.
- 1:01:56Sounds good.
- 1:01:57Well, Tom, I feel like we've covered a lot of ground in this episode.
- 1:02:01It seems like it, yeah.
- 1:02:04Yeah, yeah.
- 1:02:05We could have almost done three shows out of this.
- 1:02:07Maybe we'll come back someday and do that.
- 1:02:09So maybe we'll leave it there for those topics, but let's get to the questions.
- 1:02:13So if you're going to work on any of these projects, what editor do you open up?
- 1:02:17Atom.
- 1:02:19Always Atom.
- 1:02:20I had a brain fail there.
- 1:02:22I was like, wait a minute.
- 1:02:23What is it even called?
- 1:02:26Oh, yeah.
- 1:02:26The title says Atom.
- 1:02:28Awesome.
- 1:02:28Cool, cool.
- 1:02:30And we have over 100,000 packages on PyPI these days.
- 1:02:37What's one that maybe you ran across recently that was awesome, but not everyone knows?
- 1:02:41White Noise.
- 1:02:42White Noise is a piece of whiskey middleware that serves static files for you.
- 1:02:54That's all it does.
- 1:02:55It serves static files for you.
- 1:02:57And it does it so.
- 1:02:58What is great about it is it's fast enough that you can just put in this bit of pure Python code
- 1:03:05that handles being able to have your static files served from the same platform that the rest of your application is being served from.
- 1:03:14You 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.
- 1:03:23And it handles all of the right bits of getting the HTTP caching for that right.
- 1:03:32So 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
- 1:03:43because as soon as the CDN got each asset, it'll just end up getting served from the CDN.
- 1:03:48And what I love about White Noise is it's so perfectly scoped.
- 1:03:52It's one of those projects where it's like, okay, yeah, you've got this right.
- 1:03:57That's awesome.
- 1:03:58That sounds really, really fun.
- 1:03:59So thanks for that.
- 1:04:00I hadn't heard of White Noise.
- 1:04:01And I like the name too.
- 1:04:02There you go.
- 1:04:03Yeah, static files.
- 1:04:04So it took me a while to get it.
- 1:04:06Static files, right?
- 1:04:08Yeah, yeah.
- 1:04:09That's awesome.
- 1:04:10Okay.
- 1:04:11So final call to action.
- 1:04:13People want to check out your projects.
- 1:04:15They want to get involved.
- 1:04:15What do they do?
- 1:04:16Just jump in really.
- 1:04:17So API start, that's jumping on the discussion group.
- 1:04:22Even if it's just saying I'm interested, this is why I'm interested.
- 1:04:25And that's a great thing to do.
- 1:04:27Was that what your talk at PyCon was about?
- 1:04:29It was.
- 1:04:29Yes, it was.
- 1:04:30Yeah.
- 1:04:30Okay.
- 1:04:31So you can check that out at youtube.com slash, what is it?
- 1:04:33PyCon 2017 and then search for you.
- 1:04:36Yeah.
- 1:04:37Yeah.
- 1:04:37With REST Framework, the thing that is a really good place to get into is going on to the discussion
- 1:04:44group.
- 1:04:45And if anybody's having problems trying to help there or getting stuck in on Stack Overflow,
- 1:04:51those are all great things to do.
- 1:04:53Or just say hi on Twitter or come and have a chat on IRC.
- 1:04:57Anything like that is always welcome.
- 1:04:59All right.
- 1:04:59Beautiful.
- 1:05:00Well, Tom, this has been a lot of fun to talk about all these API ideas and also the funding
- 1:05:05stuff was really interesting.
- 1:05:06Thanks for being on the show.
- 1:05:07Great.
- 1:05:07Thank you so much, Mike.
- 1:05:09Have a great day.
- 1:05:10You bet.
- 1:05:10Yeah, you too.
- 1:05:11Bye.
- 1:05:12This has been another episode of Talk Python To Me.
- 1:05:15Today's guest was Tom Christie.
- 1:05:17And this episode was brought to you by Linode and Rollbar.
- 1:05:21Linode is bulletproof hosting for whatever you're building with Python.
- 1:05:25Get your four months free at talkpython.fm/Linode.
- 1:05:29Just use the code Python17.
- 1:05:32Rollbar takes the pain out of errors.
- 1:05:35They give you the context and insight you need to quickly locate and fix errors that
- 1:05:40might have gone unnoticed until your users complain, of course.
- 1:05:43As Talk Python To Me listeners, track a ridiculous number of errors for free at rollbar.com slash
- 1:05:49talkpythontome.
- 1:05:50Are you or a colleague trying to learn Python?
- 1:05:53Have you tried books and videos that just left you bored by covering topics point by point?
- 1:05:57Well, check out my online course, Python Jumpstart by Building 10 Apps at talkpython.fm slash
- 1:06:03course to experience a more engaging way to learn Python.
- 1:06:06And if you're looking for something a little more advanced, try my Write Pythonic Code course
- 1:06:11at talkpython.fm/pythonic.
- 1:06:13Be sure to subscribe to the show.
- 1:06:16Open your favorite podcatcher and search for Python.
- 1:06:18We should be right at the top.
- 1:06:19You can also find the iTunes feed at /itunes, Google Play feed at /play, and
- 1:06:25direct RSS feed at /rss on talkpython.fm.
- 1:06:29Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.
- 1:06:34Corey just recently started selling his tracks on iTunes, so I recommend you check it out at
- 1:06:38talkpython.fm/music.
- 1:06:40You can browse his tracks he has for sale on iTunes and listen to the full-length version
- 1:06:45of the theme song.
- 1:06:47This is your host, Michael Kennedy.
- 1:06:49Thanks so much for listening.
- 1:06:50I really appreciate it.
- 1:06:51Smix, let's get out of here.
- 1:06:53Smix, let's get out of here.
- 1:06:53Outro Music.
- 1:07:14you
- 1:07:15Bye.
- 1:07:15you
- 1:07:16you