We're covering a lot in this video. We're going to see how to request data from a JSON API, parse out the information we want, sort the data using a custom key, and a lot more. We're going to be using the Homebrew API, but you don't need to use Homebrew or a Mac to follow along. This can apply to many other APIs you'd like to analyze with Python. As I mention in the video, our final result _does_ have a little more functionality than what we can get from their existing API, so I believe it was definitely a useful exercise. For example, we can filter popular packages by a keyword in the description, which is a nice edition. Hope you all find this helpful!
@Violet_Patrick5 жыл бұрын
I hope you make some videos on API development and talk about some of the fundamental concepts concerning API construction and design.
@Violet_Patrick5 жыл бұрын
Corey, can you talk a little about naming conventions? Especially where things get a little more complex?
@ammarhaider15305 жыл бұрын
Can you make a video on Django REST framework?
@nghuwei3 жыл бұрын
I just watched this while I’m Still learning on how to play with the data that I got from api call. Your video is so easy to follow along. I hope that you continue to create more contents on python .
@kevindrew83473 жыл бұрын
I know im asking randomly but does someone know a way to get back into an Instagram account? I was stupid lost the account password. I would love any assistance you can offer me.
@arthurcaesar22003 жыл бұрын
These are simply the best python coding tutorials on the world wide web anywhere. What a lifesaver.
@Lamb41395 жыл бұрын
Corey is the unsung hero of Python KZbinrs :)
@hassamdaudi5 жыл бұрын
I'm a man of limit means... but YOU, you will be the first creator I support on Patreon. You are offering actual education which is helping me in my career. For that you deserve the respect and MAH MONEZ!!!!
@djlatino1015 жыл бұрын
where was this video 3 years ago when i had to teach myself this??! better late than never. this is a massive help to future in the making python programmers
@mr_jacklu80144 жыл бұрын
extremely helpful. as always Corey explains everything in the cleanest manner possible. i think it's because Corey is Midwestern? Would you say that's the reason for your simplicity and clarity? I grew up in Indiana so that's how I feel about Mid-westerners.
@jereziah5 жыл бұрын
These real world scripts you do are simply the best to see how “it all comes together”.
@iChrisBirch5 жыл бұрын
This was one of your best videos to date. I love the longer format using a real world project that can be applied to many other tasks. I hope enough people are donating and supporting you to keep up this work.
@jingyuchang18855 жыл бұрын
No regrets to sponsor your channel at all! Good job Corey!! You videos really helped me a lot!!
@benwalsh28255 жыл бұрын
I really appreciate the courtesy you show other websites. I'm sure Homebrew was whacked last night with a bunch of JSON get requests--I know I tried it out--but I made sure to sleep each request between calls like you said. I am sure there's a lot of outside work that goes into making a great video--planning, writing, rendering, etc.--and I really appreciate the effort you put forth to produce such great content. Thanks so much for taking the time to put this video together.
@coreyms5 жыл бұрын
Thanks! Yeah, I’m always torn on putting together videos like this because I don’t want to inadvertently hammer their system with a lot of people trying at the same time. That’s why I used my personal website for the web scraping tutorials instead of someone else’s. I believe their JSON files are static and aren’t making actual database calls, so I believe these were pretty lightweight requests. So hopefully they didn’t notice too much of a load.
@Violet_Patrick5 жыл бұрын
I've been trying to get a job as a python developer and haven't had much luck yet. I tried messing around quite a bit with Django but after awhile realized that i was just covering material and not actually learning it. Now i watch your videos for joy and for your passion with programming, and its kept me going. Thanks Corey.
@Violet_Patrick5 жыл бұрын
@@GlennChambers Do you feel Java could complement Python experience? I was thinking of picking up JavaScript since most of my projects so far have been to do with Django and web development. Although, i very much enjoy scripting like this above video and 'server-side' logic.
@EUU1003 жыл бұрын
@@Violet_Patrick have you been able to get a job doing python?
@raymondmichael49874 жыл бұрын
I just had to drop a little comment, to thank you. This is a massive knowledge and well taught. Stay safe Greetings from Tanzania 🇹🇿
@백영래-u3x5 жыл бұрын
Your tutorial just made my day! It has been on my mind during several days how to get JSON files through API's by Python scripts but I could not find the right video for me on KZbin. Good job, Corey! Have a nice day!
@archstampton59105 жыл бұрын
A python mini-project : exactly what I needed. I will probably re-watch the video a couple of times, as there is a lot to digest. Thank you Corey
@morethanprogrammer75945 жыл бұрын
This is a great example of things you can do to practice Python or to have something on your CV. Thanks!
@mahammadsameer97643 ай бұрын
Your literally the savior man 🙏🙏🙏
@abhishekvasisht72415 жыл бұрын
you are a lifesaver, your python tutorials are the best. You saved my day.
@henryreith77213 жыл бұрын
Huge thank you for this tutorial. I’ve been writing in PHP for years but more and more of the api’s I use have native Python SDK’s so makes sense to write in Python. This was very insightful to see where python is similar to PHP and where you can take a different route to get the same result. Really cool.
@pplanetEarth Жыл бұрын
Great video, thanks a lot for sharing, it answered my question that I was Googling. I also worked out how to write 30d-90d and 365d as separate columns, I resorted to list comprehension, there might be a better way. Looked through the comments but didn't see anyone mentioning this. On that note: I see a lot of comments saying like: I would be keen to see how you could bla bla, I think comments here should focus on the content of this video, rather than asking for various imaginations and new assignments, please!
@davydwes2 жыл бұрын
thank you so much dude... i was 5 hours in a row searching for one of the solutions that you teach in this video.
@CainanParker5 жыл бұрын
I would have to say you’re video tutorials are so easy to follow, I understand what I’m being taught and you explain each point so well!
@gsb224 жыл бұрын
You constantly reminding us not to DDoS homebrew tells me something about you, that you are considerate. :)
@Neonlightxyz3 жыл бұрын
the way you explained is beautiful and awesome
@v90cross25 жыл бұрын
This is a really great video describing every single step required for JSON data process - Thanks a lot!
@linkflap13425 жыл бұрын
Just discovered your channel and i liked videos with practical approach. Thanks for your knowledge sharing and please do not stop creating more materials.
@emylincon4 жыл бұрын
you are a legend out here!! I always learn something new watching your tutorials
@ibnbattuta13044 жыл бұрын
Thanks for the training! Just downloaded 4997 records today in 39 mins. No mods needed to your scripts.
@sim99554 жыл бұрын
did you apply his code to something totally different and it just worked?
@letsberealq5 жыл бұрын
Amazing work. Clear explanations on whats going on . Thank you sir!
@ericlambert70465 жыл бұрын
Amazing skill as a teacher. Thank you - keep up the great work.
@australianpopulism34905 жыл бұрын
Your tutorial is really easy to follow and I learned a lot from you. Thank you.
@ashwinmandaokar36203 жыл бұрын
the superb explanation, it solves most of my problem, and thank you, keep educating us.
@justin35944 жыл бұрын
one of my all-time favorite videos.
@mishrarp5 жыл бұрын
Amazing video on python. So much of stuff in a single video
@anandmaurya33894 жыл бұрын
Great video bro....it solved some of problem of my project
@yeboahdominic18963 жыл бұрын
Where have you been my mentor is been a longtime I have been waiting for you. By the way thanks for coming back.
@okmidnight17165 жыл бұрын
Thanks a lot sir..your videos always helped me to learn as a programmer...appreciate it.
@muratsokucu58913 жыл бұрын
You are the man! God bless you.
@woody50125 жыл бұрын
Really great video, so many potential use cases for this!!
@prakash11715 жыл бұрын
Awesome..... we really need that type of python script
@akbarahmadi50664 жыл бұрын
great teaching, great work
@Dave-do3pp4 жыл бұрын
This is awesome. You are fantastic. Thank you
@stevehageman67852 жыл бұрын
Wonderful tutorials, thank you.
@Bubbalubagus3 жыл бұрын
This was a great video, it really helped me. Thank you, truly, for taking the time to put this together - it is easy to analog this to other projects
@aabidsofi194 жыл бұрын
Really corey your tutorials are different they make my day.💕
@anneest5 жыл бұрын
This was great Corey, thanks a lot for that! :-)
@johanneszwilling5 жыл бұрын
Thank you so much! Best one on this topic I found!
@nghiepcrypto70344 жыл бұрын
I saw all video ads. Feel nice!
@mdsegara1013 ай бұрын
i've been watching this video for the 3rd times, just for a refresher, then come up to my mind that wonder if you could do a tutorial video to build that homebrew api, please.
@ogoshi5 жыл бұрын
Thank you for your awesome videos, sir 👍
@joeyzalman82542 жыл бұрын
this is an amazing tutorial
@prabhathkota1075 жыл бұрын
Response elapsed time & pref_counter was something new I learnt👌👏
@indroindia3 жыл бұрын
Great video !
@khaled-dz83574 ай бұрын
Hero as usual
@TheKlajmaS4 жыл бұрын
awesome tutorial
@muhammaddilshadkhaliq5405 жыл бұрын
love you keep it up sir......
@fattanehameri4485 жыл бұрын
Thank you Corey!
@a_maxed_out_handle_of_30_chars3 жыл бұрын
best spent 48:42 minutes of my life :)
@fatbench2 жыл бұрын
22:48 - another option here instead of killing your program with ctrl+c would be to limit the for loop explicitly with an upper bound on the index: for package in packages_json[:5]: Sometimes these loops can bog down slower hardware and create lag before the program is killed. Or you can accidentally click outside the terminal and ctrl+c won't kill it until you click back into it. The above method removes all doubt about when the loop will terminate.
@pplanetEarth Жыл бұрын
Good point, I used a counter, limited it to 20 for testing
@xionarxfl3 жыл бұрын
finaly some good fkn explainations
@joiseystud3 жыл бұрын
47:10 great video as always. Can someone tell me why you don’t have to pass an argument to the install_sort() function or use parentheses for that matter?
@mehdismaeili37432 жыл бұрын
Excellent.
@Nearco10005 жыл бұрын
@Corey, deeps thanks , keep it up.
@Jigyasu_RP5 жыл бұрын
Great work sir👍 Please make video on telegram bot using Python.
@abednegonganga49275 жыл бұрын
Hey Corey, I'm a great fan of your tutorials. I had a request though, would you probably do a series on ReactJS?
@cylonscion54705 жыл бұрын
Great video. One suggestion I have is to also say something about error handling in the script. For instance, what if response.get() had thrown an error for some reason (e.g. connection timed out). How should one deal with that in a script like this? How should one go about figuring out how to property specify a try: and except:?
@coreyms5 жыл бұрын
That’s a great point. That’s an easy thing to forget.
@rajath19645 жыл бұрын
@@coreyms probably something for users to try out and learn about exception handling in python. An extended mini-work.
@nurshah8162 жыл бұрын
You can always check the status code =200, with try catch block.
@danielparada8736 Жыл бұрын
If you use the input() function at the end of the for loop the code will run one iteration at a time, waiting for you to hit enter before running the next iteration. It's usually how I do sanity checks on my loops.
@briandreilly5 жыл бұрын
Excellent video!! I would be interested to see how a script like this would store financial information or data that changes periodically. Like timestamping, storing each json file individually, retrieving, and comparing them. Would you use a database to store the info instead of multiple json files? Many thanks.
@gaylonalfano5 жыл бұрын
Amazing as always, Corey! Just curious how you would modify this to break up the request into a few parts, rather than making all requests and then storing the data at the end. Reason I ask is for slower connections if it errors out in the middle of then you lose everything that's been retrieved. My thinking is to use range() to break up the loop into smaller parts and then changing the subsequent writes to our package_info.json file to append new package data (rather than overwriting). Sound sensible? Anything I might be missing? Thanks as always for the amazing content!
@drygordspellweaver87612 жыл бұрын
Could even do threading
@FIBONACCIVEGA Жыл бұрын
I love your video. I'm trying to convert a json file into table format to be able to work more easily on it in python. It's just easier to understand and visualize for me in table format.but i can't get it. Any recommendation? I'll watch your video now about Sorting Lists, Tuples, and Objects.Thank you so much. It is a very useful video.
@memeremor5 жыл бұрын
Hi Corey. Great video, again! Do you usually post the code on github or somewhere for further reference? While following along your code I was doing work on some other project using similar patterns.
@kentkramer3866 Жыл бұрын
do u have to join the homebrew page for ssl access?
@chikosan992 жыл бұрын
Thanks a lot !
@chrisbebek31925 жыл бұрын
Corey what's the best way to approach this: Getting a certain key value when there's a regex match on another key value? Any suitable videos?
@ejazshaikh17325 жыл бұрын
Awesome tutorial, just one suggestion, you can use chrome extension for formatting and beautifying JSON in browser.
@coreyms5 жыл бұрын
Nice. I’ll check that out. Thanks!
@mmurray40434 жыл бұрын
If you want to take over the world with python, i’ve got a video link in the description.... awesome video
@GxDonaven5 жыл бұрын
You might possibly get a key error for the 'path-extractor' package since under the analytics section the name of the package is "path-extractor --HEAD" not 'path-extractor'.
@lardosian5 жыл бұрын
Hey Corey, any plans to do something like creating our own api with Django Rest Framework, would be great to see how you would approach it, just started using it myself to render charts with Chart.js based on the data in the database and it was very quick to get off the ground. Used your django project as the base for my project so thanks a mil for that. I'm sure I will make some mistakes along the way so would love to see how you do it.
@Shuubham_Harilal_Saroj2 жыл бұрын
Your videos are awesome. I had one issue with requests package, How can i fix the issue of SSL error on https requests without using verify=False
@ahmedabushama40245 жыл бұрын
God bless u …🙏🏽
@ahmedabushama40245 жыл бұрын
Am just wonder if u could make series in neural network with python…?
@TheL337trance3 жыл бұрын
I have a couple Json dists and lists I need parsing through. You want to do a little freelance work?
@frankconte24575 жыл бұрын
Thanks Corey for another great video. I am following your tutorial using my Jupyter notebook. Unfortunately, the Jupyter Notebook server I am on stops sending out output (which is not to crash homebrew server). Can we simply download the file and then read it into your script? Please advise.
@maidenfanusa4 жыл бұрын
when I include the break statement, it outputs the json file, but without the break, it doesn't output the json file. Why would that occur?
@juanpablomtbxc2 жыл бұрын
Thanks 😃
@gauravmishra444 жыл бұрын
Respect!!!
@daminilanje55233 жыл бұрын
Hey i have one json file as a request body for an api..if suppose i have multiple json objects in that json file...for every object it finds in the json file the request should occur...how do we do this ?
@JollyAZ4 жыл бұрын
How you dont have 1 million subscribers is just ridiculous
@strange_facts_Of_the_world4 жыл бұрын
i need some help : how to comment out multiple python lines at once in sublime text ?
@Nightizm5 жыл бұрын
What font are you using in your editor?
@coreyms5 жыл бұрын
Source Code Pro
@arwahsapi4 жыл бұрын
Could you please make a tutorial on how to combine/merge two (or more) sorted json files?
@gerrelatanacio5 жыл бұрын
Hi, are you familiar with Tavern API? I hope you can make a tutorial about it.
@GovindSingh085 жыл бұрын
Hi Sir, I want to learn Python Django with Rest Api. Kindly suggest me your videos from where I should start learning.
@mihaidinca20625 жыл бұрын
I like very much your videos and i learned a lot from your videos. I am a little confused. how can this lib in my project ? if i can make a request to other site it does not work. now i am scapring a site and i dont figure out how can i format my data into a json format.
@EUU1003 жыл бұрын
thanks for the video, really helpful! what do i do if the json list i have has certain keys missing sometimes. My loop worked twice but the stopped and gave an error KeyError: 'price' since the price is missing from the info for that item I am trying to take data from an Etsy API, do you have any advice on how i could get around this? i tried to put 'if price not in list: continue' in my loop but not sure if that is possible or if i have laid it out incorrectly. Sorry i am still new to Python, Thanks! any help would be appreciated
@amshaprabhu90653 жыл бұрын
Hi Sir, In line #13, - "install_sort" is being called and executed. As it takes one argument - "package", where it is being passed to it ? in line #13... I thought it will throw error, but it runs. Please respond.
@mahalakshmi-fp9ze2 жыл бұрын
Hi!! Is it possible to create API using TKinter GUI?!? TIA!
@v90cross25 жыл бұрын
Is there any further instruction for how to visualize the collected data here?
@coreyms5 жыл бұрын
Not with this specific data, but if you watch my Matplotlib series then you can apply that to this data to get some cool visuals
@anthonysimonyan47634 жыл бұрын
Hi there @Corey Schafer I have a question if for example you have two different json websites containing information information about the same product like one site contains name the other price after scraping how can I put them next to each other row by row?
@silkogelman3 жыл бұрын
At 34:58 if you don't want to wait 25-30 minutes for the 1000s of requests to finish you can also do this: limit the for loop to 10, 100 of 1000 loops by truncating/slicing the packages list like the list at 46:25. Simply add [:10] or [:100] or [:1000] to the for loop code. for package in packages_json: then becomes for package in packages_json[:100]: You'll end up with the details of 100 packages in your package_info.json file.
@drygordspellweaver87612 жыл бұрын
You could also run multiple threads
@PSY_JD3 жыл бұрын
Could someone explain to me how the sort function works because to me it looks like it's just an empty function and not even given any information?
@jorgensenathomas5 жыл бұрын
got an error "#KeyError: 'path-extractor'" - tried for 5/10 min to find if google had a quick answer but no - made a try except. Great videos - keep it up :)
@akashverma41975 жыл бұрын
I am getting the same type of error. Please tell me how did you resolve this?
@akashverma41975 жыл бұрын
I am getting the error as "KeyError: 'residualvm'"
@GordonAitchJay5 жыл бұрын
It sounds like the JSON the server is giving you doesn't always have a "path-extractor" key. Some of the items in the list might have it, but not all. Likewise with the "residualvm" key. You can handle this a couple ways. One simple way is to use the *get* method on the dict. So instead of something like json_dict["path-extractor"], you'd do json_dict.get("path-extractor", "No path given").