For the channel.list function of the YouTube API are you able to call statistics for any channel on YouTube? Reviewing the below call parameters it seems all require you to be the owner of that channel to receive any information on that channel.
I've also tried the API test to see if I can receive data by username for the channel but doesn't seem to work. Beginner so if anyone could help out I'd much appreciate it!
https://developers.google.com/youtube/v3/docs/channels/list?apix_params=%7B%22forUsername%22%3A%22Peter%20McKinnon%22%7D
You do not need to be the owner of the channel you just need the channel Id. You can tests this using the try me on channel.list its a public api call.
request
GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&id=UCeY0bbntWzzVIaj2z3QigXg&key=[YOUR_API_KEY] HTTP/1.1
Accept: application/json
response
{
"kind": "youtube#channelListResponse",
"etag": "y2BDT1Qkcr2Fm2FAHjDfG6Gn8Sc",
"pageInfo": {
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "VCwefXyl53bCqIREF0zJeTfxZXk",
"id": "UCeY0bbntWzzVIaj2z3QigXg",
"snippet": {
"title": "NBC News",
"description": "» Subscribe to NBC News:",
"customUrl": "nbcnews",
"publishedAt": "2006-07-19T20:46:03Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/a/AATXAJzjPejETKc2lrL43-9gFFWRL9WKwEmOIvtbWyait1c=s88-c-k-c0xffffffff-no-rj-mo",
"width": 88,
"height": 88
},
"medium": {
"url": "https://yt3.ggpht.com/a/AATXAJzjPejETKc2lrL43-9gFFWRL9WKwEmOIvtbWyait1c=s240-c-k-c0xffffffff-no-rj-mo",
"width": 240,
"height": 240
},
"high": {
"url": "https://yt3.ggpht.com/a/AATXAJzjPejETKc2lrL43-9gFFWRL9WKwEmOIvtbWyait1c=s800-c-k-c0xffffffff-no-rj-mo",
"width": 800,
"height": 800
}
},
"localized": {
"title": "NBC News",
"description": "» Subscribe to NBC News: "
}
},
"contentDetails": {
"relatedPlaylists": {
"likes": "",
"favorites": "",
"uploads": "UUeY0bbntWzzVIaj2z3QigXg",
"watchHistory": "HL",
"watchLater": "WL"
}
},
"statistics": {
"viewCount": "1942288925",
"commentCount": "0",
"subscriberCount": "3700000",
"hiddenSubscriberCount": false,
"videoCount": "25734"
}
}
]
}
Related
Introducing handles: A new way to identify your YouTube channel
Does the YouTube Data API support querying for a channel by it's #handle? This does not seem to be supported.
ex: https://www.youtube.com/#lionsgatemovies
forUsername param
GET https://www.googleapis.com/youtube/v3/channels?part=id,snippet&forUsername=#lionsgatemovies
{
"kind": "youtube#channelListResponse",
"etag": "RuuXzTIr0OoDqI4S0RU6n4FqKEM",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
}
}
id param
GET https://www.googleapis.com/youtube/v3/channels?part=id,snippet&id=#lionsgatemovies
{
"kind": "youtube#channelListResponse",
"etag": "RuuXzTIr0OoDqI4S0RU6n4FqKEM",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
}
}
None of the supported filter params seem to be appropriate:
{
"error": {
"code": 400,
"message": "No filter selected. Expected one of: mySubscribers, forUsername, mine, managedByMe, categoryId, id",
"errors": [
{
"message": "No filter selected. Expected one of: mySubscribers, forUsername, mine, managedByMe, categoryId, id",
"domain": "youtube.parameter",
"reason": "missingRequiredParameter",
"location": "parameters.",
"locationType": "other"
}
]
}
}
You can use Search API with q parameter set to #handle
curl \
'https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&q=%40kevinrooke&type=channel&key=[YOUR_API_KEY]'
{
"kind": "youtube#searchListResponse",
"etag": "AYlro9VG2vMtdew4OQiWoQM8Rs0",
"regionCode": "LT",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "ls9E_ctoa-RLsqznJwxWlHHIE1s",
"id": {
"kind": "youtube#channel",
"channelId": "UCTdxV_ItCZMayyzGkw7P_qQ"
},
"snippet": {
"publishedAt": "2017-05-27T03:56:38Z",
"channelId": "UCTdxV_ItCZMayyzGkw7P_qQ",
"title": "Kevin Rooke",
"description": "Interviews with the builders bringing the Lightning Network to life. ⚡kerooke#fountain.fm.",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu-SpmaNjx7KOMqs5Cr7ZthU60BaQApzt89_dHOlcg=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu-SpmaNjx7KOMqs5Cr7ZthU60BaQApzt89_dHOlcg=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu-SpmaNjx7KOMqs5Cr7ZthU60BaQApzt89_dHOlcg=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "Kevin Rooke",
"liveBroadcastContent": "none",
"publishTime": "2017-05-27T03:56:38Z"
}
}
]
}
As of this moment (17th Nov 2022), YouTube has yet to update the Data API with #handle support.
The channelId was scattered around in the Html. You can easily parse them after fetching the url with the handle.
const html = await(await fetch(url)).text()
const channelId = html.match(/(?<=channelId(":"|"\scontent="))[^"]+/g)[0];
Following is the python snippet while we are waiting for YouTube API's official support. This is inspired by goodhyun's wonderful thoughts.
import requests
import re
# return YouTube channel id via handle or False if failed
def scraping_get_channel_id_from_handle(handle:str):
if handle.find('#') == -1:
handle = '#' + handle
url = 'https://www.youtube.com/' + handle
resp = requests.get(url)
if resp.status_code == 200:
found = re.findall('"channelId":"([^"]*)","title"', resp.text)
return found[0]
else:
return False
I'm integrating MPGS (Mastercard Payment Gateway Services). I want to use token to pay. But when I call the API Transaction "Pay", I get the wrong result. I want to know what went wrong. Thank you very much.
This is my payment process:
Use hosted checkout to complete the payment and save the sessionid of successful payment
Use the sessionid obtained in the first step to get the token and store the token
Reference API: POST /api/rest/version/62/merchant/{merchantId}/token
RequestBody:
{
"session": {
"id": "SESSION0002130457496K8245619M90"
}
Create session and obtain the sessionid and OrderID.
Reference API: Session: Create Checkout Session
Use Transaction: Pay to start payment
Reference API:Transaction: Pay
RequestBody:
{
"apiOperation": "PAY",
"order": {
"amount": 10.55,
"currency": "HKD"
},
"session": {
"id": "SESSION0002249161342J64341132I3"
},
"sourceOfFunds": {
"token": "5123456709720008",
"type": "SCHEME_TOKEN",
"provided": {
"card": {
"expiry": {
"month": "01",
"year": "39"
},
"storedOnFile": "TO_BE_STORED"
}
}
},
"transaction": {
"source": "INTERNET"
},
"agreement": {
"id": "m599944354",
"type": "UNSCHEDULED"
}
}
Response
{
"agreement": {
"id": "m599944354",
"type": "UNSCHEDULED"
},
"gatewayEntryPoint": "WEB_SERVICES_API",
"merchant": "myMerchantId",
"order": {
"amount": 10.55,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"chargeback": {
"amount": 0,
"currency": "HKD"
},
"creationTime": "2022-05-19T08:08:43.740Z",
"currency": "HKD",
"id": "2022051520752464800620225416016",
"lastUpdatedTime": "2022-05-19T08:08:43.754Z",
"merchantAmount": 10.55,
"merchantCategoryCode": "4812",
"merchantCurrency": "HKD",
"status": "FAILED",
"totalAuthorizedAmount": 0,
"totalCapturedAmount": 0,
"totalDisbursedAmount": 0,
"totalRefundedAmount": 0
},
"response": {
"gatewayCode": "BLOCKED"
},
"result": "FAILURE",
"risk": {
"response": {
"gatewayCode": "REJECTED",
"review": {
"decision": "NOT_REQUIRED"
},
"rule": [
{
"data": "NO_LIABILITY_SHIFT",
"name": "MSO_3D_SECURE",
"recommendation": "REJECT",
"type": "MSO_RULE"
},
{
"data": "512345",
"name": "MSO_BIN_RANGE",
"recommendation": "NO_ACTION",
"type": "MSO_RULE"
}
]
}
},
"sourceOfFunds": {
"provided": {
"card": {
"brand": "MASTERCARD",
"expiry": {
"month": "1",
"year": "39"
},
"fundingMethod": "CREDIT",
"number": "512345xxxxxx0008",
"scheme": "MASTERCARD",
"storedOnFile": "TO_BE_STORED"
}
},
"token": "5123456709720008",
"type": "CARD"
},
"timeOfLastUpdate": "2022-05-19T08:08:43.754Z",
"timeOfRecord": "2022-05-19T08:08:43.754Z",
"transaction": {
"acquirer": {
"id": "Myid",
"merchantId": "myMerchantId"
},
"amount": 10.55,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"currency": "HKD",
"id": "tran-14",
"source": "INTERNET",
"stan": "0",
"type": "PAYMENT"
},
"version": "62"
}
Problem points:
Is my method of obtaining token correct?
Whether the method of using "Transaction: Pay" is correct, and whether the parameters of request body are missing
Why is the order.authenticationStatus="AUTHENTICATION_NOT_IN_EFFECT" in the response in step 4? What "There is no authentication information associated with this transaction." means?
You need to update CARD Details using SESSION UPDATE and then make a payment using PAY.
Ensure the 3DS scheme is verified before attempting to PAY.
You don't need to provide card expiry details again in the API request body as it is already stored in the token.
Your transaction is getting BLOCKED because of Risk Rejection rule
"NO_LIABILITY_SHIFT"
"rule": [
{
"data": "**NO_LIABILITY_SHIFT**",
"name": "MSO_3D_SECURE",
"recommendation": "**REJECT**",
"type": "MSO_RULE"
}
]
The "NO_LIABILITY_SHIFT" rule is triggered when in the Merchant Admin Portal -> Transaction Filtering -> 3-D Secure Rules ->No Liability Shift -> "Reject" Screenshot and you are trying to perform Pay operation without 3DS authentication as otherwise in case of fraud or chargeback the liability will be on the merchant and acquirer side.
You need to perform EMV 3DS authentication before Pay operation. https://eu-gateway.mastercard.com/api/documentation/integrationGuidelines/supportedFeatures/pickAdditionalFunctionality/authentication/3DS/3DSecureAuthentication.html?locale=en_US
When querying archival node for transactions with EXPERIMENTAL_tx_status method, some transactions have no receipts while having receipts_outcome. How is that possible, and how is that transaction different from others?
If I understand correctly, receipts_outcome are the results of applying receipts. According to explorer, this transaction has Convert Transaction To Receipt part, so there should be some receipts generated.
According to documentation
A Receipt is the only actionable object in the system. When we talk about "processing a transaction" on the NEAR platform, this eventually means "applying receipts" at some point.
A good mental model is to think of a Receipt as a paid message to be executed at the destination (receiver). And a Transaction is an externally issued request to create the Receipt (there is a 1 to 1 relationship).
My query
{
"jsonrpc": "2.0",
"id": "2",
"method": "EXPERIMENTAL_tx_status",
"params": ["7beNxrbHxMRspJWT9NeEVwx719kVcmY9tRdPG9SYro26", "bumbleee99.near"]
}
Response
{
"jsonrpc": "2.0",
"result": {
"status": {
"SuccessValue": ""
},
"transaction": {
"signer_id": "bumbleee99.near",
"public_key": "ed25519:DFM5GRGbpNkk4XkhcFnRUFeKG8a3nzTH8NwZp754pC48",
"nonce": 59080995000003,
"receiver_id": "bumbleee99.near",
"actions": [
{
"AddKey": {
"public_key": "ed25519:CUoNs153GHrPZ9F8HpvhzFr1mwuUFUdGQsRNE2CTNjVH",
"access_key": {
"nonce": 0,
"permission": "FullAccess"
}
}
}
],
"signature": "ed25519:15v34qoyCHSvSL5uLcaPqD9vXvjcPrCaZVStCMms8e58C62z2UHiazwUXzHajPEgdHpwn7s4J9dd5UPmtvzbYgM",
"hash": "7beNxrbHxMRspJWT9NeEVwx719kVcmY9tRdPG9SYro26"
},
"transaction_outcome": {
"proof": [
{
"hash": "ECKDm5FVhzit7Wqs9sEyBB9NtuTrVRZmWwcxkkg2yUh4",
"direction": "Right"
},
{
"hash": "E4VXdwsNj3fZCbP6y9YH3M5oZHPDcdArqU9kbZJa95Qp",
"direction": "Right"
}
],
"block_hash": "ASY6HgDUQUXUa99L7dPEfghKEnEk5SNkwQrx24u3Fobz",
"id": "7beNxrbHxMRspJWT9NeEVwx719kVcmY9tRdPG9SYro26",
"outcome": {
"logs": [],
"receipt_ids": [
"JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
],
"gas_burnt": 209824625000,
"tokens_burnt": "20982462500000000000",
"executor_id": "bumbleee99.near",
"status": {
"SuccessReceiptId": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
},
"metadata": {
"version": 1,
"gas_profile": null
}
}
},
"receipts_outcome": [
{
"proof": [
{
"hash": "8RwCWE9HgqenPKv8JW9eg2iSLMaQW82wvebYSfjPbdTY",
"direction": "Left"
},
{
"hash": "E4VXdwsNj3fZCbP6y9YH3M5oZHPDcdArqU9kbZJa95Qp",
"direction": "Right"
}
],
"block_hash": "ASY6HgDUQUXUa99L7dPEfghKEnEk5SNkwQrx24u3Fobz",
"id": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ",
"outcome": {
"logs": [],
"receipt_ids": [],
"gas_burnt": 209824625000,
"tokens_burnt": "20982462500000000000",
"executor_id": "bumbleee99.near",
"status": {
"SuccessValue": ""
},
"metadata": {
"version": 1,
"gas_profile": []
}
}
}
],
"receipts": []
},
"id": "2"
}
You could see that both transaction_outcome.outcome.receipt_ids and transaction_outcome.outcome.status are pointing to a receipt with ID JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ. I've tried querying node about this receipt with EXPERIMENTAL_receipt method like this
{
"jsonrpc": "2.0",
"id": "2",
"method": "EXPERIMENTAL_receipt",
"params": {"receipt_id": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"}
}
yet the node returns error indicating, that there is no receipt with given ID
{
"jsonrpc": "2.0",
"error": {
"name": "HANDLER_ERROR",
"cause": {
"name": "UNKNOWN_RECEIPT",
"info": {
"receipt_id": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
}
},
"code": -32000,
"message": "Server error",
"data": {
"name": "UNKNOWN_RECEIPT",
"info": {
"receipt_id": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
}
}
},
"id": "2"
}
TL;DR the receipt is a local receipt
The transaction from your example is a simple AddKey action where the sender is the receiver (remember this, it's important)
"Execute" transaction (means to convert the transaction into a Receipt)
Apply the Receipts
As the result of the conversion of the transaction into a receipt is your transaction_outcome
"outcome": {
"receipt_ids": [
"JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
],
"status": {
"SuccessReceiptId": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
},
This receipt is about to be applied and the predecessor_id and the receiver_id are equal. In nearcore such receipts are called local receipts (sir - sender-is-receiver) and those receipts are not stored in the nearcore database.
We emulate them on NEAR Indexer Framework side (that's why you can see Receipt JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ on the transaction details page on NEAR Explorer)
And because nearcore doesn't store such receipts in the database you got UNKNOWN_RECEIPT from the RPC.
I am sending below response to the service url provided by botFramework request https://telegram.botframework.com/v3/conversations/-263387177/activities/
My intent is that using sendMessage method of telegram I am able to route a text to the telegram channel via microsoft botframework
The http post which I am sending is as below
{
"type": "message",
"locale": "en-Us",
"chat_id":-263387177,
"channelID":"telegram",
"from": {
"id": "GTSFIBot",
"name": "sapeops"
},
"text":"hi , Greetings!",
"replyToId": "1505813737353",
"recipient": {
"id": "DirectLineClient"
},
"conversation": {
"isGroup": true,
"id": "-263387177",
"name": "sapeops group"
},
"channelData": {
"method": "sendMessage",
"parameters": {
"chat_id": -263387177,
"parse_mode": "HTML",
"text": "<B>Greetings! How are you doing?</B>"
},
"chat": {
"id": -263387177,
"title": "sapeops group",
"type": "group",
"all_members_are_administrators": true
}
}
}
I get 502 bad gateway response and a below JSON.
{
"error": {
"code": "ServiceError",
"message": "Telegram API returned a result code indicating non-success"
}
}
I am not getting "nextPageToken" in the response object when I tried to retrieve list of users who subscribed to our channels using YT Data API (v3) Subscription. For some reason YT not returning "nextPageToken" even though below channel has more than 100K subscribers so could you please advise me on how to be able to fetch next pages of subscribers. Same behavior happening when I tried with any of channels from our CMS account:
Request:
https://www.googleapis.com/youtube/v3/subscriptions?onBehalfOfContentOwner=xxxx&onBehalfOfContentOwnerChannel=xxxxxxxxxxx&fields=items(contentDetails,id,snippet(publishedAt,channelId),subscriberSnippet(title,description)),nextPageToken,pageInfo,tokenPagination&maxResults=50&mySubscribers=true&part=id,snippet,contentDetails,subscriberSnippet&key=xxxxxxxxxxxxxxxx
Here is sample response snippet (I trimmed out other 48 items from below list and intentionally masked out subscriber details)
{
"items": [
{
"snippet": {
"channelId": "UCUR8UieACc2QXl7waH821hQ",
"publishedAt": "2014-05-20T19:50:44.000Z"
},
"contentDetails": {
"newItemCount": 0,
"activityType": "all",
"totalItemCount": 51
},
"subscriberSnippet": {
"description": "",
"title": "Sebastian Brentsworth"
},
"id": "MVPSEm5kMooIHMvcBKqbtFJAp1dHw0GeHza2Iq5KXP"
},
{
"snippet": {
"channelId": "UCYs04YSyy1soNzyvsDljYVg",
"publishedAt": "2014-05-28T22:39:30.000Z"
},
"contentDetails": {
"newItemCount": 0,
"activityType": "all",
"totalItemCount": 51
},
"subscriberSnippet": {
"description": "",
"title": "Jason Chan"
},
"id": "Xd7_fS3FIA4rnSu6NXEfxF8trXzL8-LspvIuYtDMmc0"
}
],
"pageInfo": {
"resultsPerPage": 50,
"totalResults": 144403
}
}
"Known" (Hopefully also to Google) bug:
https://code.google.com/p/gdata-issues/issues/detail?id=7163 and youtube.subscriptions.list (api v3) - nextPageToken isn't available
For the time being, I've came up with a token generator as a workaround (see other SO post, or here: https://gist.github.com/pulsar256/f5621e85ef50711adc6f)