I want to retrieve all the messages that were sent in my teams slack domain,more than year.
i'm using channels.history method to retrieve the history of each channel,
But this method returns maximum of 1000 records only.
count 100 Optional, default=100
Number of messages to return, between 1 and 1000.
And i dont have access for https://my.slack.com/services/export to export all the data.
Also timesatmp is not way to get the desired data, beacuse my slack channel recived more than 1000 message per day
Are there any possibilities?
Yes, you can get all messages with channels.history for your situation. Here is how:
Call the method once to get the newest 1000 messages (1st chunk)
Call the method again with latest property set to the timestamp of
the oldest message you received in the last chunk and the
inclusive property set to false. This will get you the next
chunk of 1000 messages
Repeat until you received all messages
Remember that the rate limit is 1 call per second, so make sure you don't call the API more often.
Related
I am calling Twilio API to fetch messages history. The number of messages and segments returned by the API are different than it shows in the Twilio Usage section. The end point I am calling to fetch the messages list is:
https://api.twilio.com/2010-04-01/Accounts/Account_SID/Messages.json
Please see the stats returned by Usage API for April 14, 2021 in the screenshot below:
You can see in the screenshot that the number of messages returned are 685 while the messages API is returning only 561 messages. Why is there such discrepancy?
The difference has to do with message segments. The /Messages resources and has a field called, "num_segments": "X" - so one message may be made up of multiple segments.
/Messages will be less than the result of the Usage API if you sent a message with more than one segment. A segment is what you are charged for. You can use this tool to see how many segments a message has, or view the results using the field mentioned above, num_segments.
Message Segment Tool
Trying to limit the number of results returned by the List channel messages Graph API. However, when setting $top to e.g. 10, then only 3 messages are returned. When setting it to 30, then 19 messages are returned. Does $top count deleted messages that aren't returned or something like that? Is this a bug?
How do I reliably get the last 10 messages? Do I really have to ask for e.g. 30 and then filter out the rest?
When fetching all users in organization in the C# SDK, I ran into something similar. Running .Distinct() on the result set reduced the number of records to the expected amount.
BaseUrl for client appears to be https://graph.microsoft.com/v1.0
I've been using the YouTube Data API and I want to just call the API and for it to return a channel's latest video. Currently I have been doing this:
https://www.googleapis.com/youtube/v3/search?key=[key]&channelId=[channelId]&part=id&order=date&maxResults=1,
but that still uses many units.
Is there any way to get the data I need without using so many units?
For the first question of yours:
I want to just call the API and for it to return a channel's latest video.
the answer is positive. You'll have to proceed as follows:
Step 1: Obtain the ID of the uploads playlist corresponding to the channel of your interest:
For a given channel -- identified by its ID CHANNEL_ID --, invoke the Channels.list API endpoint, queried with its request parameter id set to CHANNEL_ID:
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&fields=items/contentDetails/relatedPlaylists/uploads&id=CHANNEL_ID&key=....
The needed uploads playlist ID is to be found as the value of the property contentDetails.relatedPlaylists.uploads of the Channels resource JSON object returned by the endpoint.
Usually, a channel ID and its corresponding uploads playlist ID are related by s/^UC([0-9a-zA-Z_-]{22})$/UU\1/.
Note that above I used the fields request parameter for to get from the API only the info that's actually needed.
Also note that you'll have to invoke Channels.list as above only once, for to use the obtained uploads playlist ID as many times as you need.
Step 2: Obtain the latest uploaded video of the channel of your interest:
For that you'll need to rely on an undocumented behavior of the PlaylistItems.list API endpoint queried with its playlistId request parameter set to the ID you've obtained at step 1:
According to point 2 of this answer of mine:
For the uploads playlist of a channel, the items returned by PlaylistItems.list API endpoint are (have to be) ordered in reverse chronological order by contentDetails.videoPublishedAt.
Therefore, you'll have to invoke PlaylistItems.list on the following URL repeatedly in a loop (using pagination):
https://www.googleapis.com/youtube/v3/playlistItems?playlistId=UPLOADS_ID&part=snippet&fields=nextPageToken,items/snippet/resourceId&maxResults=50&pageToken=PAGE_TOKEN&key=...
Above, UPLOADS_ID is the ID of the uploads playlist obtained at step 1.
The request parameter pageToken=PAGE_TOKEN is needed if and only if you're not invoking PlaylistItems.list for the first time. When the endpoint is invoked the N-th time, with N >= 2, then PAGE_TOKEN would be the value of the property nextPageToken of the JSON response obtained from the previous endpoint call. If an endpoint call does not provide the property nextPageToken then the pagination loop terminates.
The pagination of the result sets of PlaylistItems.list is needed for the sake of correctness of you implementation: you'll have to ignore the snippet objects of the items array obtained from each endpoint call when the value of the property snippet.resourceId.kind is not equal with youtube#video.
For each snippet object obtained from the endpoint that has snippet.resourceId.kind equal to youtube#video, the property snippet.resourceId.videoId is set to the ID of an uploaded video belonging to the playlist identified by UPLOADS_ID.
Therefore, the first time you encounter a snippet object of this latter kind, you retain the respective video ID and break off the pagination loop (thus invoking PlaylistItems.list no more).
For what concerns your second question:
Is there any way to get the data I need without using so many units?
again, the answer is positive.
Taking into account the quota costs, executing the step 1 taken once and the step 2 taken N times amounts to a cost of 1 + N * 1 = N + 1 units. Moreover, if step 1 is not executed, then the cost would be N units. (You need not execute step 1 once you already know UPLOADS_ID from previous runs of step 1 + 2.)
Also note that your pagination loop will most likely terminate with N being 1; thus your API calls would entail most probably only 2 units of quota cost. When step 1 is not executed, the quota cost implied would most probably be only 1 unit.
the following cost 2 unit
baseurl = https://www.googleapis.com/youtube/v3
Get channel "Upload" ID
{baseurl}/channels?part=contentDetails&id={channel Id}&key={api key}
then use upload id for playlistItems
{baseurl}/v3/playlistItems?playlistId={upload id}&part=snippet&maxResults={max numbers}&key={api key}
I am trying to get a list of my subscribers using the Subscriptions: list. Is there a way to get values for all of my subscribers, or is it only possible to get 50 max? Is there another way to get values for all of my subscribers? I am aware the documentation says you can only get 50 results max, but I wanted to see if there was another way to get all the values. Thanks!
The max results you can get with 1 call is 50.
To get more results, you would need to make multiple calls. After the first call finishes and there are more results that can be obtained, the API call should return a string for the nextPageToken property. Use this for the optional pageToken parameter for your next API call. Repeat this process until you've obtained all the results.
Yes! Take a look at the pageToken parameter listed in the docs:
The relevant description is:
The pageToken parameter identifies a specific page in the result set that should be
returned. In an API response, the nextPageToken and prevPageToken properties identify
other pages that could be retrieved.
Twitter API documentation says that I can get only 20 last messages (proof link). I'm just wondering if there is any other possibility to get more messages, for example - "all the messages from specific point in time".
I think you can specify count, which can be upto 200 and number of pages as well which allows you to retrieve upto 3200 status messages. And since_id allows you to retrieve messages after that particular message.http://twitter.com/statuses/friends_timeline.xml?count=100&page=5&since_id=23323
Check the parameters in the link you've pasted. There's a parameter count that allows you to get up to 200 messages in one call. If you want more then that you can change since_id parameter value to get even older entries or use page_id.
http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses-user_timeline
See the count parameter.
For example:
http://twitter.com/statuses/user_timeline.xml?screen_name=someuser&count=50
That would get 50 messages, instead of the default 20.