Build and Sell your own API $$$ (super simple!)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so data is the new oil today in this video I will be sharing with you how you can create your own Epi you can extract data and you can sell that API on rapid API and earn money so this tutorial will be divided into into different parts first of all we will create our server with node.js and express.js then we will create our web scraper which will extract data which we will provide to our API users third we will push our API code to GitHub fourth step will be to deploying that API on render.com for making it available 24 cross seven fifth step will be to uploading our API on rapid API and setting up all the pricing and all the endpoints and base URLs so this will be a very exciting video I hope you will learn something formative from this video and something useful which will help you earn money in future so in this video the process is very important like how you can create your server how you can create your own API how you can create your own web up scraper which collects data and then applying it on server and Publishing that on Rapid Repair and not the idea on which I am working on so you can use your idea you can use your brainstorming like what data you can sell but the process is important and that is what I want you to learn from this video and not the thing which I have created so use your creativity and come up with different exciting API which you can sell which will be useful for people and for which people would like to pay hey guys if you're new my name is your Gmail on this channel ip8 videos related to web development tutorials tips and tricks freelancing entrepreneurship and I share my journey so if you are interested in these topics make sure you subscribe to the channel and or you can go through my YouTube channel and you can find more informative video which might be useful for you so make sure you subscribe make sure you like and share this video let's get into the video so you can click on test endpoint it will test the end point so this is the kind of data which you get from the API so here I have created a new folder called tools API from here I will go to terminal click on new terminal and here I will install some packages npm install Express and Cheerio so these are the two packages which I will install for now so let's click on enter and that's it okay so both of our packages have been installed in your practice.json you can see cheat you and express click on new file and create index.js so first of all we will create a new server press server so Express equals to require Express const app equals to express let's define our Port process dot EnV dot port or let's define it as 5000 after that we will use a DOT use Express dot Json and we will listen to app Dot listen so listen on Port will be a arrow function and it will say console.log server running on Port okay so remove these two from here and include backticks so it is above your tab key and then dollar and then and type Port so this will show us on which Port our current server is running and let's have a get route set so app dot get if there is something on this route default route we will select whereas we will raise dot send welcome to tools API so our server is properly set up I think we will have to go to our packet.json add a script here so here you have right script for start you will say node index.js for Dev comma here for Dev we will say nodemon index.js and we have to install node one so let's npm install node mon so that our server is running continuously whenever we make changes okay done now let's call npm start so our server is running on Port 5000 so when we go to our Chrome browser from here let's go to localhost slash three thousand name five thousand slash so it will say welcome to tools API okay so our server is set up perfectly now we have to create our scraper and from scraper we will get the data and after that whenever someone will call our API on some route we will present him with the data so let's work on that so let's create one more route and let's type app dot get flash tools then we will we will call function let's say let's call it main function and this main function will be a async function function Main and this main function will call so we will be scraping this page we will get all of this data from this page so we'll get its title its duration it's uh places if it's fair let's say 33 999 and we will also get its link which is inside this button so yeah this is what we will be scraping inside this let's call the main function let's call Akbar travels function and let's create that function here so it will be a async function Akbar travels we will also have to install one more package so click on this click on new terminal click on npm install and call it request and then install request along with npm install request Dash promise so now let's use that so we will say cons request equals to require request Dash promise and cons Cheerio require G view now after that we will say const HTML will be equals to avoid request dot get and we will send our request to this link so you have to paste this link here it will request page from this link and after getting that page we will load that page to Cheerio so Serio dot load load over HTML so that we can pick elements from the the page and let's have let package is equals to AMT array after that we will say Cheerio since we want so we will go to this uh so we will select this element then dot map so we'll map over that so this is same for all the elements that's why we are mapping all the elements so I will like uh first of all create this scraper and after create completing this paper I will tell you in detail how did I found out these locations okay so first of all let's finish this so we will have index and we will have element after that we have we will call a function inside this we will say cons title equals to so we want to press the title so we will say con element so here we have got our title so we have got the hold of our title which is inside div left contact so now I will explain how did I got these elements location so first of all uh I will go to this site you can see this URL just go to this side click on file and then select this tool and click on this element uh this element and after that inside this you will have one more element like this wrapper so this is the wrapper element and inside this we have left and we have right okay so in left there is the image you don't want that and there is right clickable card this is for div dot wrapper and inside that we want du dot right clickable card and inside that we have divot pop see this is div and this is the wrapper this is a class that's why here is dot inside this we want to go to write clickable card and inside this we want to go to top and for every element which contains this we will map over that and we'll select that element and form that element we will select the title so we will have d dot left content so inside this we have div we have left content and inside this we have H3 so inside this we have H3 and its nth child is one okay so we want its first child that is dodam yatra so it's Text due with a class theme of left content inside that we have H3 we want it second child and inside its second child we have span and inside that we want text so it is this is the second child we have the span and we want its text so it will come out to be six night and seven days now after that we want places so for places for places inside this we will have all the places so it is inside div dot left and inside the P tag and we want all of its text inside P tag so this is due left content and inside that we have P tag and we want all of its text content okay so this is how we get places pair for inside view we have here we have slash price and then we have to inside this we have so if you want to find any element let's say you want to find this this thing then you can just click on this and you will be taken here starting price for adults player slash price so it is view dot this is a class name fear dot slash price inside this we have P tag and inside this we want starting price for adult okay I think you have got the idea we will put that into a con package equals to so we want to rename these two packages and let's rename this let's name it to package and we want to create a object and this object will have a property as title duration as duration places as places pair for as fair for fair is for fair link is for link okay so we have created our object with with one package since it will iterate it's a map so it will iterate over all the elements all the packages so we will get this for all the package okay so after getting this package we will push this into our packages array here so let's push through packages dot push What will what we will push we will push package after that we have to get this function okay we will package this dot for each we'll run for each Loop to see if we have got all the packages correctly or not let's just console log themes console DOT log element test elements so this is our scraper which will accept all the packages from this site and it will accept title duration places where link package push all of this into this array and let's run this so let's make our call to cannot get Slash 2 so when we click on this Ctrl refresh high but we have got things in our console so the data is available now to operate in this API we have got our data in our visual studio so as you can see from here so this is the whole data which we have got from our tools it is perfectly in a good State we can read this so we have got all of this data and now some whenever someone will call to our API we will return this data to that person okay if in future something like this uh structure board if doesn't work that means they have changed their site structure that means these location will not be pointing to the same location where our elements are so to make it work to make this tutorial work what you can do is you can just uh click on you can just comment this out you can just comment this like this and inside packages you can just create some of your title and you can give those um yatra and after that price will be protocol to duration will be three days okay so you can just copy this okay so you can create something like this and uh so if in future if this code doesn't returns you the places as it is currently working that means the file the people from whatever might have changed your structure so you instead of this you can just create a package array which contains these objects so and after that it will just return these packages so uh so this will make this uh tutorial future proof and it will not depend on this code if you want to like put some data inside this then you can just use this technique of web scraping and put the data so it's not necessary that you do this you can put anything you want which is like a data which you can sell to other people which which will be useful to them so yeah you can do something like this but it will only return these elements always so this doesn't make sense to sell this data because this data is of no value it will tell you how you can like create a API you can publish that on a rapid API and the scraping part is the different part and the and creating uh an API and uploading it to Rapid API setting up the packages and setting a server for the API is a different part deploying it on the server is the different part for now you can just uncomment this you can just uncomment this and it will work fine for now for that we will have to so we will have to make this as a sync and we will put this also inside try and catch box so try this cat error so if there is dot Json error but if you don't have something then just call this main function res dot Json will be Json dot bar Parts our packages okay oh wait now let's check with the tools API Ctrl refresh so here we have to first of all make we will have to make some changes so remove these packages array from here Ctrl X and let's put this inside our function Ctrl V Ctrl save and after that we have got our packages here there's dots and it won't build records and it will be and also let's remove this whole thing console.log and then let's let's just return packages so from here we will be returning the package Ctrl save uh he from here we will save the const packages equals to a weight but travels we will just respond to adjacent control C okay so now let's check if it is working correctly or not so control refresh okay good it's working so I will just show you so just Ctrl refresh here it will it should show all of this data so we have got all of this data make sure if it is not showing then make sure your tools you are on this route slash tools if it is not showing like this then I have I think a tension installed we will just install some Json viewer Chrome extension and it will be like this okay so we have now created the API so till now we have set up our server we have created our scraper and from scraper we are getting the data okay so our three task is done and a word our task remaining is let's click on create new repository tools API call this private or let's keep this public for you click on create new repository copy this code from here and go to our tools API so what I did here is I just came here I I pasted this code to get init then git add readme.md get first commit then get Branch Dash M then get remote add origin this is the code which we got on the top not the second one but the first one and I have pasted that here after that I created here dot git ignore file so just click on this file and type this git ignore and inside this just type slash node module so this node modules folder will be ignored while we we will be pushing this GitHub so after that you just save this and from here just click on get status so from get status you will get these four files then that means your setup is com is perfectly fine till now and from that we will say git add everything in this code so this will add all of your files and write this command get commit flash M Dash M create a tools API this is the message and after that click on enter then click on git push origin main so this will push your code to the GitHub on the main branch so as you can see we have all of our files here now and let's click on sign in so after coming to render we will click on create new click on web service and from here we will have to click on connect to GitHub and from here we will select the repo we will see two tools API click on Save now click on new web services click on this connect tools API to name a unique so it will be choose API branches main root directory runtime node build command Nothing free click on the free tier and create web service so it is deploying let's wait okay so our services live now yeah we can go to this site so we can click on slash tools and our tool should be printed here okay power tools are getting printed and our service is live so from here we will click on if you are not signed up or logged in then you have to sign up or login after that you have to go to you have to go to my apis and from here you have to click on ADD API project let's give it a name of tools API description of tools API giving data from upper crawels category will be a business Commerce communication cyber security data database device if team will be personal let's click on ADD API project from here we will have verification on this we will have apis as public so the website link will be the link which you have got from the render so it is this one so click just copy this and paste this here visibility is public base URL so you can click on ADD URL paste this base URL and click on Save now after that we have to click on adding an end point so click on here definitions click on end points and from here click on create rest endpoint name your endpoint so get tools data get tools data from a number travels and here it will be slash it will be to now from here tools we will have to request so example response will be Response Code will be 200 add Response Code this is okay this is okay valid example you can also set up security so just click on save you can just add a Gateway so Gateway DNS will be wrapped let's come to monetize so after that so let's reduce this to 500 per month let's click on Save changes so for basic it will be zero dollars and 100 per month and after that pop Pro we will have so let's click on edit plant I believe monthly subscription and the subscription price will be let's say five dollars and request per hour with 1000 1000 and this will be the recommended plan let's click on Save changes and this will have a hundred thousand per month and the ultra will have the pricing of let's say 25 and 1000 requests let's preconceive changes let's decrease it to 5000. click on Save changes let's decrease this to 50 000 and click on Save changes okay so our API has three prices basic Pro and Ultra let's click on V1 Hub however API looks like is tools API by the or Gmail updated a few minutes ago it's in travel and point from here you can just click on pricing these all are the pricing so you can click on test endpoint it will test the end point so this is the kind of data which you get from the API okay so it is showing all the data good but you can only call this for like 500 times per month for basic plan for you can call this API 5000 times per month for five dollars you can call this API 50 000 times you can have a request fifty thousand per month for 25 dollars so this is how this will work so this was the whole process and how you can uh deploy your API on rapid API and how you can set up all the pricing all the deployment on render how you can create your API I hope you have liked this video you uh learned something new and if you like this video make sure you like the video uh you commented out like if you have any issues you can comment it out comment out that yeah you like the video so that this video reaches to more and more people and I think you will also like this video on which I have shared 50 resources which only top one person web developers know so you can watch this video next and let's meet in some next video bye [Music]
Info
Channel: TechCreators
Views: 4,716
Rating: undefined out of 5
Keywords: what is an api, restful api, rest api, rapid api, rapidapi, rapidapi hub, startup idea, selling api, software development, express routing, cheerio, nodejs, web scraper, news api, build news api, climate change api, ania kubow, coding, coding tutorial, nodejs tutorial, nodejs project, backend developement, techcreators, divasraj vimal, web development, web developer, tours api, web scrapper, tours api data
Id: TE7ZalOe0y4
Channel Id: undefined
Length: 24min 3sec (1443 seconds)
Published: Wed Sep 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.