get all channel info with youtube api and curl - json

Hey guys i was perusing the youtube api documents and saw this json snippet right here: https://developers.google.com/youtube/v3/docs/channels#resource-representation
I saw this and would like to grab all this info from the specified youtube channel in my curl code. So far all i wrote was this:
curl "https://www.googleapis.com/youtube/v3/channels?part=statistics&id=[CHANNEL NAME]&key=[API KEY]"
but that only gives back a small part of that json, i think its the "statistics" part.
If yall can help that would be so kind, thanks.

To get the other info attached to a given channel, do mention the set of properties you're interested in via the part parameter, as specified by the reference doc.
Update:
To get all the info available, the URL to be passed to curl would be:
https://www.googleapis.com/youtube/v3/channels?part=brandingSettings,contentDetails,contentOwnerDetails,id,localizations,snippet,statistics,status,topicDetails&id=[CHANNEL NAME]&key=[API KEY]
Note that the part parameter does not contain auditDetails since that requires additional permissions.

Related

Can I utilize cURL parameters without using cURL?

This is probably a stupid question but I'm pretty out of my depth here. I'm trying to utilize an API for my business, and while most of the API has the parameters in the form of "site?param1=one&param2=two", one of them does not. Instead it's in the form
required parameters -> key
optional parameters
params: a key-value array of where clauses for the query
I would love to be able to put the parameters in directly in the link, but I'm not sure how to parse this or if it's possible.
Example
https://thepetresorts.gingrapp.com/api/v1/animals?key=KEY&params=[{animal_id=1},{name=Charlie}]
This is the example they provided using cURL, but I'm really not interested in actually programming with the API, I just need to make specific pulls every once in a while, and I cannot for the life of me figure out how to utilize cURL.
curl "https://{your-subdomain-here}.gingrapp.com/api/v1/animals" \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
--data-urlencode "params[month(from_unixtime(birthday))]=11" \
--data-urlencode "key={your-key-here}"
Any advice would be extremely appreciated!
If you're working with an API, it's even better if you can use POSTMAN or INSOMNIA.
The API your describing has two types of requests, GET and POST - the GET request is usually used to "get to view" but occasionally some use it to also modify and push data - this uses parameters within the URL (what you described), POST however is generally used to push data into the body to make a modification, the parameters are posted within the body of the request instead of in the actual URL like GET requests.
You won't be able to modify the endpoint (unless its your own) you will need to GET where its needed and POST when its needed, the POST request will likely deny a GET request as it's not the intended method - you can create a jump page (your own API) to accept GET parameters and generate a POST request to your API - as #muklis mentioned POSTMAN is great you can create the request in there, generate the code in any language and use that to produce a simple PHP page or so that'll take in $_GET[] variables and pass them into the generated POSTMAN request - it's probably your best bet.
-- Edit
You can also use Zapier, forgot about that - Zapier is amazing for easy code-less integrations; you can use the Webhook zap to receive your parameters in repost them in two easy steps within the zap.
Just another idea for you.

Twitter API for Non-public/organic/promoted metrics in Google Script

I'm trying to use the Twitter API in Google Script to get the non-public metrics of my posts.
I believe have done all of the authentication properly since I am able to get the information when using Postman. I have generate a consumer_key, a consumer_secret, an access_token, and a token_secret.
According to the twitter documentation , I MUST use Oauth1.0 (https://developer.twitter.com/en/docs/twitter-api/metrics).
In order use the Oauth1, I used Google's own script for Twitter Oauth1 (https://developers.google.com/google-ads/scripts/docs/examples/twitter-oauth10).
I was able to take that code (along with the library it required) and successfully retrieve the tweets for my username.
My attempt to get the non_public metric was replacing the "https://api.twitter.com/1.1/statuses/user_timeline.json" with the GET request I had from POSTMAN but it returned a "401 error".
I have a hunch that I can't just replace that url with my own but I am unsure how to approach it.
In summary:
Tokens/Twitter Authorization/GET request are written properly since they work in Postman
Google Script is writing properly since the default URL works
Unsure how to replace the default url to accomplish different tasks
Ended up figuring it it out!
I was not supposed to pass the entire url as a replacement for "https://api.twitter.com/1.1/statuses/user_timeline.json".
It is supposed to be replaced by the "base" url. In my case this was "https://api.twitter.com/2/tweets".
I then had to change the variable "params" that feed into it.
note that the params is from the code provided by Google in my original post
They have to be in the following format (https://developer.twitter.com/en/docs/tutorials/twitter-api-google-sheets):
params = {
"tweet.fields": "author_id,created_at,lang",
"ids": "21,1293593516040269825,1334542969530183683",
}
I was able to add my own fields such as "non_public_metrics,organic_metrics" to get:
params = {
"tweet.fields": "author_id,created_at,lang,non_public_metrics,organic_metrics",
"ids": "21,1293593516040269825,1334542969530183683",
}
I hope this helps someone someday :)

Get Data info from a certain page- MediaWiki API

I'm very new to the api system and i was wondering how to get data from a certain page. So my link is:
https://nookipedia.com/w/api.php
but i want to get my api from this page:
https://nookipedia.com/wiki/Bugs/Animal_Crossing:_New_Leaf
but when i try this:
https://nookipedia.com/wiki/Bugs/Animal_Crossing:_New_Leaf/w/api.php
the link doesn't work and gives me this error:
Error 404: Not found
The requested page or file could not be found on our server. It may have been moved or deleted.
How would i get that certain page?
I suggest you play around with the API sandbox on Wikipedia to see how queries are built. You will still need to read the actual API documentation to get useful information...
Basically, you want to pass the title(s) as a parameter to api.php, like so:
https://nookipedia.com/w/api.php?titles=Bugs/Animal_Crossing:_New_Leaf
However, this will still get you no information by itself; you need to know what data you want exactly, and use the correct API module with the appropriate parameters. For example, to get all the categories of a page:
https://nookipedia.com/w/api.php?action=query&titles=Bugs/Animal_Crossing:_New_Leaf&prop=categories
For this specific example, you can see the documentation for the Query API and the Categories property:
API:Query
API:Categories

Unable to get accurate results from Browserlocation API with curl

I'm trying to get the current location of my computer from Google's BrowserLocation API.
How to create a script to query Google Browserlocation: This thread helped me construct the script, but one problem remains: the accuracy is way off when using curl from the command line: "accuracy" : 11178. Bafflingly, if I copy-paste the same address in my browser, the returned JSON is perfectly fine with an accuracy of "accuracy" : 52.
What could the crucial difference be, and how do I modify the curl script to work like my browsers do? There is JSON, CURL and Google's geolocation this previous thread with what appears to be a similar issue, but the solution posted does not help me.
I have Wireshark, and a capture of the two methods of accessing the API. I am currently trying to figure out how to retrieve the relevant packets for inspection. If anyone can help me with this intermediate step, that would be most welcome.
Well I got it to work. The issue was that I didn't URL escape the names of the access points. Look here for how to do this with Perl.

Is there a programmatic way to edit a Brightcove video's reference ID?

The example on the Brightcove site provides the JSON needed to update tags for a particular video in my library:
{"method":"update_video","params":{"video":{"id":"123456",
"shortDescription":"vidDesc","Name":"vidName","startDate":1392912992000,
"endDate":null,"tags":["tag1","tag2","tag3"]},"token":"someToken.."}}
I've tried this, and it works.
But when I try to post something similar but with an updated reference ID, like this:
{"method":"update_video","params":{"video":{"id":"123456",
"shortDescription":"vidDesc","Name":"vidName","startDate":1392912992000,
"endDate":null,"referenceId":"newReferenceId","token":"someToken.."}}
I get this error back from the service:
{"error": {"name":"MissingJSONError","message":"Could not find JSON-RPC.",
"code":211}, "result": null, "id": null}
I've tried passing it as ref as well - no dice. Does anyone know if it's possible to update this value via any means other than Brightcove's web portal?
Make sure you're sending the JSON as form data rather than in the post body.
e.g. with curl,
curl -F 'json={"method":"update_video","params":{"video":{"id":"123456789","referenceId":"newrefid"},"token":"myToken"}}' https://api.brightcove.com/services/post