How to get Yammer messages of particular group? - ionic-framework

I used
https://www.yammer.com/api/v1/search.json
but am getting all the messages of yammer.
But I am in need of getting messages only for 1 group.
There is no group paramter in above API to sort.
I am in need of search message/topic of particular group.
Help is appreciated !

This is the API you would need to call:
https://www.yammer.com/api/v1/messages/in_group/{{group_id}}.json
I don't see this specifically supported in the Yammer Developer Docs so make sure you understand that it might be removed or changed in the future:
https://developer.yammer.com/v1.0/docs/rest-api-rate-limits
You could also use the Data Export Api and that generates a csv of messages that you could filter on group ids.

It's not possible to search by group using the API. What you can do though is to filter the JSON response by the group ID. For example, if your group ID is 12346, fetch the response then apply a custom filter in your code to get all messages that has "messages.group_id:12346".

Related

Is there a way to retrieve the number of members in a group using the Keycloak API?

I am using Keycloak API and I have a use case where I need to get the number of members in a group, before fetching all users.
Unfortunately, both endpoints GET /{realm}/groups/{id}/members and GET /{realm}/groups/{id} do not return such information.
The API doc on https://www.keycloak.org/docs-api/5.0/rest-api/index.html does not seem to indicate how we can get the count.
So, how we can get this information using the Keycloak API ?
Unfortunately, one does not have an endpoint like GET /{realm}/groups/{id}/members/count like one has for the number of groups (i.e., GET /{realm}/groups/count).
What you would need to do, is to define max query parameter to -1 so that you are sure to get all the members using the endpoint GET /{realm}/groups/{id}/members and then just count the number of members on the json response. Of course, this is a sub-optimal approach, but the only one using the API as it is.
I have provided a complete script that automatizes this processes in the following repo.
As mentioned by #dreamcrash, you need to count that from the response of GET /{realm}/groups/{id}/members.
I am using jq.. then my script is:
curl .... ${url}/${realm}/groups/${id}/members | jq '. | length'

Aggregate functions in WIQL query

I want download WIQL report using REST API. REST response doesn't give all fields but it gives a list of URLS as workItems.
To get field values I need to download each WorkItem separately.
Any direct REST way to accomplish this in a single REST call?
Repeated REST calls gives me rate limiting or similar error. I get error 500 types after repeated GET request.
Genesis of this need is - There are no aggerate functions available likes of SUM, MAX, MIN, AVG Etc.
REST response doesn't give all fields but it gives a list of URLS as
workItems.
To get field values I need to download each WorkItem separately. Any
direct REST way to accomplish this in a single REST call?
Sorry but as I know, there's no direct rest api available to get WIQL report. An alternative workaround should be:
1.Use Query By Wiql to return the list of WorkItem IDs and Urls (I think this is the same rest api you use).
2.Then use Get Work Items Batch to get all the details(fields) about the requested work item ids. And here's one issue which has similar needs like yours, you can use the upgraded script from konpro11 to get list of IDs and use the IDs to get your report (with the help of second rest api).
Hope it helps :)

Mailchimp API: How to get members in a list who have selected a particular interest

I am new to the Mailchimp API. I want to get a list of members from a list who have selected an interest (checkbox type) in an interest category. I don't know how to form the query statement for the members or search-members API method.
I did a web search for a Mailchimp API query example but couldn't find one pertaining to Groups.
I'm using Postman for now as part of my research. Here is an example of what I've tried (c133bd0ba3 is the ID of the Interest I want to check):
https://usX.api.mailchimp.com/3.0/search-members?query=c133bd0ba3=true,list_id=nnnxyz
I want the query to return a list of members who have selected the interest (value = true).
Any help is greatly appreciated.
Update: I found a way to get the information with the members API method call:
https://usX.api.mailchimp.com/3.0/lists/24b8bd6114/members?interest_category_id=2dd67a99be&interest_ids=8114c6945b&interest_match=all&fields=members.id,members.email_address
Curious if anyone knows how to create a query for the search-members API method to get this same result?
The search-members API endpoint only functions the way it does in app where you can only search specific strings like names, email addresses, but not ids as those aren't visible in app.
However using the query string ?interest_ids=X attached to the end of GET lists/list_id/members will pull up anyone with that specific Interest ID. But that is what you allready figured out!

Possible to specify date_preset with insights edge in Facebook Ads API?

For the Marketing API, I know that I'm able to make one call to retrieve all of the adsets from a certain account along with their insights, but am I able to specify the date_preset for the insights edge in that same call?
For example, the following gives me lifetime insights stats:
/v2.4/{accountID}/adcampaigns?fields=insights
To be clear - I know this is possible to retrieve by making separate calls for each adset id (where I know I can specify the date_preset); instead, I'd like to do this via the call where I get a long list of the ad sets plus their insights details in one go.
Yes this is possible using query expansion, however you probably should not do it in this anyway.
Using query expansion results in multiple requests being executed in one HTTP call, in this case one to get all the adcampaigns, and then N requests where N is the number of adcampaigns returned. This will in turn affect your rate limiting.
The most efficient way to request all insights for all adcampaigns (ad sets) is instead to request them at the account level, specifying aggregation level:
/v2.4/act_{ADACCOUNT_ID}/insights?date_preset=last_7_days&level=campaign
This requires just 1 request, or the number of requests to retrieve the total number of pages.
If you really want to achieve this with query expansion, you can do the following for example:
/v2.4/act_{ADACCOUNT_ID}/adcampaigns?fields=insights.date_preset(last_30_days).time_increment(all_days)
You can see the parameters to insights that would normally be query parameters of the form param_name=param_value are now in the form of param_name(param_value).
To specify the date_preset , here is the correct format . Its important to use insights as edge to get the date_preset filtering .
/v2.10/act_{ADACCOUNT_ID}/insights?fields=impressions,clicks,ctr,unique_clicks,unique_ctr,spend,cpc&date_preset=last_3d
The above one is tested with latest Graph Api version(2.10) as of now . FOr more info related to the date_preset values refer to there api docs .
https://developers.facebook.com/docs/marketing-api/insights/parameters

REST Get items not in collection

Introduction
Let's say I have a rest service which returns items:
GET /items
GET /items/7
POST /items
etc.
We also have groups of items:
GET /groups
GET /groups/16
POST /groups
etc.
And we can then get the items in a specific group:
/items?groupid=16
This is all pretty straight forward.
Question
Now that we have a way to get items in a specific group, should we also supply a way to get items that are NOT in a specific group? Why? Because if a client wants to add items to a group, it has to know which items aren't added yet.
I see two options:
We supply some way to query the data
Don't do anything, let the client handle it.
Ad 1.
We can supply a way to query/search the data like this:
/items?groupid=!16
or
/items?q=groupid<>16
I have the feeling this leads to a never ending stream of feature requests for search queries.
Ad 2.
The client can first get all items. Next the client can get all items in group 16. Doing a diff on these two collections gives the items not in group 16.
This way the client has to do a little more coding, and work with collections, keep them in memory etc. On the other hand it doesn't need to learn a specific query syntax.
Are there any best practicies on this topic?
First, I'd use a different URL to get the items in a group:
GET /groups/16/items
This would return the collection resource of all items that are in group 16. To add an item to a group,
POST /groups/16/items
could be used.
Adding an item to a group will have the same result, regardless of the item already being in the group or not. In both cases the client only cares about the result: he wants the item to be in the group. If it already was, fine, if not, it is now.
So I don't see any usecase for getting items that are not in a group.
Perhaps allowing the client to POST the new item to the desired group could be the way to go.
During the validation you would need anyway, you could either accept the not-pre-existing item or reject it because it is already there.
Building on the URLs of #Tichodroma, you could perhaps have:
GET /groups/16/non-items