Date of annotated tag from API

I need to find the date of our annotated tags through the GitLab API (using Python), but cannot see where the date is held. My Python code gets the list of tags for the project, and I know which ones are annotated tags. The nearest help I’ve found is that the target returned is the tag’s ID for an annotated tag, and that an annotated tag is a full GitLab object, but I don’t know the next step.

Note that I can get the date of the commit, but I need the date of the tag.

Any help would be gratefully received. Thank you.

Hi, as far as I can see from the gitlab API docs:

https://docs.gitlab.com/ee/api/tags.html#create-a-new-tag

{
  "commit": {
    "id": "2695effb5807a22ff3d138d593fd856244e155e7",
    "short_id": "2695effb",
    "title": "Initial commit",
    "created_at": "2017-07-26T11:08:53.000+02:00",
    "parent_ids": [
      "2a4b78934375d7f53875269ffd4f45fd83a84ebe"
    ],
    "message": "Initial commit",
    "author_name": "John Smith",
    "author_email": "john@example.com",
    "authored_date": "2012-05-28T04:42:42-07:00",
    "committer_name": "Jack Smith",
    "committer_email": "jack@example.com",
    "committed_date": "2012-05-28T04:42:42-07:00"
  },
  "release": {
    "tag_name": "1.0.0",
    "description": "Amazing release. Wow"
  },
  "name": "v1.0.0",
  "target": "2695effb5807a22ff3d138d593fd856244e155e7",
  "message": null,
  "protected": false
}

the above are results from creating a tag using the API. I would expect the created_at is the date when the tag is created. This shows the commit that is related to that tag, release and tag name.

Unfortunately, as you can see from the above results, there is no other date field for the tag creation. I haven’t tested it to verify if that actual created_at is related to a commit made days earlier or not. If this is the case, then it isn’t possible for you to get a date for when the tag was created as the information simply isn’t there.

Thanks @iwalker, but unfortunately the date there is the date of the commit, and not when the annotated tag was created. In another post someone else said that an annotated tag is a full gitlab object and so you can get the date from that, but they didn’t explain further. (Lightweight tags don’t have this information.)

Can’t see anything related to objects, however maybe this?

https://docs.gitlab.com/ee/api/releases/

Take a look at the full json on the link, here are some parts I pulled out:

[
   {
      "tag_name":"v0.2",
      "description":"## CHANGELOG\r\n\r\n- Escape label and milestone titles to prevent XSS in GFM autocomplete. !2740\r\n- Prevent private snippets from being embeddable.\r\n- Add subresources removal to member destroy service.",
      "name":"Awesome app v0.2 beta",
      "description_html":"\u003ch2 dir=\"auto\"\u003e\n\u003ca id=\"user-content-changelog\" class=\"anchor\" href=\"#changelog\" aria-hidden=\"true\"\u003e\u003c/a\u003eCHANGELOG\u003c/h2\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eEscape label and milestone titles to prevent XSS in GFM autocomplete. !2740\u003c/li\u003e\n\u003cli\u003ePrevent private snippets from being embeddable.\u003c/li\u003e\n\u003cli\u003eAdd subresources removal to member destroy service.\u003c/li\u003e\n\u003c/ul\u003e",
      "created_at":"2019-01-03T01:56:19.539Z",
      "released_at":"2019-01-03T01:56:19.539Z",
      "author":{
         "id":1,
         "name":"Administrator",
         "username":"root",
         "state":"active",
         "avatar_url":"https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon",
         "web_url":"https://gitlab.example.com/root"
      },

now viewing the release information does seem to show tag_name and created_at and released_at date fields. Perhaps that would suffice? Providing of course you have releases as well as tags, so I might not have found anything relevant in the API docs.

Perhaps the created_at is when the tag was created, and the released_at when a release is created. So potentially an option.

Can’t find anything else in the API docs related to what you are searching to do unfortunately. And I’ve gone through projects, releases, etc, everything that could potentially be tied to where tags exist.

Thanks Ian for looking.

All- has there been any indication of improvement on this topic? My organization would like to use scripting to collect information based on tags that are present on merge requests, and I’m hoping to get an idea of the feasibility of such a task.