Lookup channel by name - slack-api

Is there an API to look up the channel ID by the channel name? What I basically need is to find the IDs of members in a channel and I only know the channel name. What would be the easiest way to do it. Thank you.

Unfortunately there is no single call API to do that.
You'll need a couple of API calls to do that.
Firstly, you need to get the list of channels available in the workspace.
https://api.slack.com/methods/conversations.list
Then, match the channel name & get the Channel Id.
Using this channel Id, you can get list of members:
https://api.slack.com/methods/conversations.members
Ideally, you should use channel Id instead of channel Name
But if your use case does not allow that, you can use the given solution.

Related

How to search for a message by a specific ts

I am trying to get the parent message of a threaded reply with the Slack API. When a new reply is put, it has a "thread_ts" attached to it, which corrsponds to its parent message's "ts". I tried to do a searchall with the ts as the query but this didn't work. How would I do this?
See Slack's docs on retrieving a single message with channels.history. This "selecting 1 item from a range" approach should also work with other channel history methods and conversations.history.
The easiest way is to provide the thread_ts value you want to look up as the latest parameter to conversations.history, along with the containing channel ID as channel, and a limit of 1 to ask for a single message. You will need the corresponding *:history scope to make the request.
Example:
GET /api/conversations.history?token=TOKEN_WITH_CHANNELS_HISTORY_SCOPE&channel=C2EB2QT8A&latest=1476909142.000007&inclusive=true&limit=1

Get all videos for a given user

I'm trying to find a way to retrieve all videos posted by a given user (eg: https://www.youtube.com/user/laliga/videos).
All the examples I've found online or the doc (https://developers.google.com/youtube/v3/docs/) seems to require either a playlist ID, channel ID or video ID.
Is there any way I can directly query the author's videos or am I forced to retrieve all playlists and then iterate over?
Thanks
You just need to map the user name to its channelID first via the YouTube API like so:
https://www.googleapis.com/youtube/v3/channels?forUsername=USER_NAME&part=id&key=API_KEY
Full docs: https://developers.google.com/youtube/v3/docs/channels/list
Then you can make a Videos:List call with that channelID to get the videos.
1)take your google key id and channel id and put inside below url
https://www.googleapis.com/youtube/v3/search?key=APIKEY&channelId=CHANNELID&part=snippet,id&order=date&maxResults=20
ex
https://www.googleapis.com/youtube/v3/search?key=adsjsdakhkjshd&channelId=sdahghsadhgj&part=snippet,id&order=date&maxResults=20

Searching the youTube V3 API via channel name not username?

Youtube allows a username and channel name. They can be different from each other. The youtube API allows me to search via username but I can't see where or how to search by channel name. It is the channel name that is displayed under the videos.
Anyone shed some light onto how I can search via channel name/title and not username?
Thanks
If the channel search API didn't return a result I call the search API
https://www.googleapis.com/youtube/v3/search?part=snippet&type=channel&maxResults=1&q=(<# potential channel name #>)
So it runs a standard search for entered value "potential channel name". Google docs say the first returned result will be a channel so we only need 1 result which is why we set maxResults=1.
If that returns nothing then I assume channel does not exists and display error to user
This works with me, just change the key with your api-key
url1="[https://www.googleapis.com/youtube/v3/search?part=snippet&type=channel&maxResults=15&q=Inna&key=[YOUR-API-KEY]"
r = requests.get((url1))
print(r.content)
It returns all channels with names that contain the word Inna
Hope this can help you

Youtube - How to browse all channels in a given category?

For example, there are 884 channels under beauty and fashion, however, Youtube only shows about 50 of them. How do i get the complete list? Either through API or web.
https://www.youtube.com/channels/beauty_fashion
Thanks,
The first thing to do is to get the Guide Category ID that you're interested in. If you do a call to
https://www.googleapis.com/youtube/v3/guideCategories?part=snippet&hl=en&regionCode=US&key={YOUR_API_KEY}
where the hl parameter is the language and the regionCode is the country code (as some categories may not be available for particular languages/regions), you'll get a list of all the categories and their IDs.
For example, that call tells us that the Beauty and Fashion guide category ID is GCQmVhdXR5ICYgRmFzaGlvbg. With that ID, we can then do a channels list call:
https://www.googleapis.com/youtube/v3/channels?part=snippet&maxResults=50&categoryId=GCQmVhdXR5ICYgRmFzaGlvbg&key={YOUR_API_KEY}
This will give you 50 channels in that category. It will also give you a 'nextPageToken' ... you do the same request as above, but add "&pageToken={WHATEVER THAT NEXT PAGE TOKEN VALUE IS}" to get the next 50, and so on.
You can retrieve up to 500 that way ... that's the limit through the API.
Note that all of these calls require an API key from console.developers.google.com
Visit this site: http://www.channelcrawler.com/
You can list the channel in selected category and many other options.

youtube analyticsService Report parameters

I am authenticating with google to try and get youtube analytics my problem is that i don't know how to filled you the parameters when quering youtube
here i am making a new service: and then try to query it
I am not sure what to put in the "ids" parameter or where to find it?
What do I put there?
_analyticService = new YoutubeAnalyticsService(_authenticator = CreateAuthenticator());
...
_analyticService.Reports.Query("ids", "2013-01-01", "2013-02-02", "views").Fetch();
The ids parameter is the an expression with the id of your channel. If you go to http://www.youtube.com/analytics and click on the title with your own channel name, you get a link like http://www.youtube.com/channel/UCYHMS8hN8s49F93iJuEgG6w The last part is the id of your channel. You have to use this as the ids parameter in an expression like "channel==UCYHMS8hN8s49F93iJuEgG6w". This is to query in the context of your own channel. This is needed as you might have access to several channels.
I can query views for one of my videos by: https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DUCYHMS8hN8s49F93iJuEgG6w&start-date=2013-01-01&end-date=2013-02-02&metrics=views&dimensions=day&filters=video%3D%3D_iwmv6644dA&sort=day&key={YOUR_API_KEY}
Try to use the API explorer at the bottom of this page, there are some text explaining the different parameters there as well. https://developers.google.com/youtube/analytics/v1/
Hope it goes well!

Resources