Fireship · @fireship

How Tom Scott & Mr. Beast use APIs to update their videos programmatically

Uploaded May 25, 2020 · Length 8:53

How Tom Scott & Mr. Beast use APIs to update their videos programmatically

Summary

Tom Scott and Mr. Beast use APIs to update their YouTube videos programmatically, teaching how to work with Google APIs, Node.js, and schedule background jobs.

  • api updates youtube videos
  • tom scott mr beast
  • google api nodejs
  • background jobs cloud functions
  • api authentication oauth

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    today on how they do it if you watch my

  2. 0:01

    youtube channel there's a good chance

  3. 0:03

    you've already seen Tom Scott's video

  4. 0:04

    this video has X amount of views if not

  5. 0:07

    check it out

  6. 0:07

    but basically what he does is run a

  7. 0:09

    background job that hits the YouTube API

  8. 0:11

    to update the title with the latest view

  9. 0:13

    count every few minutes then another

  10. 0:14

    youtuber you may have heard of mr. beast

  11. 0:16

    appears to be doing the same thing in

  12. 0:17

    his latest video where the thumbnail

  13. 0:19

    updates every few minutes with the

  14. 0:20

    amount of money given away if you're

  15. 0:22

    wondering how to do this you might be a

  16. 0:23

    little disappointed when Tom Scott says

  17. 0:25

    I'm not gonna talk about the exact

  18. 0:26

    details of my code here it is not the

  19. 0:28

    important part because code is just

  20. 0:30

    incredibly dull on camera but I have to

  21. 0:33

    disagree there because in my opinion if

  22. 0:34

    the code is the most exciting part so in

  23. 0:36

    today's video we'll take a deep dive

  24. 0:37

    into api's and i'll show you exactly how

  25. 0:39

    these youtubers are updating their

  26. 0:41

    videos automatically in the background

  27. 0:42

    if you're new here like and subscribe

  28. 0:44

    and you can grab the full source code

  29. 0:45

    from github my primary mission today is

  30. 0:47

    to teach you everything you need to know

  31. 0:48

    about api's which is an essential skill

  32. 0:50

    for both front-end and back-end

  33. 0:51

    developers along the way you'll learn

  34. 0:53

    about API authentication and oaah

  35. 0:55

    - how to work with Google API s and

  36. 0:57

    nodejs and how to schedule your code to

  37. 1:00

    run in the background with a service

  38. 1:01

    cloud function but first let's answer

  39. 1:03

    the question what is an API an

  40. 1:05

    application programming interface is

  41. 1:07

    simply a way for two pieces of software

  42. 1:09

    to talk to each other in this demo we

  43. 1:11

    have our application which will

  44. 1:12

    eventually live on a cloud function it

  45. 1:14

    needs to talk to YouTube to get the view

  46. 1:16

    count for a video and then tell YouTube

  47. 1:17

    to update the video with a new title to

  48. 1:20

    facilitate this YouTube has a standard

  49. 1:21

    set of functions where developers can

  50. 1:23

    request the data they need on the web

  51. 1:25

    api's are accessed over HTTP or in other

  52. 1:28

    words there's a URL on the internet that

  53. 1:30

    connects that server to the rest of the

  54. 1:32

    Internet the most popular standard for

  55. 1:33

    implementing API is in today's world is

  56. 1:35

    rest which stands for representational

  57. 1:37

    state transfer API is that implement the

  58. 1:39

    standard like YouTube are called restful

  59. 1:41

    api is the most important concept to

  60. 1:43

    understand is that restful api s are

  61. 1:45

    stateless which means the client and the

  62. 1:47

    server don't need to know anything about

  63. 1:49

    each other's internal state instead they

  64. 1:51

    simply pass messages back and forth the

  65. 1:53

    process starts when the client your

  66. 1:55

    application makes a request an HTTP

  67. 1:58

    request message has a very specific form

  68. 1:59

    at the start line contains the URL of