Working with APIs in Python [For Your Data Science Project]

Поделиться
HTML-код
  • Опубликовано: 7 июн 2024
  • We’re going to be working with the RUclips API to collect video statistics from my channel using the requests python library to make an API call and save it as a pandas dataframe. Working with APIs is a necessary skillset for all data scientists and should be incorporated into your data science projects. I talk about the one data science project you’ll ever need in this video bit.ly/3rEt6WG so we’ll start with the first step and learn how to work with APIs in python to collect our data.
    The python notebook and links to resources are located in this Github repo: github.com/Strata-Scratch/api...
    Link to the video referred to in the Intro: • The One and Only Data ...
    ______________________________________________________________________
    👉 Subscribe to my channel: bit.ly/2GsFxmA
    👉 Playlist for more data science interview questions and answers: bit.ly/3jifw81
    👉 Playlist for data science interview tips: bit.ly/2G5hNoJ
    👉 Practice more real data science interview questions: platform.stratascratch.com/co...
    ______________________________________________________________________
    Timeline:
    Intro: (0:00​​​​)
    Coding on Google Colab: (2:00​​​​)
    Testing with the Requests Library: (4:16​​​​)
    Working with the RUclips API: (6:32​​​​)
    Response from Making API Call: (11:00​​​​)
    Data is in the 'items' Key: (12:22​​​​)
    Parsing through the Data: (12:57​​​​)
    Creating the Loop: (16:17​​​​)
    Making a Second API Call: (18:30​​​​)
    Saving to a Pandas DataFrame: (20:31​​​​)
    Implementing Good Software Engineering Fundamentals: (22:40​​​​)
    Conclusion: (27:03​​​​)
    ______________________________________________________________________
    If you want data science interview practice with real data science interview questions, visit platform.stratascratch.com/co.... All questions are free and you can even execute SQL and python code in the IDE, but if you want to check out the solutions from me or from other users, you can use ss15 for a 15% discount on the premium plans.
    ______________________________________________________________________
    Contact:
    If you have any questions, comments, or feedback, please leave them here!
    Feel free to also email me at nathan@stratascratch.com
    ______________________________________________________________________
    #PythonAPI

Комментарии • 235

  • @jaggyjut
    @jaggyjut 3 года назад +152

    After a lot of search, I finally found this tutorial which shows how to get data from an API and then convert the json into a dataframe. This is pure gold. Thank you

    • @stratascratch
      @stratascratch  3 года назад +9

      You wouldn't have thought it would take so long to find a video that does? =) glad you found this channel.

    • @jaggyjut
      @jaggyjut 3 года назад +4

      @@stratascratch there are tutorial on how to use API and then different tutorials on converting json to data frame. So far haven’t found a tutorial showing everything end to end.😀

    • @purvilimbachiya1501
      @purvilimbachiya1501 Год назад

      what is the next step after importing a database??

    • @vijaykumarcn8425
      @vijaykumarcn8425 11 месяцев назад

      How about applying read_json method ?

  • @Thuvu5
    @Thuvu5 2 года назад +18

    Hi Nate, thank you for this great video! Just a quick tip, if any wants to grab the video data for multiple channel IDs at once you can directly use this method (from RUclips API doc): request = youtube.channels().list(
    part='snippet,contentDetails,statistics',
    id=','.join(channel_ids))
    response = request.execute()
    where channel_ids is a list of channel ids (e.g ['id_1', 'id_2', 'id_3'']
    and youtube = build('youtube', 'v3', developerKey=api_key)

  • @clockfixer5049
    @clockfixer5049 2 года назад +1

    Incredible how concisely this whole topic can be presented. Happy to very soon become a StrataScratch subscriber.

  • @sitanshumishra6468
    @sitanshumishra6468 2 года назад +2

    Thanks Nate, this is the next level of simplifying a so called complex issue related to an API

  • @grimoireen
    @grimoireen 2 года назад

    Wow, you're really give a huge knowledge for data science projects for free, big thanks man

  • @Davidkiania
    @Davidkiania 2 года назад

    What I love most about your content is how you simplify the building process and then refactoring …. I am hooked.

  • @vinutnasai584
    @vinutnasai584 2 года назад +2

    Very good and easily understandable educational video! Thanks Nate, for making the tech stuff interesting as well !

  • @menchu56
    @menchu56 2 года назад +2

    As a beginner, this really helps me understand how to work with JSON files and API calls. Thanks for the great content!

  • @mazhar0001
    @mazhar0001 2 года назад

    Covered all the basic and important points is a well structured manner to make it simple enough to follow and understand.
    You have great teaching skills! Thank you for spreading your knowledge.

  • @prateek2159
    @prateek2159 2 года назад +30

    Hey Nate, your videos are just too good. I love how your channel is so dedicated towards real word data science. By the way I noticed that you started a video series, "For your Data Science Project" and I really want you to continue making videos for this particular series because there's literally no one on RUclips with such guidance on DS projects and I have been looking for one since a very long time because I have my placements just after 12 months and I really want to make a full stack data science project. Thank you.

  • @ivlivs.c3666
    @ivlivs.c3666 2 года назад

    Now this is real-world, practical knowledge. After watching your video on the one and only data science project you'll ever need, I knew I had found something amazing. After watching this one, I was sold. Just subscribed. Keep these gems coming!

  • @soumodeepsen3448
    @soumodeepsen3448 2 года назад

    This is probably the best video i watched so far on use of api in data science cause everywhere else the videos are so long and i could not understand a lot of those tutorials. Thank you so much for this video content.

  • @naanaaabdelmalek
    @naanaaabdelmalek 2 года назад +1

    I really wanna thank you so much cause those are the real skills that we need as entry-level data scientist, i'm an artificial intelligence student and everything they are teaching us is a pure academic which will not cover the practical side.

  • @joaofernandes6349
    @joaofernandes6349 Год назад +4

    The best part is how you show in a easy way how to do the whole process and then you clean up the code according to good practices. This was really good, thank you!

  • @hafsawajid2793
    @hafsawajid2793 2 года назад

    You are doing an amazing job. It is what's required to understand the programming side.

  • @bactran7799
    @bactran7799 2 года назад

    amazing tutorial. Thank you for your well organized video, your voice and everything you talk about are absolutely clear and help me easily to follow. Please keep your great works

  • @JMinster
    @JMinster 2 года назад

    Thank you so much for your videos, I just recently discovered this channel and it is amazing!

  • @sitiismi7231
    @sitiismi7231 2 года назад

    this video-storyboard on point. very clear, explain the scope and summarize. thank you!

  • @PATRICKCHUAD
    @PATRICKCHUAD 2 года назад

    Thank Nate for this very clear video on API. It is a great help for me as I'm studying python API , flask etc. right now.

  • @azamatbagatov4933
    @azamatbagatov4933 2 года назад

    This channel deserves million subscribers and views. Keep it up!

  • @cristiansoto7581
    @cristiansoto7581 Год назад

    More videos about this, please. Great information. I loved it!

  • @codehorror6743
    @codehorror6743 2 года назад

    the amount of knowledge in this one video!!!!!!!!!!
    God bless you

  • @matthewd4972
    @matthewd4972 4 месяца назад

    Really appreciate the tutorial, tremendously helpful getting my own api project started.

  • @czr372
    @czr372 Год назад

    I spend couple hours figuring out the url's and the api key, but this is a great help, Thanx a lot!

  • @69nukeee
    @69nukeee 7 месяцев назад

    AMAZING tutorial, thanks for sharing!

  • @CodyJelinek
    @CodyJelinek 3 месяца назад

    This is brilliant. I took way too much time searching and googling and watching hours long videos to find pretty much everything I need in a clear crisp straight forward 30min video. Minus a tiny bit of API beginner information and knowing the basics of Python, this was perfect. Well done. I imagine the next video will be everything I need and nothing that I don’t to take the next step of processing/analyzing the data. I am hitting play on that……. Now!

  • @avanishpank7572
    @avanishpank7572 2 года назад

    Ever since I started my data science learning journey,this might be the most valuable video I have come across,thanks a lot mate,this is extremely helpful.

  • @Delchursing
    @Delchursing Месяц назад

    Made more api progress today than with days of Internet and ai. Thank you. I love how pragmatic this video is.

  • @rohitprajapati2303
    @rohitprajapati2303 Год назад +1

    Amazing video ,finally get the understanding how to extract data from the API ,Thanks man

    • @stratascratch
      @stratascratch  Год назад

      I appreciate your feedback! Thank you too.

  • @javierjdaza
    @javierjdaza 3 года назад +1

    simple, short, and efective.
    Keep going bro, amazing content

    • @stratascratch
      @stratascratch  3 года назад

      Thanks so much for watching. Glad people like these python videos!

  • @guoyitang4001
    @guoyitang4001 2 года назад

    love your video! Clear explanation and straight to the point

  • @ellenycnyc
    @ellenycnyc 2 года назад

    Wow this helped so much! Super straightforward thanks!

  • @wwmmff
    @wwmmff 2 года назад

    Huge thanks! I really like your video. Systematic and clear in your explanation. hope your channel grows! subscribed!

    • @stratascratch
      @stratascratch  2 года назад

      Thanks for watching! And glad you found it educational!

  • @mariumbegum7325
    @mariumbegum7325 Год назад

    Fantastic tutorial, easy to follow and presented in a way that is easy to follow

  • @jackpeters1598
    @jackpeters1598 2 года назад

    Brilliant! Great explanation of the process.

  • @chiomaeze8245
    @chiomaeze8245 Год назад +1

    wow, this is amazing! Thank you so much. It was concise and robust. Learnt a lot from it

    • @stratascratch
      @stratascratch  Год назад

      You are welcome. Happy that you found our video helpful.

  • @procorepierre3124
    @procorepierre3124 2 года назад

    Thanks a million Nate for such a great content. You are an inspiration

  • @joelngige5776
    @joelngige5776 Год назад

    Super informative video on working with API's

  • @Networkprofessor
    @Networkprofessor Год назад +1

    I thought my video speed was on max, but it wasn't; there is just a lot of information being presented. Very comprehensive. Thank you.

    • @stratascratch
      @stratascratch  Год назад

      Thank you. We love to share what we know. Glad we have helped you.😀

  • @badsanta01
    @badsanta01 Год назад +4

    Thanks for the video Nate.
    Update : One might get an error in the dislike count part. "The statistics.dislikeCount property was made private as of December 13, 2021. This means that the property is included in an API response only if the API request was authenticated by the video owner. See the revision history for more information."

  • @sidechain0
    @sidechain0 Год назад

    Great tutorial, thanks!

  • @rajgopalmanoharan
    @rajgopalmanoharan 4 месяца назад +1

    This is an amazing session, thank you

  • @rolandr97
    @rolandr97 2 года назад

    I forgot to thank you in April: awesome, thanks!

  • @danielmoss7133
    @danielmoss7133 Год назад

    Best video I have seen on APIs. Thank you so much.

    • @stratascratch
      @stratascratch  Год назад

      Thank you! If there are other projects you're interested in, let me know!

  • @tuhindas6745
    @tuhindas6745 2 года назад +2

    I have been struggling to learn data science from multiple sources and there are hell lot of content.. After scavenging through the dirt pile, garbage of useless information. I can finally say that I have found the most valuable resource available on the internet !
    Thank you Nate ! I can finally see light at the end of the tunnel. Love from Delhi, India

    • @stratascratch
      @stratascratch  2 года назад +1

      Thank you for your kind words! More to come!

  • @jeh5842
    @jeh5842 2 года назад

    Thanks Nate for making this easy!!

  • @alirezakaramali1844
    @alirezakaramali1844 2 года назад

    It was very clear and useful. Thank you so much.

  • @stefano_er
    @stefano_er Год назад

    Thanks! Really appreciated it

  • @eulerthegreatestofall147
    @eulerthegreatestofall147 Год назад

    Great video!!!! very easy to follow through!

  • @luzestrada9536
    @luzestrada9536 Год назад +1

    You are the best! Thank you so much for sharing this valuable information

    • @stratascratch
      @stratascratch  Год назад

      Thank you. We are happy that we were able to help.

  • @awesomeGuss
    @awesomeGuss 2 года назад

    THANK YOUUU man...woow, love this

  • @supriya1316
    @supriya1316 2 года назад

    Thanks for your video . You make the things easy . Thanks a ton :)

  • @Paper-Z
    @Paper-Z 2 года назад

    You just gained a subscriber Bro 😃
    Nice content

  • @samchimaobi3398
    @samchimaobi3398 8 месяцев назад

    Thanks for this video. was really very helpful.

  • @poo872
    @poo872 3 года назад

    Perfect Explanations.
    Very useful.
    Thank you so much.

  • @adityaahire2743
    @adityaahire2743 2 года назад +13

    I cannot comprehend right words to express how great this video is and all the content that you create.
    For all those who dream, plan or wish to make great career in data science you are simply an angel.
    The most important part which I want to request is a complete playlist of all the components that you mentioned in the : "The one and only one Data Science Project you need".
    This video covers the data collection part through API...and if other components are covered and all together that playlist would become the gold mine for aspirants.
    I hope you get time from your busy schedule to consider my humble request...
    Thanks a lot for all your videos which keep enlightening the Data Science aspirants.🙏

    • @stratascratch
      @stratascratch  2 года назад +4

      Definitely will create this playlist or at least write an article that will provide you with resources for each part of this project journey. Thanks for the suggest. It's a great idea.

    • @alfatmiuzma
      @alfatmiuzma 2 года назад

      Next highly expected topic can be .. setting up cloud to store the data. We can have a playlist of videos on topics Nate mentioned in the end to end data science project 😊😊

  • @stainxyz3373
    @stainxyz3373 9 месяцев назад

    thanks. this thing took me an entire day to finish.

    • @stratascratch
      @stratascratch  9 месяцев назад

      I'm glad you did the project! It's a good one day project

  • @sajjad5345
    @sajjad5345 Год назад

    I love this playlist and look forward to seeing more videos in it.👍

  • @jiangchengli2191
    @jiangchengli2191 Год назад

    good work man, best tutorial of collecting data from api !!!!

  • @1cutecouple
    @1cutecouple Год назад

    THIS IS ABSOLUTE BLISS TO WATCH!!! THANKS FOR THE AWESOME CONTENT

    • @stratascratch
      @stratascratch  Год назад

      Glad you enjoy it!

    • @darkflamedoctor9023
      @darkflamedoctor9023 Год назад

      @@stratascratch now that we have collected the data how are we going to apply ml to this specific task(yt api) My Guess is we need little more info to predict something with good accuracy
      these are the things I thought for this data: I think we can cluster the video with less views or likes or something like that, one more thing I can think of is predicting views or likes with the help of regression models I cant think of anything else can u please tell me something else

  • @jzh4950
    @jzh4950 2 года назад

    Very helpful! thank you

  • @omginever
    @omginever 2 года назад

    this is pure gold!

  • @djjiang3718
    @djjiang3718 2 года назад

    Good stuff and Thank you Nate for sharing!

  • @saaqibmhd
    @saaqibmhd 2 года назад

    Love this tutorial!!

  • @mercantilism954
    @mercantilism954 Год назад

    Oh my god. Your video is a treasure

  • @ujjwaltarway1438
    @ujjwaltarway1438 Год назад

    One of the best videos regarding API call. Subscribed.😇😊

  • @kashifrana6798
    @kashifrana6798 7 дней назад

    Amazing content !

  • @zahedinima732
    @zahedinima732 2 года назад

    FANTASTIC tutorial!! What can possibly top this?

  • @soujanyamukkala1052
    @soujanyamukkala1052 Год назад

    Hello Nate, Nice Video, love it! I have a question here, instead of making a second API call for the stats, can we use fields parameter in the URL of the first API call to get the stats. Pardon me if I am not understanding the fundamentals properly. Thanks

  • @wombatwombaffle
    @wombatwombaffle 2 года назад

    Good work!!!

  • @kelechiasianya4496
    @kelechiasianya4496 2 года назад

    Your tutorials are cool

  • @alexwoodard2759
    @alexwoodard2759 Год назад

    good stuff, sir!

  • @inigocuervo
    @inigocuervo 9 месяцев назад +4

    Hey there! Just a quick tip for anyone trying out the code: make sure you're using a version of pandas earlier than 2.0. Otherwise, you might need to use a different method instead of .append, or consider adding the data to a Python list first and then converting it to a pandas dataframe. Hope this helps! 😊

    • @lme918
      @lme918 9 месяцев назад +1

      Even if you will use append method, it's strongly adviced do not use append as in his video as it's awful for performance. Don't do it!

  • @digigoliath
    @digigoliath 2 года назад

    Awesome!!! TQVM!!

  • @abhaytiwari6411
    @abhaytiwari6411 3 года назад

    Wonderfull video

  • @michelchaghoury870
    @michelchaghoury870 2 года назад

    i really like your content a lottt can you make more SQL and Databases vides (More Advanced) please and keep going

  • @shashibhushansingh1628
    @shashibhushansingh1628 Год назад

    Great👍

  • @ChrisMaringka
    @ChrisMaringka Год назад

    Hello Nate, thank you for sharing this tutorial I appreciate it! I just had one quick question about the second API calling: when I tried to call the statistics, every now and then one of the stats (viewCount, likeCount, dislikeCount, or commentCount) might be missing and I could not assign them into a variable. Do you by any chance know the work around for it? Thanks!

  • @konstantinpluzhnikov4862
    @konstantinpluzhnikov4862 2 года назад

    Good old days, you can see dislike_count for any video. Great tutorial, many thanks!

  • @ryandavis280
    @ryandavis280 2 года назад

    thank you!

  • @its_me7363
    @its_me7363 3 года назад +2

    Hi Nate, Thanks for making this video and I really enjoyed and learnt from this video. I have a question, do all big/medium companies/startup make their data public via API?

    • @stratascratch
      @stratascratch  3 года назад +3

      Hey! Thanks for watching. The next video is coming out in 1-2 weeks to close out the series. Sometimes companies make their data public but they usually won't make internal data like user engagement or financial stats public. But they usually do make whatever data you own or whatever is deemed public, accessible to all. Like Twitter has an API you can use to collect tweets because all the tweets are publicly accessible. Hope that helps.

  • @RememberQuranAlways
    @RememberQuranAlways Год назад +1

    Just Awesome

    • @stratascratch
      @stratascratch  Год назад

      Wonderful. Hope you find the video helpful.

  • @YashSharma-zg1uk
    @YashSharma-zg1uk 10 месяцев назад

    thank you so much dude

  • @elhipster1
    @elhipster1 2 года назад

    This is definitely the best youtube API video I've been able to find. Thank you so much. I actually went through two other videos before this and this one was the clearest that actually moved into a full pandas dataframe. Thanks!

    • @stratascratch
      @stratascratch  2 года назад

      Hey thanks so much for the kind words! I tried my best to clearly explain all the steps and theory. I hope to create more in the future.

    • @elhipster1
      @elhipster1 2 года назад

      I really appreciate how you created the 'for' loops, THEN went back and restructured the code to be more 'fundamentally' sound. bravo!

    • @stratascratch
      @stratascratch  2 года назад +1

      @@elhipster1 Thanks for noticing how I do it. I always work in this way where I will write code to make sure the function is there. Once the entire script is finished and it's able to function, I'll go back and refactor everything and try to automate things to make my life easier the 2nd time around. It's a good practice for your self. And if you work on a team, you can even share the code with your team so they can use it for their purposes.

  • @senyotsedze3388
    @senyotsedze3388 Год назад

    Interesting video. I was able to create my own api key from RUclips. But since I have no posted videos, it is difficult to conceptualize your teaching. I wish we could get a generic api key to see data populated in the dataframe.

  • @vivekrathore1857
    @vivekrathore1857 2 года назад

    pure learning..

  • @mjj2u2
    @mjj2u2 2 года назад

    Well done. Nice video.

  • @pauljordan6346
    @pauljordan6346 Год назад

    Hi Nate, I love the video, super clear and explains a lot. I am struggling with pagetoken, you said it would be explained later, is there another video I need to watch to get a handle on this? Thanks

  • @saadmansakib6612
    @saadmansakib6612 2 года назад

    I love your videos!

  • @andrep1370
    @andrep1370 2 года назад

    I'm new to Python and this really helped a lot , been programming for a long time , but Python is new to me. It explains a lot Is this code available anywhere will save having to re-type . Thanks

  • @markk364
    @markk364 2 года назад +1

    Excellent Code Descriptions - breaking down the loop elements BEFORE creating the code is excellent.
    I was inspired by this lesson - to improve my data ingestion capabilities. At risk of redirecting viewers - I started a LI Learning course: Data Ingestion with Python, Miki Tebeka. (requires a subscription to LI).

  • @useydkerimoglu5720
    @useydkerimoglu5720 Год назад

    LOVE IT

  • @sarwatzabeen8523
    @sarwatzabeen8523 Год назад

    This is very helpful! Just a quick question, since the second set of variables were defined for the first video only with index 0 and no for loop, I am getting a dataframe with only one row. Am I missing something?

    • @chiomaeze8245
      @chiomaeze8245 Год назад +1

      cause you used 0 index so you will get only one row. Your loop should be able iterate through the each index of the Json["item"] object to grab the features you need.

  • @user-ur2en1zq4f
    @user-ur2en1zq4f Год назад

    tHanKs Dude

  • @shuang7877
    @shuang7877 Год назад

    That diploma looks very familiar - hello Big Red!

  • @myselfandpesit
    @myselfandpesit Год назад

    Thanks for the video. Nevertheless, some python libraries such as Tensorflow talk about APIs when they are actually saved already on our hard drive. I want to ask you how does, a web application such as tensorflow API function here ?

    • @stratascratch
      @stratascratch  Год назад +1

      Hi. If I'm understanding correctly, these APIs that are local are basically just ways of transmitting your data locally. You're just using an API locally to build your web app. You can move the API to another server or to the cloud and your web app would still work.

  • @vizdam9537
    @vizdam9537 2 года назад

    Awesome

  • @faustopf-.
    @faustopf-. 2 года назад

    Thank you so much for this amazing video! I got just one question: Could you list all the most used APIs by you in your daily basis routine as a DS/DA?

    • @stratascratch
      @stratascratch  2 года назад +3

      I think most DSers use internal APIs if their companies build their pipelines as a microservice concept. Otherwise, you'll use DB queries to pull your data from dbs.

    • @faustopf-.
      @faustopf-. 2 года назад

      @@stratascratch Gotcha, thanks again! 💪🏻

  • @jcokonkwo
    @jcokonkwo 2 года назад +2

    Thanks again Nate, I appreciate the helpful content on understanding/navigating the API through Python. I know you didn't have time in the video to elaborate, but how can we continue looping through pages via 'pageToken' to extract all of data than just the first page?

    • @stratascratch
      @stratascratch  2 года назад +3

      Great question. I actually have the code in the github repo. There's a link in the description. I use the 'pageToken' to do this as you mention. Check out the implementation!

    • @jcokonkwo
      @jcokonkwo 2 года назад +1

      @@stratascratch Thanks Nate! Appreciate the help. Currently in interviews and I've gotten far with your content!

    • @user-np2md7vw5q
      @user-np2md7vw5q 8 месяцев назад

      @@stratascratchWhen I add the "pageToken" some conflist with response['item'] arises. What could be the reason?
      ----> 4 df = get_videos(df)
      in get_videos(df)
      6 response = requests.get(url).json()
      7 time.sleep(1)
      ----> 8 for video in response['items']:
      9 if video['id']['kind'] == "youtube#video":
      10 video_id = video['id']['videoId']

  • @lifecodes9155
    @lifecodes9155 2 года назад

    Too good. Thanks a lot.
    but i have problem that captcha is getting in the way of me scraping the website.