Use Excel VBA to Read API Data

Ғылым және технология

Use Excel VBA to read API data
Today I'm going to show you how to use Web API's with Excel VBA.
Web APIs may seem a bit daunting at first but by the time you finish this video, you’ll be able to read data from any Web API with ease.
The first part of the video explains the 3 core parts of dealing with Web APIs. It explains each in detail and provides coding examples.
Don't miss the final part of the video where I show a simple method for writing the code for any API.
All the code used in this video is available to download from the link in the description below.
#VBAAPI #ExcelVBAAPI #VBAWebAPI #VBARequestAPI
SUBSCRIBE TO THE CHANNEL: bit.ly/3aKHxlY
DOWNLOAD THE SOURCE CODE FOR THIS VIDEO: bit.ly/3BRIe92
Related Training
The Excel VBA Handbook Course(TheExcelVBAHandbook.com)
Webinar Archives - 60+ Hours of VBA training(excelmacromastery.com/excel-v...)
Free Excel VBA Resources
Excel VBA Articles (excelmacromastery.com/vba-art...)
Useful VBA Shortcut Keys
========================
Debugging:
Compile the code: Alt + D + C OR Alt + D + Enter
Run the code from the current sub: F5
Step into the code line by line: F8
Add a breakpoint to pause the code: F9(or click left margin)
Windows:
View the Immediate Window: Ctrl + G
View the Watch Window: Alt + V + H
View the Properties Window: F4
Switch between Excel and the VBA Editor: Alt + F11
View the Project Explorer Window: Ctrl + R
Writing Code:
Search keyword under cursor: Ctrl + F3
Search the word last searched for: F3
Auto complete word: Ctrl + Space
Get the definition of the item under the cursor: Shift + F2
Go to the last cursor position: Ctrl + Shift + F2
Get the current region on a worksheet: Ctrl + Shift + 8(or Ctrl + *)
To move lines of code to the right(Indent): Tab
To move lines of code to the left(Outdent): Shift + Tab
Delete a Line: Ctrl + Y(note: this clears the clipboard)
Table of Contents:
00:00 - Introduction
00:37 - What is an API?
04:37 - API Code example
07:41 - JSON Converter Library
09:27 - Reading the converted data
12:20 - Understanding the returned data
15:46 - Fast method to write any API code

Пікірлер: 151

  • @Excelmacromastery
    @Excelmacromastery2 жыл бұрын

    I hope you enjoy my new video. Please let me know if you plan to use Web APIs. *Important Note:* To use each API on the RapidAPI website you must subscribe on the API page.

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    @@yashchawla8360 Thanks yash. I hope you like it.

  • @bogdanexit1

    @bogdanexit1

    2 жыл бұрын

    I will use in Microstrategy

  • @quoctam1719

    @quoctam1719

    2 жыл бұрын

    I plan to use API on price comparision website

  • @JasonTorpy

    @JasonTorpy

    2 жыл бұрын

    question - what about customers? I do a lot of paid freelance work with VBA (and Google script) but I've always avoided any addons as customers might not have Scripting Runtime or WinHTTP loaded). Is that a concern? Any suggestions on how to ensure a client has those addins added... maybe an auto-load button?

  • @madschedules

    @madschedules

    2 жыл бұрын

    Hi @@JasonTorpy , you can do it with late binding so that your clients don't need to turn on the reference library needed.

  • @TuncanGaming
    @TuncanGaming8 ай бұрын

    I didn't know anything about VBA and was able to do what I wanted to just by watching your video. Great work, thank you so much!

  • @guidopiotrowski7114
    @guidopiotrowski7114 Жыл бұрын

    Incredible video, super clear, and great teacher. Thanks!

  • @mikem8915
    @mikem8915 Жыл бұрын

    Solid video. Shows exactly what you should do for a given objective.

  • @garethwoodall577
    @garethwoodall5772 жыл бұрын

    Excellent explanations (as usual). Good teacher! Thanks Paul *

  • @marcellino53
    @marcellino532 ай бұрын

    Awesome job.. Thanks, and greetings from Brazil !

  • @trueevilangel
    @trueevilangel2 жыл бұрын

    thank Paul , you explained it easy to understand.

  • @magalisantos5544
    @magalisantos55449 ай бұрын

    Thanks very much for this tutorial!! I created a macro which retrieves data from an API and thus it saved me lots of hours (~6h) from checking them individually!! Thank you VERY MUCH AGAIN!

  • @kolavithonduraski5031
    @kolavithonduraski50312 жыл бұрын

    next level VBA 👍

  • @wayneedmondson1065
    @wayneedmondson10652 жыл бұрын

    Hi Paul. Very cool tutorial! Thanks for access to all the resources used. I worked through the name example and connected successfully with the same results. Can't say I totally understand it all yet, but it's a great start. Always something new and interesting at Excel Macro Mastery :)) Thumbs up!!

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Thanks a lot Wayne. Glad you enjoyed it.

  • @bongzsmalawu1614
    @bongzsmalawu1614 Жыл бұрын

    Thank you so much, this has made things lighter for me, I have no programming background, but was looking forward to leverage this lesson to help me import run statistics from strava, garmin connect and polar websites for my team.

  • @vbaclasses3553
    @vbaclasses35532 жыл бұрын

    Awesome video, thank you. Will make time to work through it all.

  • @DLAmurph
    @DLAmurph2 жыл бұрын

    This example blew me away very informative and helpful, thank you Paul

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Thanks Ken.

  • @tgirard123
    @tgirard1232 жыл бұрын

    Easy as 1-2-tree. Thank you so much. I could not figure this out for the life of me. Now I got a working sheet!!

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Glad you found it useful Timmy.

  • @chrisouellet2832
    @chrisouellet28327 ай бұрын

    thanks for this tutorial Paul!! this one is very cool!!!

  • @edrobinson8248
    @edrobinson82482 жыл бұрын

    good stuff. hope beginners realize that is for a specific (web) api . Not generic API's.

  • @fredrodriguez963
    @fredrodriguez9632 жыл бұрын

    Hi Paul, very good stuff. Thank you.

  • @hf2138
    @hf2138 Жыл бұрын

    Thanks for a great video Paul, keep it up

  • @ashkumar8797
    @ashkumar8797 Жыл бұрын

    Great video, thanks for sharing and explaining

  • @Algoreborn
    @Algoreborn11 ай бұрын

    THANK YOUUUUU, you made my day...

  • @simondechoisy779
    @simondechoisy7792 жыл бұрын

    Really looking forward to this

  • @anthonypasslow1933
    @anthonypasslow19332 жыл бұрын

    Great job as always, thank you Paul

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    You're welcome Anthony

  • @Monduras
    @Monduras2 жыл бұрын

    Outstanding as always! Bravo

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Thanks Leon.

  • @nickroe5992
    @nickroe59922 жыл бұрын

    Thanks, that was a very good tutorial

  • @fairosabdulmutalip641
    @fairosabdulmutalip6412 жыл бұрын

    Hi Paul, love your tutorial

  • @kingparc
    @kingparc2 жыл бұрын

    Thank you very much 👍

  • @davidlinesq
    @davidlinesq2 жыл бұрын

    Thank you so much for this video. This has helped me with a program that I needed to create for work. One request for a follow up video would be how to make paginated api calls and combine the results into one array. Thanks as always!

  • @thomy0319
    @thomy03192 жыл бұрын

    Wow , que impresionante! 👏👏

  • @Abhishekuchagaonkar
    @Abhishekuchagaonkar2 жыл бұрын

    You are awesome!! (Guruji)

  • @johnsmith2771
    @johnsmith27712 жыл бұрын

    Great video, thank you so much for posting this, really helps

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    You're welcome John.

  • @hain.v.h5744
    @hain.v.h5744 Жыл бұрын

    Thank your video.

  • @sofianemeriane
    @sofianemeriane Жыл бұрын

    thanks for sharing!

  • @MrMallesh1
    @MrMallesh12 жыл бұрын

    Amazing video ! I liked it , thanks a lot !

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Thanks Mallesh.

  • @oz7075
    @oz70752 жыл бұрын

    I was preparing a series of videos to upload to my upcoming KZread channel and one of them was APIs. Interesting. I have a project of mine which uses a WebAPI from an Online dictionary.

  • @CivilEngSpreadsheets
    @CivilEngSpreadsheets2 жыл бұрын

    Hi Paul! I'm learning a lot from your channel. Would really appreciate if you could do a tutorial about VBA and Google Drive API like how can you use VBA to upload or download a file from Google Drive.

  • @saxena1955
    @saxena19552 жыл бұрын

    Hi Paul , Great video. Can you make it a dynamic code to read data of any api and write it to excel ? Please explain it in next video . Thanks

  • @bernardoezeta2531
    @bernardoezeta25312 жыл бұрын

    Hi Paul! Thank you so much!

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    You're welcome

  • @caste_
    @caste_2 жыл бұрын

    thanks my man your a genious

  • @MarceloCutin
    @MarceloCutin2 жыл бұрын

    Great video!!! Congrats!

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Thanks

  • @briandelaney6354
    @briandelaney63542 жыл бұрын

    Hi Paul, I had no idea you could use VBA for this purpose! Thanks for sharing the knowledge 😀😀

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    You're welcome Brian.

  • @buzan.untung
    @buzan.untung2 жыл бұрын

    Thank you

  • @kevinbezant8972
    @kevinbezant89722 жыл бұрын

    Very interesting video, Paul. I'm currently using Integromat to integrate web apps. Whilst Integromat is very good, I feel I could do with having more control and your video has got me thinking! A follow-up video on writing to an API would be useful.

  • @jjtagh

    @jjtagh

    2 жыл бұрын

    Also some examples writing to API using GraphQL (mutation) as well as REST API would be fantastic.

  • @jorgevalverdevalderrama5586
    @jorgevalverdevalderrama55862 жыл бұрын

    Excellent video and great Spanish name picking UwU

  • @jesus.moreno
    @jesus.moreno2 жыл бұрын

    wouuuuuuuuuuuuuuuuuuu amazing ... you got a suscriber to your channel !!!

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Welcome aboard

  • @aNDy-qh1em
    @aNDy-qh1em2 жыл бұрын

    15:35 It could be a mixture of dictionaries/collections and also classes . 'Country' could well be a class. But that is a matter of preference - for simplicity reason that is ok. When using s dictionary I would verify if the key-value pair exist. A great tutorial, thak you

  • @scotolivera8207
    @scotolivera82072 жыл бұрын

    very informative

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Glad you like it George.

  • @luismejia6817
    @luismejia68172 жыл бұрын

    This is so awesome. I’m gonna. Be working on a lot of personal projects from this rapidapi website. I’m a data analyst so I’ll be inserting the responses in a database :)

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    That's great to hear Luis.

  • @TheJaebeomPark
    @TheJaebeomPark2 жыл бұрын

    Amazing!

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Glad you like it.

  • @TheSardOz
    @TheSardOz2 жыл бұрын

    Hi Paul, thanks for the excellent video. How do you catch errors if you have a miss match? If you have a collection of stocks cods and you getting the close price, if one code if not available you’ll have a error and the loop will brake.. how can you skip the error and finish the loop? Thank you.

  • @shinrafahell
    @shinrafahell2 жыл бұрын

    Hey Paul, great video as always! Any chance to have a tutorial explaining how to get apis that utilizes oauth such as Google sheets or Twitter? Thanks!

  • @phonesolo8513

    @phonesolo8513

    2 жыл бұрын

    Exactly what i need.

  • @MyAudioBookCompilation

    @MyAudioBookCompilation

    2 жыл бұрын

    This is the last wish that i want to achieved. To learn to modify google sheets using vba.

  • @shinrafahell

    @shinrafahell

    2 жыл бұрын

    @@MyAudioBookCompilation using python it is a breeze. Unfortunately I didn't find anything related to vba.

  • @MyAudioBookCompilation

    @MyAudioBookCompilation

    2 жыл бұрын

    @@shinrafahell I see. Thank you. Python and JavaScript are in my list but sometimes we still want to achieved what we really want to achieved. 😁 I know that learning to manipulate google sheet using VBA might be overkill but that what makes us happy. Anyways thank you for the info i think i will try to learn if first.

  • @rajesh321r
    @rajesh321r2 жыл бұрын

    This is awesome👍 Happy to learn APIs and how to use with VBA.

  • @fernandobravo2886
    @fernandobravo28862 жыл бұрын

    this is great, one question could be how would you do it with a POST request, that also you need a request body website, that is very common within intranet company's websites.

  • @Ashokkumarg8
    @Ashokkumarg810 ай бұрын

    That is awesome, but can you tell how did you make those two API examples currencies & recipes from the excel

  • @elricho72
    @elricho722 жыл бұрын

    Excellent video and explanation, I ask you seeing the use of the api, could we make it possible for us to interact with VBA to upload or download files from google drive?

  • @solimanalali8048
    @solimanalali80482 жыл бұрын

    A very interesting lesson. My question is, I want to create an invoice automatically. I want to create a QR code on the same invoice, and when scanning the code, the same invoice appears.

  • @mas07sencillo
    @mas07sencillo Жыл бұрын

    Thanks for this video! I also have a doubt. How do i handle the API call when the API response have pagination? should i use a for an remake a colletion?

  • @halforman6726
    @halforman672611 ай бұрын

    Great video. Your channel is awesome. How can I use a private API (requires authentication) in VBA?

  • @1rikenpatel
    @1rikenpatel2 жыл бұрын

    Hi Paul in the example you have used with the name and country, can a filter be applied on the country id so that when a name is selected on data for the filtered country is retrieved? if possible how would I add this to the code?

  • @bioactiveSaha
    @bioactiveSaha2 жыл бұрын

    Hi Paul! Thanks for the video. It is very informative. I was able to download and parse json data for small dataset. However, If I try to download complete data (~600,000), excel goes to not responding. I tried with .SetTimeouts 0, 0, 0, 0 and/or waitforresponse but the problem still persist. Any tips? Thanks in advance for your help.

  • @Rice0987
    @Rice09872 жыл бұрын

    By chance 've read this: "Programs must be written for people to read, and only incidentally for machines to execute". :)

  • @acidkans
    @acidkans Жыл бұрын

    Hi Paul, great tutorial, with almost zero knowledge i managed to get data of EURO currency from Polish National Bank...but what I'm missing in your tutorial is assigning values to specific cells...for example when I filter a dataset I'd like to paste currency rate to filtered column.....no idea how to do it... I mention that I've this rate but can't paste it...could you help int hat matter? your movies are top quality, great job

  • @protostecnologia4096
    @protostecnologia4096 Жыл бұрын

    Wonderful video. Coul VBA connect with a dspace repository? The latest version of dspace repository is made in Angular (front end) and use a backend built on spring boot (java web app)

  • @tangsh497
    @tangsh4972 жыл бұрын

    talent

  • @The_Code_Father
    @The_Code_Father Жыл бұрын

    Very beneficial video I'm trying to build a connection with e invoicing portal in my country using json files and api and they're talking about sth called token Could you plz add more detailed tutorial on this topic

  • @vijayalakshmibadigeru4479
    @vijayalakshmibadigeru44792 жыл бұрын

    Very useful video thanks.. can we define the jsonconverter in classes..

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    You're welcome.

  • @RMS888168
    @RMS888168 Жыл бұрын

    Would it be possible to see how to implement OAuth 2.0 authentication using the examples in this video?

  • @tarunprakashsingh
    @tarunprakashsingh2 жыл бұрын

    hey nicely explained... I am trying to build something where user can define a Get URL and my code can parse any JSON without knowing the Structure and show it in tabular form in excel. How can i do that?

  • @schmuttergold2296
    @schmuttergold2296Ай бұрын

    Great video. I have to use a post command and need to pass a JSON request together with the http request and headers, How can I do that with VBA?

  • @WoottonRivers
    @WoottonRivers2 жыл бұрын

    This is a really good video. I've had a go at this before but ran into the problem of authentication. I was trying to access data in Xero (the cloud accounting solution). How do you authenticate through VBA if you only have a email address, password and 2FA code? Authentication for other web services creates a similar issue. Suggestions welcome.

  • @farahinrosli7244
    @farahinrosli724410 ай бұрын

    hi can you do to copy data from private apps then paste it in excel, also include the screenshot of data and paste in the excel too, but for this it included multiples data to do in one sheet before move to next sheet

  • @KLiCuk1
    @KLiCuk1 Жыл бұрын

    Hi Paul, I remember watching this when you first posted it and thought I'd put it on a backburner until I needed it. I just tried downloading the source code but unfortunately the link doesn't work anymore. Is there an up to date link?

  • @excelmonkey
    @excelmonkey Жыл бұрын

    Just out of curiosity, how would you store multiple API keys in your module such that the correct key was called by each subroutine?

  • @yograjkolhe5225
    @yograjkolhe5225 Жыл бұрын

    How can we parse api response in XML? Is there any library available for the same like VBA-JSON library?

  • @youknowme6780
    @youknowme6780 Жыл бұрын

    I am working on a vba to fill web form, it works on first IE page and submit the form, but when a new page loads with different web address, my code don't recognize the active web page...to keep on filling this page Any advice??? No selenium used

  • @davidsaw3517
    @davidsaw35172 жыл бұрын

    How do you do nested dictionaries?

  • @KhalilYasser
    @KhalilYasser2 жыл бұрын

    Thank you very much. Awesome tutorial. I have signed up in rapidapi but how can I get the API that I would insert in the VBA code (I couldn't find such API section)

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    You have to subscribe to each api you wish to use.

  • @KhalilYasser

    @KhalilYasser

    2 жыл бұрын

    @@Excelmacromastery I have tested again now and it is working. Yesterday, something went wrong.

  • @johnstabile9016
    @johnstabile9016 Жыл бұрын

    I'm working on a mac. When you do the references part, is there a mac equivalent to WinHTTP Services. I don't have as many options as you do. Thanks, John

  • @MicheleLieske

    @MicheleLieske

    Жыл бұрын

    I have this question too

  • @abhiabhiram2855
    @abhiabhiram2855 Жыл бұрын

    Could you please let me know how to get API response text in VBA ? For example for 200 response , response text is ok .

  • @faiz.ahmad65
    @faiz.ahmad65 Жыл бұрын

    Can you please also tell me how to send parameters along with API Key in Post request?

  • @ReverendZen
    @ReverendZen2 жыл бұрын

    Hi Paul, thank you for the great video. I had an issue with downloading the source code. I am not sure if the link is broken or if I need to create a login or something. Is there another means by which I can get the source code?

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Can you send me an email? It's Paul at the channel name.

  • @huonggiang537
    @huonggiang537 Жыл бұрын

    Hi Paul. You can guide How to scrape data from a website that requires login? thank U

  • @timlambe8837
    @timlambe8837 Жыл бұрын

    Hello, is it possible to use Excel as a backend and set up an API with VBA? 🤔

  • @rbloesser9009
    @rbloesser90092 жыл бұрын

    It would have been nice to get more specifics on how to get an API Key. The Rapid-site is very confusing for a beginner. I could not run your code because I could not figure out how to get an API Key.

  • @lisah8896
    @lisah8896 Жыл бұрын

    Hi Paul, Love this but I'm hoping you can help me with something. I can't get the msgbox to display the "request.responsetext. I just get a blank box. If I put the address in a google address box, values return but my message box remains blank. Can you give me some ideas?

  • @axelamoe
    @axelamoe2 жыл бұрын

    Can you make a video for windows api to control an open third party application and get the text?

  • @thierryodou4479
    @thierryodou44792 жыл бұрын

    Is it possible run R script on VBA?

  • @knowyourdirt1152
    @knowyourdirt1152 Жыл бұрын

    Can you show an example of a post request instead of a get request?

  • @NaveenKumar-fs3nk
    @NaveenKumar-fs3nk Жыл бұрын

    LinkedIn to scrap using macro is it possible

  • @MrMallesh1
    @MrMallesh12 жыл бұрын

    whats the difference between Extracting data via API and extracting data via web scrapping ! or they both same ! can we use same code for web scrapping !

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    That's a good question. While they both read from a website they are completely different. *Web Scraping*: When you access any website in your browser you are essentially receiving a HTML file from the website. HTML is text and what web scraping does is read through this HTML and extracts data from it. *API*: An API is a programming interface created by the website that allows you to access certain functionality. This means you have direct access to the web application with support and documentation.

  • @gokmensen823
    @gokmensen8232 жыл бұрын

    we could not find your APIKEY module and without it the excel does not work. could you share with us? module or xlsm excel file? thanks

  • @daves4026
    @daves40262 жыл бұрын

    Hi Great video thank you for sharing. Cant see the code link though, cant wait to practice this

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    The link is there now👌

  • @mwolffe
    @mwolffe Жыл бұрын

    Great video. I'm a little late to the party. :) I followed along several times and tried typing out the code as you went along, but my code failed. I keep getting a Compile error: User-defined type not defined on the 'Dim country As Dictionary' portion of the code. Not sure what I missed. Hopefully you or someone here will have an idea. Thanks!

  • @Excelmacromastery

    @Excelmacromastery

    Жыл бұрын

    You need check "Microsoft Scriping Runtime" under Tools->References

  • @jamcast725
    @jamcast725 Жыл бұрын

    I cant get just a list to print. it doesn't have a key value pair inside but just a list

  • @andriodenavarrete4495
    @andriodenavarrete44953 ай бұрын

    But how do you add it to th excel sheet?

  • @user-pb7zf8tm3x
    @user-pb7zf8tm3x2 жыл бұрын

    can not find the download link of this video

  • @user-pb7zf8tm3x

    @user-pb7zf8tm3x

    2 жыл бұрын

    Sorry, I got it.

  • @bimaljain1666
    @bimaljain16662 жыл бұрын

    Hey Paul, I am from India. I have designed a project for which I want to get the Train No. and name of the train from the web in my excel worksheet. Please help the execute the same.

  • @todddean7722
    @todddean77222 жыл бұрын

    The link to the code seems to be broken

  • @TheGEEKofGAME
    @TheGEEKofGAME Жыл бұрын

    With your code about name and countries, I have an error on the line Request.Send and I verify references WinHTTP and Scripting are check…. :/

  • @noambrand
    @noambrand2 жыл бұрын

    The bitly link DOWNLOAD THE SOURCE CODE writes the website is not secure and does not let me download.

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    Are you using a company firewall or popup blocker?

  • @noambrand

    @noambrand

    2 жыл бұрын

    @@Excelmacromastery company firewall, from home it worked

  • @Excelmacromastery

    @Excelmacromastery

    2 жыл бұрын

    @@noambrand Glad you got it sorted Noam.

  • @trillionshares3914
    @trillionshares39142 жыл бұрын

    template website "Page not Found"

Келесі