Adobe analytics API - Can you combine multiple segments in one report call? - adobe-analytics

I have a report in the Adobe Analytics UI which is segmented by 3 segments.
I'm trying to mimic this report using the Adobe Analytics API (v2).
I was able to successfully execute the report using the /report endpoint while applying a single segment with the globalFilters property.
However I'm not seeing any indication that you can apply more then one segment per report.
Is there any way to execute a report with multiple segments via the API?
Here is the link to the report documentations
https://www.adobe.io/apis/experiencecloud/analytics/docs.html#!AdobeDocs/analytics-2.0-apis/master/reporting-guide.md
For reference, an example of the request data of a successful report with a single segment I was able to execute:
{"rsid": "{rsid}",
"globalFilters": [{"dateRange": "2020-03-01T00:00:00.000/2020-03-25T23:59:59.999", "type": "dateRange"},
{"type": "segment", "segmentId": "{segmentId}"}],
"dimension": "variables/lasttouchchannel",
"metricContainer": {"metrics": [{"columnId": "Cart Additions", "id": "metrics/visits"}], "metricFilters": []},
"settings": {"limit": 250, "dimensionSort": "asc", "page": 0}}
Please let me know if more information is needed,
Thanks in advance!

It turns out you can add multiple segments under global filters.
Simply add them to the 'globalFilters' parameter.
e.g.
{"rsid": "{rsid}",
"globalFilters": [
{"dateRange": "2020-03-01T00:00:00.000/2020-03-25T23:59:59.999", "type":"dateRange"},
{"type": "segment", "segmentId": "{segmentId}"}, {"type": "segment", "segmentId": "{segmentId2}"}],
"dimension": "variables/lasttouchchannel",
"metricContainer": {"metrics": [{"columnId": "Cart Additions", "id": "metrics/visits"}], "metricFilters": []},
"settings": {"limit": 250, "dimensionSort": "asc", "page": 0}}
You can also add them under metricContainer.metricFilters[n] as suggested by Crayon Violent in the comments (thanks for the tips!), but I'm not sure if the results would be the same.
Ultimately 'globalFilters' gave me the results I was looking for and that is the solution I want with.

Related

YouTube API - Description snippet from YouTube does not match the API / Getting "Primary" description text content

I want to use the YouTube API to get the snippet of their description. However, I want it to be the primary text snippet describing the video YouTube uses as the snippet, which is different from the data api's response.
Let me give an example to clear things up:
This video will be the demonstration: https://www.youtube.com/watch?v=ADPFEw-7FtU
At the top of this description is the text "Compress Decades Into Days. Get Dan Lok’s World-Class Training Solutions to Grow Your Income, Influence and Wealth Today. Start Here ► [redacted]"
On the YouTube data API search snippet the response is: "Compress Decades Into Days. Get Dan Lok's World-Class Training Solutions to Grow Your Income, Influence and Wealth Today.". This makes sense because they're both at the start of the description. Now this is where I get confused.
If you search the title on YouTube (not the API), you'll actually see that the description is "Have you ever thought of starting an exciting YouTube career on YouTube doing what you love? Or maybe you have started, but ..."
This is the snippet I want. I want their video's "Primary SEO Search Snippet", which describes the video. Is there anyway to calculate this or get this from the API using another method? I don't want to use any non-official API/library to do this.
What this is not:
This is not any caching that has yet to expire/update
Unique to this video. There are plenty of videos where this happens
As far as I know there isn't any official API providing the data you are looking for. Anyway if you change your mind about not using unofficial APIs, then you can proceed as follows by trying out my open-source YouTube operational API. Indeed by fetching https://yt.lemnoslife.com/search?part=snippet&q=YOUR_QUERY, you will notably get the primary SEO search snippet you are looking for in item["snippet"]["detailedMetadataSnippet"].
For instance with "How To Grow With 0 Views And 0 Subscribers" you would get:
{
"kind": "youtube#searchListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#searchResult",
"etag": "NotImplemented",
"id": {
"kind": "youtube#video",
"videoId": "ADPFEw-7FtU"
},
"snippet": {
"channelId": "UCs_6DXZROU29pLvgQdCx4Ww",
"title": "How To Grow With 0 Views And 0 Subscribers",
"thumbnails": [
{
"url": "https:\/\/i.ytimg.com\/vi\/ADPFEw-7FtU\/hq720.jpg?sqp=-oaymwEjCOgCEMoBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLCKNA5T652tMTvnOw22llDniM9O6Q",
"width": 360,
"height": 202
},
...
],
"channelTitle": "Dan Lok",
"channelHandle": "DanLok",
"timestamp": "3 years ago",
"duration": 887,
"views": 4495095,
"badges": [
"CC"
],
"channelApproval": "Verified",
"channelThumbnails": [
{
"url": "https:\/\/yt3.ggpht.com\/ytc\/AMLnZu_TXnQ07ufj6eGxco9yHndCCcV5KfAizZ9jbI8vmA=s68-c-k-c0x00ffffff-no-rj",
"width": 68,
"height": 68
}
],
"detailedMetadataSnippet": "Have you ever thought of starting an exciting YouTube career on YouTube doing what you love? Or maybe you have started, but\u00a0...",
"chapters": [
{
"title": "Intro",
"time": 0,
"thumbnails": [
{
"url": "https:\/\/i.ytimg.com\/vi\/ADPFEw-7FtU\/hqdefault_25933.jpg?sqp=-oaymwEjCNACELwBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLBVOtOt_jLJd1dRRt5_dj3SlGBtRA",
"width": 336,
"height": 188
}
]
},
...
]
}
},
...
]
}
I wanted to add an answer for anyone trying to do this in 2023 and onwards.
I opened a ticket on the Google Issue Tracker regarding this issue: This was their response.
Hi Conor,
I was able to reproduce this behavior, and also found that neither a search resource description nor a video resource description will display the "Primary SEO Search Snippet" that you are seeking. Thus, I have opened up a feature request with our internal team to request this functionality, but I can't guarantee this feature will be implemented. Thus for updates regarding this, I recommend keeping an eye on our revision history.
You can use the unofficial API as per Benjamin's answer, but unfortunately, that can cause other issues depending on the scale you need to use this feature.

Retrieving labels from multiple JIRA Subtasks via JIRA API

I am creating a reporting dashboard with the intent of getting multiple tickets/issues for a project. As most of you probably know, a JIRA issue can have subtasks. These subtasks can have labels.
I want to retrive all labels for every subtask.
I already have the project API request implemented which returns the parent ticket ids along with the issue/ticket number of all subtasks. The problem is the data returned from this request does not include the labels for the subtasks themselves.
I can loop over each subtask number and make an additional API request for each one to get the labels, however this would result in a large number of requests.
Looking through JIRA's API I cannot find a better way of doing this. Google seems to return a lot of results about plugins and version differences with Cloud vs. Server but I have not found a better solution.
Their API makes reference to an expand option but I have yet to figure out a way to make that work for subtask labels (I might be missing something obvious).
If anyone has experience with a similar situation I would appreciate hearing any advice you could offer. Thanks!
What I have currently:
Project API Request:
https://ourcompanyhere.atlassian.net/rest/api/2/search
with an additional parameter added for the JQL string of:
project=PROJECTNAME AND fixversion=version
This returns all the tickets in the project with subtasks but not the subtask labels.
I can loop over the returned data from the above request and make an additional request for each:
https://ourcompanyhere.atlassian.net/rest/api/2/issue/ticketNumberHere
JSON Response
Here is the partial JSON response back (full response is huge and I've removed key information) however this is the complete information for a ticket, with a subtask which has labels. As you can see the labels section of the subtask is completely missing.
ErrorDetail=,
Mimetype=application/json,
Statuscode=200 OK,
Filecontent= {
"expand":"schema,names",
"startAt":0,
"maxResults":50,
"total":3,
"issues":[
{
"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id":"24209",
"self":"https://[instance].atlassian.net/rest/api/latest/issue/24209",
"key":"DEV-3089",
"fields":{
"issuetype":{
"self":"https://[instance].atlassian.net/rest/api/2/issuetype/10005",
"id":"10005",
"description":"A new feature of the product, which has yet to be developed.",
"iconUrl":"https://[instance].atlassian.net/secure/viewavatar?size=xsmall&avatarId=10311&avatarType=issuetype",
"name":"New Feature",
"subtask":false,
"avatarId":10311
},
"project":{
"self":"https://[instance].atlassian.net/rest/api/2/project/10000",
"id":"10000",
"key":"DEV",
"name":"Development Queue",
"avatarUrls":{
}
},
"customfield_11000":null,
"fixVersions":[
{
"self":"https://[instance].atlassian.net/rest/api/2/version/14600",
"id":"14600",
"description":"",
"name":"",
"archived":false,
"released":true,
"releaseDate":"2017-09-15"
}
],
"resolution":{
"self":"https://[instance].atlassian.net/rest/api/2/resolution/10000",
"id":"10000",
"description":"Work has been completed on this issue.",
"name":"Done"
},
"customfield_10500":"",
"customfield_10700":null,
"customfield_10900":null,
"resolutiondate":"2017-09-15T09:19:37.000-0400",
"workratio":-1,
"watches":{
"self":"https://[instance].atlassian.net/rest/api/2/issue/DEV-3089/watchers",
"watchCount":2,
"isWatching":true
},
"lastViewed":null,
"created":"2017-05-02T10:15:08.000-0400",
"customfield_10022":null,
"customfield_10100":null,
"priority":{
"self":"https://[instance].atlassian.net/rest/api/2/priority/3",
"iconUrl":"https://[instance].atlassian.net/images/icons/priorities/medium.svg",
"name":"Medium",
"id":"3"
},
"customfield_10300":null,
"labels":[
"[label1]",
"[label2]",
"[label3]",
"[label4]",
"[label5]",
"[label6]"
],
"customfield_10016":null,
"customfield_10017":null,
"versions":[
],
"issuelinks":[
],
"assignee":{
"self":"https://[instance].atlassian.net/rest/api/2/user?username=",
"name":"[name]",
"key":"[name]",
"accountId":"[account]",
"emailAddress":"[email]",
"avatarUrls":{
},
"displayName":"[name]",
"active":true,
"timeZone":"America/New_York"
},
"updated":"2017-09-15T09:19:36.000-0400",
"status":{
"self":"https://[instance].atlassian.net/rest/api/2/status/6",
"description":"The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.",
"iconUrl":"https://[instance].atlassian.net/images/icons/statuses/closed.png",
"name":"Closed",
"id":"6",
"statusCategory":{
"self":"https://[instance].atlassian.net/rest/api/2/statuscategory/3",
"id":3,
"key":"done",
"colorName":"green",
"name":"Done"
}
},
"components":[
],
"description":"[description]",
"customfield_10010":null,
"customfield_10011":null,
"customfield_11100":null,
"customfield_10012":null,
"customfield_10013":null,
"customfield_10015":"",
"customfield_10005":null,
"customfield_10006":null,
"customfield_10600":null,
"customfield_10007":null,
"customfield_10008":null,
"customfield_10800":null,
"customfield_10009":null,
"summary":"[summary]",
"creator":{
"self":"https://[instance].atlassian.net/rest/api/2/user?username=",
"name":"",
"key":"",
"accountId":"",
"emailAddress":"",
"avatarUrls":{
},
"displayName":"",
"active":true,
"timeZone":"America/New_York"
},
"subtasks":[
{
"id":"30213",
"key":"DEV-4118",
"self":"https://[instance].atlassian.net/rest/api/2/issue/30213",
"fields":{
"summary":"",
"status":{
"self":"https://[instance].atlassian.net/rest/api/2/status/6",
"description":"The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.",
"iconUrl":"https://[instance].atlassian.net/images/icons/statuses/closed.png",
"name":"Closed",
"id":"6",
"statusCategory":{
"self":"https://[instance].atlassian.net/rest/api/2/statuscategory/3",
"id":3,
"key":"done",
"colorName":"green",
"name":"Done"
}
},
"priority":{
"self":"https://[instance].atlassian.net/rest/api/2/priority/3",
"iconUrl":"https://[instance].atlassian.net/images/icons/priorities/medium.svg",
"name":"Medium",
"id":"3"
},
"issuetype":{
"self":"https://[instance].atlassian.net/rest/api/2/issuetype/10009",
"id":"10009",
"description":"",
"iconUrl":"https://[instance].atlassian.net/secure/viewavatar?size=xsmall&avatarId=10303&avatarType=issuetype",
"name":"Testing Issue",
"subtask":true,
"avatarId":10303
}
}
}
"reporter":{
"self":"https://[instance].atlassian.net/rest/api/2/user?username=",
"name":"",
"key":"",
"accountId":"",
"emailAddress":"",
"avatarUrls":{
},
"displayName":"",
"active":true,
"timeZone":"America/New_York"
},
"customfield_10000":"2017-09-01T12:35:54.706-0400",
"customfield_10001":null,
"customfield_10200":null,
"customfield_10400":null,
"customfield_10004":null,
"environment":null,
"duedate":null,
"votes":{
"self":"https://[instance].atlassian.net/rest/api/2/issue/DEV-3089/votes",
"votes":0,
"hasVoted":false
}
}
}
]
}
Inspect the response for the /search endpoint again. On a completely empty JIRA Cloud instance I created a Project, one Issue and added a Sub-task for it. Calling the /search endpoint returns a list with two Issues (so, the Issue itself and its Sub-task) and for both there's a field called labels with an array of all the Labels attached to it.
The following is an abbreviated response with all unrelated data removed.
{
"startAt": 0,
"maxResults": 50,
"total": 2,
"issues": [
{
"key": "TEST-1",
"fields": {
"labels": []
}
},
{
"key": "TEST-2",
"fields": {
"parent": {
"key": "TEST-1"
},
"labels": [
"VOILA"
]
}
}
]
}
EDIT
After looking at the response then yes, the array in subtasks is really simple and cannot be separately expanded. You need to do the search, then parse out all the subtasks that you're interested in and either do
a separate /issue/[key] request for each one
a /search for those specific keys
After doing some further research I found a better way to do this. I'm still not getting the subtask labels back but instead of looping over each subtask and sending a separate request for each, you can do one API call using JQL like this:
https://[instance].atlassian.net/rest/api/latest/search?jql=project=[project] AND KEY IN ([comma separated list of tickets])&fields=labels'
The
&fields=labels
part drastically reduces the amount of information returned. So now I can just do a total of two calls and get everything I need. :)
Wanted to post this in case anyone runs into a similar situation.

Time from creation to closed

I am trying to calculate the average time for all the jira cases that are created and until they are resolved.
How can this be done, for a specific project?
You dont say how you want to calculate this.
The simplest way is to add the Resolution Time Gadget to your dashboard. Here you can add a filter to specify which issues you want to consider.
This will give you a nice bar chart of the average resolution times of issues over a given period
If you want more control, you can write a script for it with the Jira REST API
If you create a jql for the issues you are interested in, you can call the REST api with a url like this:
https://jira.intern.sparebank1.no/rest/api/2/search?jql=assignee=e6462u
This will return a whole bunch of info, but you are most interested in the issues array elements, and specifically the fields "created" and "resolutiondate"
A snipped version of the JSON returned is:
{
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 1,
"issues": [
{
"expand": "operations,versionedRepresentations,editmeta,changelog,transitions,renderedFields",
"id": "104799",
"self": "https://jira.domain.com/rest/api/2/issue/104799",
"key": "HELLO-1",
"fields": {
...
"resolutiondate": "2015-06-25T09:12:27.000+0200",
"created": "2015-03-18T16:18:38.000+0100"
...
}
}
]
}
Now you can calculate the difference between the two for each issue element and find an average.
More info on Jira REST API: https://docs.atlassian.com/jira/REST/latest/
A blog I wrote on how to script stuff like this (and present in a graph in confluence ;) ): http://javamemento.blogspot.no/2016/05/jira-confluence-3.html

Google API Explorer returns no Rows, Postman does with same query

I have been working on a project to pull analytics data from the YouTube Analytics API (v1, v1beta1 provides the same results). I began getting no rows returned in a batch call and, naturally, I suspected errors on my end.
I recreated one of the queries from my program in the Google APIs Explorer to see where I may have gone wrong. And that's where things got complicated.
Note: I am using OAuth and executing my program and the API explorer with OAuth authentication of the same user in all locations. I have omitted the Authorization Bearer [token] details from this post for obvious reasons.
Google API Explorer query:
GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2016-05-01&end-date=2016-05-31&metrics=views%2CestimatedMinutesWatched&dimensions=insightTrafficSourceType&filters=video%3D%3DEeEHdFmKrGo%3Bcountry%3D%3DUS&fields=rows&key={YOUR_API_KEY}
Google API Explorer results:
200 HTTP/2.0 200
- Show headers -
{
}
Postman query:
GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2016-05-01&end-date=2016-05-31&metrics=views%2CestimatedMinutesWatched&dimensions=insightTrafficSourceType&filters=video%3D%3DEeEHdFmKrGo%3Bcountry%3D%3DUS&fields=rows
Postman results:
{
"rows": [
[
"YT_PLAYLIST_PAGE",
83,
153
],
[
"YT_CHANNEL",
21,
38
],
[
"PLAYLIST",
103,
193
],
[
"SUBSCRIBER",
41,
63
],
[
"NOTIFICATION",
16,
5
],
[
"ADVERTISING",
1954,
2973
],
[
"RELATED_VIDEO",
179,
294
],
[
"YT_OTHER_PAGE",
16,
20
],
[
"EXT_URL",
98,
189
],
[
"NO_LINK_OTHER",
603,
23
],
[
"YT_SEARCH",
80,
130
]
]
}
So data is available. Why does the API Explorer not show it? The API Explorer matches the behavior of my program: no rows returned.
Yes, if I omit the fields value, it will give me the column headers:
200 HTTP/2.0 200
- Show headers -
{
"kind": "youtubeAnalytics#resultTable",
"columnHeaders": [
{
"name": "insightTrafficSourceType",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "views",
"columnType": "METRIC",
"dataType": "INTEGER"
},
{
"name": "estimatedMinutesWatched",
"columnType": "METRIC",
"dataType": "INTEGER"
}
]
}
Other similar questions:
ROWS not returning in Youtube Analytics API?
YouTube Analytics API doesn't return ROWS for query for a specific video
YouTube Analytics API returns no rows for demographic query - but does return views
YouTube Analytics API channel: The response has no rows parameter
I've verified some of the leads in these questions.
I am getting data for the query... just not via batch nor the API explorer.
Same as #1, really. If I change or extend the date ranges, the API Explorer still returns no rows while Postman's query shows rows.
See investigations for #4
I can pull the report in the YouTube interface — as the same user being used for the API Explorer and my program — and see data.
YouTube Interface Screenshot
This data matches what I get from Postman's query. This implies that the same data should be available via the API Explorer and batch requests, however they obviously differ.
Am missing something? Shouldn't I receive rows in the response from the API Explorer? Likewise, shouldn't a batch response contain the same contents as the direct GET request I'm seeing via Postman?
Any insight or suggestions for further exploration appreciated. If you've made it this far, thanks for your time.
Garret

How to get the total number of issues of a JIRA Project?

Since JIRA API only allows to make a search request with a max result of 1000 issues, I need to know if there is a way to get the total number of issues a project so I can iterate through all thousands of issues.
IRestResponse responseIssues = client.Execute(new RestRequest("search?jql=project=" + "\"DATPROJECT\"" + "&maxResults=5000&fields=assignee,summary,timetracking,resolutiondate,resolution,worklog", Method.GET));
I am currently doing like the code above but I only get 1000 results and not 5000 that I need. I know that I can use the filter "startAt" to iterate over all results but I don't know how many issues exist.
Any ideas?
The search rest point returns total number of issues for a given JQL search. Example result from documentation
{
"expand": "names,schema",
"startAt": 0,
"maxResults": 50,
"total": 1,
"issues": [
{
"expand": "",
"id": "10001",
"self": "http://www.example.com/jira/rest/api/2/issue/10001",
"key": "HSP-1"
}
]
}
This "total":1 value is the one you're looking for.
Hey from rest Api I don't find any rest where you can get all issue.but if you want all issue you can get it from java side. if you need total number of issues use
long getIssueCountForProject (Long projectId)
and if you want all issues and want to iterate it use
Collection<Long> getIssueIdsForProject (Long projectId)
please refer atlassian documentation for all this method.
Thank you.
You can use maxResults=0 to get only descriptive data omitting the actual results.
For example, if we want to know the amount of open issues for the currently logged in user:
rest/api/2/search?jql=project=SP+AND+statusCategory!=3+AND+assignee+in+(currentUser())&maxResults=0
The result:
{
"startAt": "0",
"maxResults": "0",
"total": "68",
"issues": [
]
}
The "total" field here is just what we need.

Resources