video_id
stringlengths
11
11
text
stringlengths
361
490
start_second
int64
0
11.3k
end_second
int64
18
11.3k
url
stringlengths
48
52
title
stringlengths
0
100
thumbnail
stringlengths
0
52
JgvyzIkgxF0
this demo I think is a very important one it basically says that the robots we've been building for decades now are physically perfectly capable of doing a wide range of useful tasks but the problem is that we can't embed them with the needed intelligence to do those things so basically creating useful state-of-the-art robotics is a software challenge and not a hardware problem and
90
113
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=90s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
so it turns out that having a robot learn how to do something very simple like picking up a bottle of beer can be a very challenging task and so in this video I want to introduce you guys to the whole subfield in machine learning that's called reinforcement learning which i think is one of the most promising directions to actually get to very intelligent robotic behavior so in the most common
113
135
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=113s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
machine learning applications people use what we call supervised learning and this means that you give an input to your neural network model but you know the output that your model should produce and therefore you can compute gradients using something like the back propagation algorithm to train that network to produce your outputs so imagine you want to train a neural
135
153
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=135s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
network to play the game of pong what you would do in a supervised setting is you would have a good human gamer play the game of pong for a couple of hours and you would create a data set where you log all of the frames that that human is seeing on the screen as well as the actions that he takes in response to those frames so whatever is pushing the up arrow or the down arrow and we can
153
174
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=153s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
then feed those input frames through a very simple neural network that at the output can produce two simple actions it's either going to select the up action or the down action and by simply training on the data set of the human gameplay using something like back propagation we can actually train that neural network to replicate the actions of the human gamer but there are two
174
193
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=174s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
significant downsides to this approach so on the one hand if you want to do supervised learning you have to create a data set to train on which is not always a very easy thing to do and on the other hand if you train your neural network model to simply imitate the actions of the human player well then by definition your agent can never be better at playing the game of pong than that human
193
213
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=193s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
gamer for example if you want to train a neural net to be better at playing the game of gold and the best human then by definition we can't use supervised learning so is there a way to have an agent learn to play a game entirely by itself well fortunately there is and this is called reinforcement learning so the framework and reinforcement learning is actually surprisingly similar to the
213
235
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=213s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
normal framework in supervised learning so we still have an input frame we run it through some neural network model and the network produces an output action we either up or down but the only difference here is that now we don't actually know the target label so we don't know in any situation whether we should have gone up or down because we don't have a data set to train on and in
235
256
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=235s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
reinforcement learning the network that transforms input frames to output actions is called the policy Network now one of the simplest ways to train a policy network is a method called policy gradients so the approach in policy gradients is that you start out with a completely random network you feed that network a frame from the game engine it produces a random up with action you know either up
256
280
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=256s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
or down you send that action back to the game engine and the game engine produces the next frame and this is how the loop continues and the network in this case it could be a fully connected network but you can obviously apply convolutions there as well and now in reality the output of your network is going to consist of two numbers the probability of going up and the probability of going
280
298
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=280s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
down and what you will do while training is actually sample from the distribution so that you're not always going to repeat the same exact actions and this will allow your agent to sort of explore the environment a bit randomly and hopefully discover better rewards and better behavior now importantly because we want to enable our agent to learn entirely by itself the only feedback
298
319
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=298s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
that we're gonna give it is the scoreboard in the game so whenever our agent manages to score a goal it will receive a reward of +1 and if the opponent scored a goal then our agent will receive a penalty of minus 1 and the entire goal of the agent is to optimize its policy to receive as much reward as possible so in order to train our policy network the first thing we're
319
340
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=319s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
gonna do is collect a bunch of experience so you're just gonna run a whole bunch of those game frames through your network select random actions feed them back into the engine and just create a whole bunch of random pong games and now obviously since our agent hasn't learned anything useful yet it's gonna lose most of those games but the thing is that sometimes our agent might
340
359
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=340s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
get lucky sometimes it's going to randomly select a whole sequence of actions that actually lead to scoring a goal and in this case our agent is going to receive a reward and a key thing to understand is that for every episode regardless of whether we want a positive or a negative reward we can already compute the gradients that would make the actions that our agents has chosen
359
382
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=359s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
more likely in the future and this is very crucial and so what policy gradients are going to do is that for every episode where we've got a positive reward we're going to use the normal gradients to increase the probability of those actions in the future but whenever we got a negative we're gonna apply the same gradient but we're gonna multiply it with minus one
382
404
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=382s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
and this minus sign will make sure that in the future all the actions that we took in a very bad episode are going to be less likely in the future and so the result is that while training our policy network the actions that lead to negative rewards are slowly going to be filtered out and the actions that leads to positive rewards are going to become more and more likely so in a sense our
404
426
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=404s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
agent is learning how to play the game of pong now I know this was a very quick introduction to reinforcement learning so if you want to read up a bit and spend a little bit more time in thinking about the details I really recommend to read and rake carpet these blog post pong from pixels it does a phenomenal job at explaining all the details all right so we can use
426
446
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=426s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
policy gradients to train a neural network to play the game of pong that's amazing right well yes it is but as always there are a few very significant downsides to using this methods let's go back to pong one more time so imagine that your agent has been training for a while and it's actually doing a pretty decent job at playing the game of pong it's bouncing the ball back and forth
446
466
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=446s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
but then at the end of the episode it makes a mistake it lets the ball through and it gets a negative penalty so the problem with policy gradients is that our policy gradient is going to assume that since we lost that episode all of the actions that we took there must be bad actions and is going to reduce the likelihood of taking those actions in the future but remember that actually
466
489
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=466s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
the most part of that episode we were doing really well so we don't really want to decrease the likelihood of those actions and in reinforcement learning this is called the credit assignment problem it's where if you get a reward at the end of your episode well what are the exact actions that led to that specific reward and this problem is entirely related to the fact that we have what we
489
510
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=489s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
call a sparse reward setting so instead of getting a reward for every single action we only get a reward after an entire episode and our agent needs to figure out what part of its action sequence we're causing the reward that it eventually gets so in the case of punk for example our agent should learn that it's only the actions right before it hits the ball that are truly
510
531
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=510s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
important everything else once the ball is flying off it doesn't really matter for the eventual reward and so the result of this sparse reward setting is that in reinforcement learning algorithms are typically very sample inefficient which means that you have to give them a ton of training time before they can learn some useful behavior and I've made a previous video to compare
531
550
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=531s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
the sample efficiency of reinforcement learning algorithms with human learning that goes much deeper into why this is the case and now it turns out that in some extreme cases the sparse reward setting actually fails completely so a famous example is the game Montezuma's Revenge where the goal of the agent is to navigate a bunch of ladders jump over a skull grab a key and then actually
550
571
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=550s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
navigate to the door - in order to get to the next level and the problem here is that by taking random actions your agent is never gonna see a single reward because you know the sequence of actions that it needs to take to get that reward is just too complicated it's never gonna get there with random actions and so your policy gradient is never gonna see a single positive reward so it has no
571
592
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=571s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
idea what to do in the same case applies to robotic control where for example you would like to train in robotic arm to pick up an object and stack it onto something else well the typical robot has about seven joints that it can move so it's a relatively high action space and if you only give it a positive reward when it's actually successfully stacked a block
592
612
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=592s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
well by doing random exploration it's never gonna get to see any of that reward and I think it's important to compare this with the traditional supervised deep learning successes that we get into something like computer vision for example so the reason computer vision works so well is that for every single input frame you have a target label and this lets you do very
612
632
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=612s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
efficient gradient descent with something like back propagation whereas in a reinforcement learning setting you're having to deal with this very big problem of sparse reward setting and this is why you know computer vision is showing some very impressive results while something is simple as stacking one block onto another seems very difficult even for state-of-the-art woodland
632
652
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=632s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
[Music] and so the traditional approach to solve this issue of sparse rewards has been the use of rewards shaping so reward chipping is the process of manually designing a reward function that needs to guide your policy to some desired behavior so in the case of montezuma's revenge for example you could give your agent a reward every single time it manages to avoid the skull or reach the
652
680
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=652s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
key and these extra rewards will guide your policy to some desired behavior and while this obviously makes it easier for your policy to converge to desired behavior there are some significant downsides to reward shaping so firstly reward shaping is a custom process that needs to be redone for every new environment you want to train a policy so if you're looking at the benchmark of
680
701
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=680s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
Atari for example well you would have to craft a new reward function for every single one of those games that's just not scalable the second problem is that we Ward shaping suffers from what we call the alignment problem so it turns out that reward shaping is actually surprisingly difficult in a lot of cases when you when you shape your reward function your agent will find some very
701
721
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=701s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
surprising way to make sure that it's getting a lot of reward but not doing at all what you wanted to do and in a sense the policy is just overfitting to that specific reward function that you designed while not generalizing to the intended behavior that you had in mind and there's a lot of funny cases where reward shaping goes terribly wrong so here for example the agent was trained
721
742
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=721s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
to do jumping and the reward function was the distance from its feet to the ground and what this agent has learned is to simply grow a very tall body and do some kind of a backflip to make sure that its feet are very far from the ground to give you one final idea of how hard it can be to the reward shaping I mean look at this shaped reward function for a robotic control task I don't even
742
763
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=742s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
want to know how long the people from this paper spent on designing this specific reward function to get the behavior that they wanted and finally in some cases like alphago for example by definition you don't want to do any reward shaping because this will constrain your policy to the behavior of humans which is not exactly optimal in every situation so the situation that
763
784
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=763s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
we're in right now is that we know that it's really hard to train in a sparsely setting but at the same time it's also very tricky to shape a reward function and we don't always want to do that and to end this video I would like to note that a lot of media stories picture reinforcement learning as some kind of a magical AI sauce that lets the agent learn on itself or improve upon its
784
805
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=784s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
previous version but the reality is that most of these breakthroughs are actually the work of some of the brightest minds alive today and there's a lot of very hard engineering going on behind the scenes so I think that one of the biggest challenges in navigating our digital landscape is discerning truth from fiction in this ocean of clickbait that is powered by the advertisement
805
826
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=805s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
industry and I think the Atlas robot from Boston Dynamics is a very clear example of what I mean so I think if you go out on the streets and you ask a thousand people with the most advanced robots today are well they would probably point to Atlas from Boston Dynamics because everybody has seen the video where it does a backflip but the reality is that if you think about
826
845
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=826s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
what's what Boston Dynamics is actually doing well it's very likely that there's not a lot of deep learning going on there if you look at their previous papers in the research track record well they're they're doing a lot of very advanced robotics don't get me wrong but there's not a lot of self driven behavior there's not a lot of intelligent decision-making going on in
845
863
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=845s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
those robots so don't get me wrong Boston Dynamics is a very impressive robotics company but the media images they've created might be a little bit confusing to a lot of people that don't know what's going on behind the scenes but nonetheless if you look at the progress of research that is going on I think we should not be negligible of the potential risks that these technologies
863
883
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=863s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
can bring so I think it's very good that a lot more people are getting involved in the whole a AI safety research because this is going to become very fundamental threats like autonomous weapons and mass surveillance are to be taken very seriously and so the only hope we have is that international law is going to be somewhat able to keep up with the rapid progress we see in
883
902
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=883s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
technology but on the other hand I also feel like the media is focusing way too much on the negative side of these technologies simply because people fear what they don't understand and well fear sells more advertisement than utopias so I personally believe that most if not all technological progress is beneficial in the long run as long as we can make sure that there
902
923
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=902s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
are no monopolies that can maintain or enforce their power with the malignant use of AI well anyway enough politics for one video so this video was an introduction into deep reinforcement learning and an overview of the most challenging problems that we're facing in the field in the next video I will dive into some of the most recent approaches that try to tackle these
923
942
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=923s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
JgvyzIkgxF0
problems of sample efficiency and the sparse reward setting so specifically I will cover a few technical papers dealing with approaches like auxilary or reward settings intrinsic curiosity hindsight experience replay and so on I've also seen that a few people have chosen to support me on patreon for which I would just like to say thank you very much I mean it really means a big
942
963
https://www.youtube.com/watch?v=JgvyzIkgxF0&t=942s
An introduction to Reinforcement Learning
https://i.ytimg.com/vi/J…axresdefault.jpg
F0CBkT0UVWE
[Music] so hi everyone uh i am glad to have to have a chance to give this talk to you today uh so as dragon already mentioned uh the title is api design uh tips and uh introduction into building the apis uh so thinking about this topic uh uh it's in this talk it's it will not be a matter of uh talking about one correct approach uh as uh there are many good ones
0
48
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=0s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
uh the goal is stop is to talk about the ideas and thought process and how you can use those when designing and thinking about uh apis uh the talk will not cover the whole topic because uh this is a very very big area to talk about uh so i will uh focus on some of the selected areas that i found in my experience to be the most available when thinking about the api
48
73
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=48s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
design examples shown in this stock are inspired by real life uh some of which are simplified or adjusted to fit the format of this talk first let me let me introduce myself to you as dragon already mentioned my name is allen i'm a deputy cto and team leader of architecture team at decoder i've been building web apps and apis for a very long time now i've been building json api powered
73
103
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=73s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
projects for the past five years i'm doing talks training workshops and educations as part of my daily work let me talk about a little bit about our company so three coder is a company based in zagreb croatia and we employ uh developers uh uh on premise and remote also from uh some uh neighboring countries uh we are medium company with 65 employees out of which
103
130
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=103s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
50 are developers and engineers so we cover mobile front and back and data science ux and ui uh our main project is uh nuscolo it's a classified platform which is number one in oh sorry do you see it now ah okay yeah sorry there was a miss in the shires uh okay uh so we have a uh our main project is a new scholar uh it's number one uh platform in croatia and uh also in slovenia
130
166
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=130s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
and we are always open to hire uh new colleagues so feel free to check out our website for more information uh on to the topic so uh when we talk about the apis uh uh depending on your technical background uh the api can uh mean several different things so let's try to clear up uh this definition first so uh in our definition apis uh is something that enables
166
192
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=166s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
application to communicate with one another uh this can be either uh server to server a client application or some other service that you are building so a well designed api should reflect the goals of business and it's designed to serve that purpose the idea here where will talk about is uh web apis but the ideas and thoughts are also applicable to other areas as well
192
218
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=192s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
uh so when talk about uh talking about the web apis we need to mention uh restful apis uh so it's an architectural style for uh building distributed systems based on hyper media and it's not necessarily just implying uh http uh so web apis is what we will talk about today a couple of things to mention here uh web is usually a stateless request model using http and the http requests should
218
250
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=218s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
be independent of each other and may occur in any order uh this is something when uh thinking about the how we will model our uh endpoints so uh why we use apis uh so apis are used to build uh webs to build for other web servers or client consumers such as web browser mobile application uh outside services uh one thing that we can also uh usually imply its communication is
250
280
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=250s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
done using http protocol in some text formats most preferably json or xml so before we dive into the apis we can also talk about the design world design world itself can have several meanings and one definition that i found very useful is design is a set of decisions with the goal to define the look and functionality of the topic that you are designing uh so
280
310
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=280s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
it's a simple but valuable definition that can help us understand when we talk about the design so uh what does this mean in a sense of api design so uh api design is a process of developing uh interfaces for exposing our functionality or data to other applications as such a good api design takes into consideration organization specific strengths uh and uh limitations in terms of
310
341
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=310s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
budgets personal skills and technical uh infrastructure so i said here we need to think about also the technical approach but also take into account the consumers and our business that we are trying to support here uh one thing that we uh often uh come into across in our experience when talking about the api design is uh when people disagree on design it's often they don't agree on the goals and
341
368
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=341s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
in my experience this is one of the very important notes to have in your head so because a lot of times the discussions is about the design but we need to consider uh what what is our goal uh so for example if there is a disagreement that the current design is not future proof for the next five to ten years uh but our goal is to deliver some short-lived feature
368
391
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=368s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
then this discussion is not needed because it's not our goal we are delivering something that has a shelf life and uh very often in our uh in our area of work uh our solutions have a shelf life because we are always thinking about how to upgrade them so when talking about the design a good design can be broken down into three main aspects those are purpose usability
391
415
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=391s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
and constraints uh so a purpose part uh as we mentioned in the previous slides uh is about fulfilling the business goals about getting the right information uh to the right side uh usability and constraints this again can be also covered depending on your technology stack and standards you could already have this covered with some standard that you use so for example in recorder we use a json
415
442
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=415s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
api standard which i'll mention later in the talk and also give some examples and this helped us a lot to really think about the important stuff and not to worry about conventions and similar so to summarize what is the api responsibilities it's to provide the data and functionality to successfully complete a business goal uh that business goal can be a sale a
442
468
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=442s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
conversion a technology related data exchange anything that you are trying to cover one also uh interesting uh thought to have is i think everyone here some variation of this is uh good solutions have strong foundations uh so when thinking about the api design uh there is a way that i can actually try to visualize this so looking at our solution we built a solution to fulfill some
468
496
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=468s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
requirements and to meet those requirements there can usually be three main pillars for building the solution so one is a client pillar one is a api pillar and one is a backend pillar again we are talking about the web concept here uh so when each of these pillars are strong we are happy and prosperous and the success is when all of them all the three pillars are working
496
522
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=496s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
towards a common goal instead of working towards the goal of one pillar uh so looking at the example for uh in the relationship between the client and the api uh there might be a case where our client needs uh the whole home page for its app in one request and this is something that usually in the api we don't think about like this or for example we have an article and the article has
522
552
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=522s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
an image so depending on the client we can do it either sending a url or we can have some complex resources additional logic behind it looking at the api and the backend relationship this is where usually things get a bit more complex in and it involves a lot of more work so sometimes an api can copy copy uh backend implementation one to one so we have the same data models we have the
552
578
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=552s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
same attributes uh and this can be a good start um but often uh because if we already know the backend implementation we can be biased towards the design of our api and this is uh this can sometimes limit our solution space so if we approach the api design isolated from the back end so not thinking about how the backend is implemented we can sometimes come up with a really
578
604
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=578s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
great designs that work uh well uh so for example if in your backend system you have a document revision system but on the api you only need to serve the latest version of the document there might actually be no need to show all this revision system in your apis so when looking at these three pillars if the pillars are too affected by each other our construction can become fragile and
604
632
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=604s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
unbalanced uh we can become coupled to the dynamic of these solutions uh so for example if our client is doing uh ui redesign and we need to change uh modify the apis because of it despite the data set being the same this can be an indicator that we are too coupled to the client or if a back end is doing some uh refactoring or optimizations and it requires us to
632
657
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=632s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
change our api again we are too coupled uh with uh with the back end again as this is the talk about the api so i will focus now more about the api itself uh so uh when thinking about the apis one thing that we can also try to test is okay how will it serve multiple clients does it need to serve multiple clients uh will it be served to multiple back ends uh how will the filtering down how would
657
686
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=657s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
the format done so there can be a lot of questions raised what we try to do is simplify and focus on the content instead of form so we should focus on what what kind of data what the data api provides and not how uh when we talk about how uh we usually think about the formats the structures uh and communication uh so this should not be our primary focus so imagine a world where everyone knows
686
718
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=686s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
what your apis work uh how your apis work and you just need to tell them what kind of data you are uh serving from it so as i mentioned before in recorder we use json api to help us with this uh what json api provides is uh enables us to stop worrying about the structure and covers a lot of frequent questions that we might find uh so uh json api removes for us the needs
718
748
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=718s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
to invent things uh that we don't need to reinvent uh the json api itself is a resource oriented api uh they do have a uh really well well written uh specification so i would suggest uh if you're interested to take a look at it and i'll go over a quick overview of uh basic features of the json api so uh looking at it so this is a basic structure or resource uh it combined it constrained it is
748
778
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=748s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
comprised of the type so usually some kind of type describing the resource the id of the resource and some attributes uh like a real world example let's see an article so we would have an article uh with an id1 and a title and the body of the article and uh so when we think about okay so i have an article i might need to uh see an author of the article so this is
778
802
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=778s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
done using the relationships so we can define a relationship and say okay relationship to this article is an author with a type of people so it gets pretty easy again thinking about okay i know the id of the user it would be great if i have this user included uh in my resource so again i can just simply have it included uh in the main response so again this is the response from from the main
802
828
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=802s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
endpoint if we need a relationship of a relationship yes the related resources are also resources so we can have a relationship and again using included we can include the relationship of that uh we can include the resource of that relationship as well so we can get the article the author and the thumbnail used uh to show this out um it looks beautiful uh so to summarize what what the json api
828
858
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=828s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
provides us that we don't need to think about so it provides us with client responsibilities it provides us a definition of service server responsibilities it defines a document structure uh it provides a fetching of resources and relationships and it provides a sparse field set so we can just have a selected set of data instead of the complete resources in addition it also provides us a
858
884
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=858s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
definition how how sorting can be done pagination filtering uh it provides a full crowd operation so it describes how we can create resources updated uh uh updaters relationships delete the resources uh and it also provides a standardized uh errors uh so again it's a it's a nicely written specification uh if you're not familiar with it feel free to check it out
884
914
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=884s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
so now that we covered uh some of the definition and some of the thought process uh we can dive into the example because there is a lot of good things to go over uh so first example first use case we have here is a user illustration i think that everyone has once in their life of development uh met with some kind of huge registration so let's look at our uh requirements so
914
939
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=914s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
we have a requirement that says that we have a mobile app mobile and web apps so we have two clients uh that have two-step registration in step one the user enters his username email and password and in the step two it enters additional personal information like uh name surname or a phone number so uh when we think about the api design how would we solve this uh well
939
966
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=939s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
there's actually a trick about it we don't so uh we ask the clients hey this is not our problem uh so from the api design perspective we enabled it uh what this means so uh we separate the work so client is responsible for covering the steps and the api needs to provide a way to validate and complete the registration process so we would serve an endpoint to validate
966
992
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=966s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
or verify the user enter data and we would uh serve an endpoint for uh process of registration itself if we look at the resource how would our resource look like so we would have a resource of the type user again this is just the name we can call it user we can call it uh a guest a person a buyer depending on your uh business uh business language and we would have some attributes uh for
992
1,021
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=992s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
example username password uh first name and last name uh so if you've ever done a registration uh there is another example we can mention here uh usually when you ask for the password you also it's a good practice to have a repeated password just in case the user misses or types it wrong so again this is something that we shouldn't do on the uh api level it should be done by the
1,021
1,047
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1021s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
client itself so the client can verify that two passwords are the same and just send us the password again if we want to think about it differently we can probably define the registration as a process of sending a registration request to create the user and then we can model our uh resource as such so we could have a resource that is type uh registration request
1,047
1,074
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1047s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
with the same attribute so we would have uh username password uh last firstnamelastname and then when we think about it okay so i send a request for registration and when i get a success response uh we can have the created user as in relationship so we can have additional relationship which is a user of type user so for any fans of the rpcs this is one option how you can do it when you use
1,074
1,104
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1074s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
json api what endpoints should we provide so we need an endpoint for uh creating of the user so for a resource and we provide additional endpoint for validation uh validation and can have a response okay if the validation is correct or a conflict or some kind of custom error and if we look at the other example for registration it could be a similar so we send have a registration endpoint and
1,104
1,135
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1104s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
registration validate endpoint okay next next use case is classified so to help with anyone who is not familiar with the term classified is a business for uh selling of uh online uh like for example an ebay uh in our case we work for a creation a platform called new scholar the items that you're selling are usually called a posting or a listing sometimes ad and this use case will be example of uh
1,135
1,170
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1135s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
evolution of the design as we get more knowledge additional requirements and to get more familiar with the topic that we are covering so uh first requirement is we need to serve the list of uh posted listings uh sounds simple enough so we would create a resource called listing and our listing would have a basic attributes of title description price and when it
1,170
1,196
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1170s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
expires and it's a simple resource we can have a list of them and just serve the all the listings in the database but then we get additional requirement that says hey can you please please include uh seller information like his name and his contact information so uh again a simple so simple approach would be we just modified the existing listing uh with the title description pricing
1,196
1,222
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1196s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
expires on and we add a seller name and a seller contact phone it's a simple addition uh but this is where the design thought process starts to think so uh the seller data can also be separated into additional uh additional resources and it can be reused on other endpoints so we could do it as additional resource so we would have again our listing with existing
1,222
1,252
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1222s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
attributes and we would have a relationship to a call seller to a special type of resource and let's look at some examples so first example would be we can have a research type seller and then we can have an attribute called display name and content form it's it's a pretty simple one uh we can be a bit more uh descriptive so again we could have a seller but we could also
1,252
1,280
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1252s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
signify that the seller is actually a user so we would have a relationship to some existing user and in this case our consumers can get even more data about it but looking at this example we can also uh think about the third example is that relation to the seller is a user so we can just have a resource user and we can have his username and phone uh directly attached
1,280
1,304
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1280s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
uh with this example then we get a new uh requirement which says a mobile application needs to mark ads that are owned by currently logged in user uh and expand an additional data so thinking about this request how how can we uh solve it so if you remember the previous slide it sounds like a ui thing right well correct we could enable this so uh we provide the mobile application with the example
1,304
1,336
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1304s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
to get the current logged in user and then the mobile app can have a simple logic as hey if the classified seller id is the same as the login user this is the logged in user so no additional data is needed for uh for the api and this is one example where we could become coupled to the ui but again if we think about design if we think about the requirements define them
1,336
1,361
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1336s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
correctly define the goal we can already see that this solution exists in our system let's look at another use case so uh there is a requirement that says okay i as a user need to see my items so we need to enable a seller to see all of the listings that uh he has he's the author of uh so there are a couple of ways we can do this so one way uh look in the json api uh
1,361
1,388
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1361s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
perspective we could filter the classifieds list and say okay filter classified list where seller is x and the x can be an id of the logged in user again this is all up to the clients to figure out the logged in user another example can be that we can add a special identifier called me and in that case depending on the context of the request uh we can see okay who is the
1,388
1,417
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1388s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
user authenticated with this request oh we can then filter it uh for the client uh this is a bit more friendly to the clients but again it might be a bit more coupled to the to the client and to the back end uh pillars another way we can also create a special uh endpoint like classified me or uh we can also uh create uh in the users on the user relation to the classified
1,417
1,446
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1417s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
so that the user can filter all of the classifieds that are related to his user uh so again to notify here that uh me keyword is a special in this case and this is again very very specific to the implementation and a bit more coupled to the to the back end so this is something to take into with caution uh another use case let's look at the messaging so we have a
1,446
1,475
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1446s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
simple uh functionality where a couple of uh users for this example a seller and buyer can have a conversation on the item or listing so looking at the resource we could have a resource type conversation uh and we have participants so we can have the attributes of when the uh conversation is created and then we can have a relationship to a uh classified so this is the item
1,475
1,503
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1475s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
that we are discussing about uh the buyer and the seller so the the two users that are uh currently participants of this conversation so looking at this conversation can have also additional attributes but we could already maybe uh simplify this so we can have a conversation that has a seller and a buyer and both of them are specified the specific research types so we can sell
1,503
1,535
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1503s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
it with the type seller buyer with the type buyer but also we can reuse them because looking at both of these user types they can be type of user so we reduce the number of special resources that we have another example another design choice that we can do here looking at the conversation example is that we can have a classified so we have a item that they're discussing
1,535
1,563
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1535s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
and we also have a seller but we already know the seller from the classified so we can uh say that uh seller is uh redundant because we can just say hey give me the seller of the class right so again design choice that we can simplify the endpoint by complicating the job for the client it's a design choice in this case it's really hard to say which one of the two is better
1,563
1,589
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1563s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
now that we have a conversation we also need to have some conversation messages uh again here is some we can have a resource type message and then we can have a design choice do we group the messages into conversations or we connect them directly to the participants so for example we would have a message that has a content it has a sent on and it has uh is read it's always read
1,589
1,615
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1589s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg
F0CBkT0UVWE
by the recipient uh and then we can have a relationship that says okay it's part of the conversation x it has a sender and it has a recipient looking at this maybe we can find uh some redundancies because in the conversation we only need the sender and the recipient is the other party in the conversation so we can probably uh move this and also when we think
1,615
1,643
https://www.youtube.com/watch?v=F0CBkT0UVWE&t=1615s
API Design - Getting Started—Alen Pokos
https://i.ytimg.com/vi/F…axresdefault.jpg