API: Get all (scenario) tags of a given project

Hello everyone,
I have been working on a CucumberStudio project with my team for some weeks now and the time has come for me to reach out to the Community :wink:

What am I trying to do in broader context?
I would like to make a custom dashboard giving a bit more detailed overview of a project. This would allow us to better understand the structure of our project and hopefully identify opportunities to improve it.
The way I would like to do it is to get some data using API, convert it to CSV and manipulate it in spreadsheets to get the result I am looking for. At this stage I would find it very convenient to use the least possible number of API requests as I am trying to avoid/minimize using Postman Runner or scripting requests in any other way.

What is on my mind more specifically?
I have queried for all scenarios in my project with:
https://studio-api.cucumber.io/#get-scenarios-of-a-given-project
The returned tags data is “type” and “id”
I would like to query for all tags (or at least all tags that are assigned to scenarios) so that I can match their detailed data with my scenarios using spreadsheets VLOOKUP.
Currently I can fetch the scenarios’ tags detail one by with below query:
https://studio-api.cucumber.io/#get-tags-of-a-given-scenario
but that would require making many requests I would like to avoid as mentioned above.
Is there a way to get all (scenarios) tags data with a single request? If not, could you elaborate why so and is it going to change anytime soon?

If you have any thoughts regarding my case, please don’t hesitate to share, thank you.
Best regards, Jakub

Hello,

Have you tried to use the endpoint https://studio-api.cucumber.io/#get-scenarios-of-a-given-project with the includes param for tags?

https://studio-api.cucumber.io/#get-scenarios-of-a-given-project?include=tags, it will return the tags in the relationships section. Would it match your requirements?

Hello David, thank you for responding so quick.

I’m afraid it’s not enough, with the include I get only limited data like this:
"tags": {"data": [{"type": "tags", "id": "someid"}]

And when I query for a single scenario tags the structure is like this:
[{"type": "tags", "id": "someId", "attributes": {"key": "JIRA", "value": "some jira exact key"}, "links": { "self": "/tags/someId"}}]

As you can see the former doesn’t really bring much information to the table and I would like to get the details provided by the latter. Is there a way to include the key-value attributes with the extended scenarios query?
In the case this is too much data to be added in the “include” I would be perfectly fine with fetching all tags in a separate request and matching them up within my spreadsheet.

Did you see that at the end of response, you get a included sections this schema:

[
        {
            "type": "tags",
            "id": "...",
            "attributes": {
                "key": "...",
                "value": "..."
            },
            "links": {
                "self": "..."
            }
        },
        {
            "type": "tags",
            "id": "...",
            "attributes": {
                "key": "...",
                "value": "..."
            },
            "links": {
                "self": "..."
            }
        },
]

And so you could map back the id in you scenario and the id in the included section to get the key:value tag?

I am not sure what you mean, it seems like you have pasted the same structure I did in my previous comment. In your question

which endpoint do you have in mind? If you mean “get-tags-of-a-given-scenario” then yes, but I don’t want to send one request per scenario because there are hundreds of scenarios. I don’t want to script it (quite frankly I think it would be tedious, error-prone and I’m not sure if I could do it successfully) it is not feasible for me. It would be orders of magnitude easier if I could get the data with a single request and manipulate it in spreadsheets.

Can you give an example of how the mapping back would be performed in your idea?

Also, I think some of my previous questions, which remain without a definite answers are basically kind of “yes”/“no” questions. Could you please address them directly?

Currently I understand that it’s possible but with only the limited data of self-labeling “type”: “tags” and “id”: “…” which don’t bring enough information for me. Is my understanding full or am I missing something?

By extended I mean using the include query params.

The endpoint https://studio-api.cucumber.io/#get-scenarios-of-a-given-project called with ?include=tags will add:

  • “tags”: {“data”: [{“type”: “tags”, “id”: “someid”}] to each scenario in the relationships

  • an “included” section at the end of the json response with the schema and the information you are looking for.

And I think the “included” addresses what you need.

To provide a full example, you use this endpoint:
https://app.hiptest.com/api/projects/<project_id>/scenarios?include=tags

and you get the following response:

{
    "data": [
        {
            "type": "scenarios",
            "id": "",
            "attributes": {
                "created-at": "",
                "updated-at": "",
                "last-author": "",
                "name": "",
                "description": "",
                "folder-id": ,
                "definition": ""
            },
            "links": {
                "self": ""
            },
            "relationships": {
                "folder": {},
                "tags": {
                    "data": [
                        {
                            "type": "tags",
                            "id": "**88486564**"
                        }
                    ]
                },
                "actionwords": {}
            }
        },
        {
            "type": "scenarios",
            "id": "",
            "attributes": {
                "created-at": "",
                "updated-at": "",
                "last-author": "",
                "name": "",
                "description": "",
                "folder-id": ,
                "definition": ""
            },
            "links": {
                "self": "/scenarios/3703839"
            },
            "relationships": {
                "folder": {},
                "tags": {
                    "data": [
                        {
                            "type": "tags",
                            "id": "**88486561**"
                        }
                    ]
                },
                "actionwords": {}
            }
        }
    ],
    "included": [
        {
            "type": "tags",
            "id": "**88486564**",
            "attributes": {
                "key": "priority",
                "value": "high"
            },
            "links": {
                "self": "/tags/88486564"
            }
        },
        {
            "type": "tags",
            "id": "**88486561**",
            "attributes": {
                "key": "priority",
                "value": "medium"
            },
            "links": {
                "self": "/tags/88486561"
            }
        }
    ]
}

I thing that this endpoin and this JSON response answer all your questions. You would just need to map the id that you have in the scenario with the corresponding id in the included section. All with one endpoint getting all the scenarios of one project.

I hope I clarified what I meant previously.

1 Like

Thank you for your patience David. Indeed it is clear now.
I have totally overlooked the “included” top member of the response body as I was applying JSONPath filtering starting with $.data for my needs. I was, until this case, unfamiliar with the JSON:API included structure, I will know better from now on. My case seems resolved, I’ll come back when I have new questions :slight_smile:.

Great! Glad that it addresses your issue!

1 Like