Batch processing for Youtube Data API in Node.js - javascript

I am trying to make a request to the Youtube API for multiple video ids, and understand that this is referred to as 'batch processing'.
So far I have successfully made individual requests by appending the video id, request parameters and API key to the following url for the request:
https://www.googleapis.com/youtube/v3/videos?
becomes:
https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics,player&id=ZYpxsJHVC-0&key=
Using this method I am able to retrieve data for multiple videos by comma separating multiple ids after 'id=' in the request url. I think that I am doing something similar to the video.list property mentioned in this post: YouTube API v3 batch processing and documented here: https://developers.google.com/youtube/v3/docs/videos/list#request
Is there some other batch processing method I should be using instead of adding 50 different video ids to the request url? Considering I am using Node, it seems like using Google's Node.js client library would make sense, but I couldn't find documentation on how to make specifically Youtube Data API requests.
The API Client Library for Javascript ( https://developers.google.com/api-client-library/javascript/features/batch#batch-request-promise ) actually sounds exactly like what I need because it supports promises, however the doc page doesn't mention how to download it. I was hoping to find some sort of 'npm install' command, but its not there. If this is the recommended method for going about retrieving video data for multiple videos, could someone point me in the right direction as far as implementing this library in my project? Thanks!

Google wants you to call their API Client Library for Javascript directly from their servers, as you can see in their authSample script:
<script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>
Google has also released Node.js libraries that can be installed using npm. These installation instructions are for the Calendar API, but the package may also include the YouTube API. Please let us know!

Related

How do I prevent the Google API from being used by others?

I'm going to make a project using the Google translate api and I'm thinking of uploading this project to a server and just sharing it with my friends. But unfortunately the Api Key that I will use in the project can be accessed clearly in the JavaScript file. This is a very bad situation. To prevent this, I have limited the Google Cloud Api and as far as I understand it is only allowed to be used on the links I allow. It cannot be used on other links. Now my main question is, is this method enough to protect Api from malicious people? Do I need to do anything else? Thank you in advance for your answers.
Best practice in these cases is to use .env files to keep data like API keys private.
You have to create a server for that which will perform OAuth and then send an API request to google.
You can get help about how to implement OAuth from this topic provided by google: https://developers.google.com/identity/protocols/oauth2/javascript-implicit-flow
If you send/attach your API key in frontend like javascript which is basically a frontend language then it can be used to:
Send fake requests which will use all of the bandwidth etc.
You should also consult the TOS.
On November 5th 2014 Google made some changes to the APIs terms of Service.
Like you I had an issue with the following line.
Asking developers to make reasonable efforts to keep their private
keys private and not embed them in open source projects.
That is however really only an issue if you are releasing the source code of your app as an Open source project for example.
If your just hosting this on a server then what you shoudl do is set up limitations for the api key adding_application_restrictions you can limit it so that the api key can only be used from your server and no where else.

Get steamID with Steam API using javascript

First off sorry if this question is a 'bad' one; I am very new to the world of web apps, API's and Javascript.
As the title says I am trying to get a user's steamID using the Steam API using javascript.
This is for a web app that needs to get information about the games a user plays. (Which from my understanding is only obtainable using this special ID.)
My initial thoughts on how to do this would be to use openID so that the user gives Steam their info and the ID is returned to my app.
I have seen that there are lots of examples of this using php; however, because of project requirements, everything must be run in the browser. There is no backend server to even run php on so it is not an option what so ever.
I have spent a better part of a day trying to figure this out and have made no real progress, everything seems to lead back to using php. (maybe what I need under my requirements is not possible?) So an example or anything really would be much appreciated.
welcome to Stack Overflow I can see you are confused as to where to start or progress so here is a basic roadmap:
You will need to contact Steam to get an API key first.
Next part is more tricky for a beginner. You will need to get node.js which is a package manager. Effectively it's a large library of javascript programs which you can import into your own program to do things with. One of these so called "packages" is openid-client, which is an implementation of openID that you can add to your site. Users click on the openID button on your site, it redirects them to steam servers, they login, then your site gets their info without leaking their username or password to you.
Now that you have both the steamID and your API Key your program can input these two into the url steam provides to get owned games. You can input this completed url into fetch or axios (another node package that can request data from servers) and it will respond with the user's owned games in json format.
Here are a list of resources in order to get you started:
https://steamcommunity.com/dev
https://nodejs.org/en/
https://www.npmjs.com/package/openid-client
https://www.npmjs.com/package/node-fetch OR https://www.npmjs.com/package/axios
https://developer.valvesoftware.com/wiki/Steam_Web_API#GetOwnedGames_.28v0001.29
I suggest reading the documentation in each of these links and seeing if there is any youtube tutorials that try and do what you are doing with these technologies to help you implement them as a newbie. Overall there is a lot to learn on each of these technologies but as long as you orient yourself using guides or tutorials you will succeed. Good luck.
Check out this page: How to retrieve Steam username using SteamWorks API?.
However, it seems like an issue you might be having is connecting to the actual API. What exactly are you using for testing?
I know from experience, for example, that you can connect using Postman to various API's, and format a request for them in a chosen language, including JS>

Publishing data from an array to a google spread sheet

I am working on a project where I run a web page from a local server using Xampp. In the web page I have a button which when clicked produces an array of 24 elements. I want this array to be written to my online google sheet.
My Question:
1)Can I post data from a web page running on a local server like Xampp to an online server like google sheet?
2)If yes, then is it possible to do it with php and javascript without any jquery?
3)If it is possible please show me the right path.
I am new to web development. Please help me. Thank you in advance for helping.
Yes it is possible to post data from your localhost as long as you have an internet connection.
to do such things I recommend you to read Sheets API Guides
You will also find there a sample code to write data to a spreadsheet on this page
Still an API key is required for public spreadsheets for other requests you need to use OAuth 2.0 as told here
If the request requires authorization (such as a request for an individual's private data), then the application must provide an OAuth
2.0 token with the request. The application may also provide the API key, but it doesn't have to.
If the request doesn't require authorization (such as a request for public data), then the application must provide either the API key
or an OAuth 2.0 token, or both—whatever option is most convenient for
you.
also as an advice and if you know javascript you could use Google App Script to get Started, after validating the implementation of the library into your project and console you will find built-in functions.

How can I upload a file to dropbox via javascript?

I am trying to allow users to upload large files without tying up my servers for an extended amount of time. I thought using dropbox as file storage might be a good solution. My plan is to use javascript to have the client-side connect directly to dropbox, so that my server is not affected.
I have been trying to find a current javascript dropbox api, but have not had much success. I tried using dropbox-js, but it seems that it is using an outdated version of the API as I get the following error with my current test: {"error": "You're using an older version of the Dropbox API with a new API key. Please use the latest version."}
Does anyone know a fairly simple way to accomplish this task?
Set up your application as a Folder app. If things go wrong, at least you won't blow up people's Dropboxes.
Follow these directions for obfuscating your API key and secret.
Use writeFile to upload the files, and then use makeUrl with the downloadHack: true option, then send the URL to your server.
You'll need the git version of dropbox-js to use downloadHack until the 0.7.0 release comes out.

How to make Twitter application that shows me tweets from specific trends?

I am planning to make a web application which will just show me all the tweets for a specific trending topic. For example, if I have #WebTech #SEO #SHARE, I want to see all the tweets for this trend. Can you tell me how to get along with it? I have knowledge about programming and I would like to make it using the JavaScript APIs may be using the REST in JavaScript. Please let me know the API and the method in which I can do this. I don't want to authenticate a user. I just want to show them the trending topics. Please help.
I prefer the streaming API for stuff like this.
If your interested in the streaming API, it can be used for this but will requires quite a bit of work to really get it to be good enough for production.
However you would have to use a server side language to open the stream so it will be secure and parse the json into a database or straight json file. You could then have javascript use these as a data source.
These resources are invaluable for getting started with the streaming API.
PHP READING STREAM
http://hasin.wordpress.com/2009/06/20/collecting-data-from-streaming-api-in-twitter/
TWITTER STREAM API
https://dev.twitter.com/docs/streaming-api/methods#track

Categories

Resources