API Tokens
Last updated
Last updated
To access this feature, send a request to support@usehaystack.io
Haystack provides API access for metrics. Below you can find the API endpoints and process of how to use them.
The API has two different endpoints for metrics. The first one is /metrics
endpoint that supports global metrics. The second one is /teams/[teamId]/metrics
and it’s for specific teams.
Haystack supports a number of different filters and metric types. Thus, to make things easier, we added support for copying any metric as a cURL request. Then, one can transform that into any language/environment.
In each metric in Haystack, you can find an option called Copy API Request
. This function will give you the API cURL command to replicate the same behavior with the metric. We advise to use this feature, and then edit fields for your use case.
Authentication done via Bearer
tokens. To create a token, please go https://delivery.usehaystack.io/api-tokens page and create a token. Keep in mind that the tokens will only be available to copy after the token is created.
The token should be added as a header field. Example:
Endpoint Host:
https://api.usehaystack.io
Endpoint URL:
POST /public/api/team/:teamId/metrics
or POST /public/api/metrics
Request Params
teamId
: (Number) The ID of the team for which metrics are being requested. (Only exists if the endpoint is team endpoint)
Request Body
startDate
: (String) The start date of the metrics data range (format: YYYY-MM-DD).
endDate
: (String) The end date of the metrics data range (format: YYYY-MM-DD).
granularity
: (String) The granularity of the metrics data (week/month/cycle).
type
: (String) The type of metrics data (issue/pull_request/cycle/deployment).
groupBy
: (String) The parameter to group the metrics data by (team/author/assignee/epic, and more).
filters?
: the filter array, we advise you to use the filter array given by our Copy API Request
feature
This responses are responses without groupBy
and granularity selected as week
or month
. The responses include two different fields, data
and averages.
data
: (Array) The metrics objects. Each object contains the following fields
title
: (String) The title of the metric
measure
: (String) Unique key of the metric
series
: (Array) The values of the chart
x
: (String) The x axis of the chart
value
: (Number) The value
averages
: (Object) The averages of the results. This is used for Value
chart types.
The averages object includes one or more then one fields. The name of the field depends on the request type.
The fields can be extracted from the measure
field from the data
. For instance if the measure is jiraIssue.count
, then you should check for averages>jiraIssue>count
for average of that metric.
The structure of the group by responses are very similar to regular responses.
data
: (Array) The metrics objects. Each object contains the following fields
key
(String) The unique key of the current groupby.
values
(Array) The values for the metrics
title
: (String) The title of the metric
measure
: (String) Unique key of the metric
series
: (Array) The values of the chart
x
: (String) The x axis of the chart
value
: (Number) The value
averages
: (Array) The averages of the results. This is used for Value
chart types. Each item in the array exist for group by.
key
(String) The unique key of the current groupby.
values
(Array) The values for the metrics
The averages object includes one or more then one fields. The name of the field depends on the request type.
The fields can be extracted from the measure
field from the data
. For instance if the measure is jiraIssue.count
, then you should check for averages>[number]>value>jiraIssue>count
for average of that metric.
The rest of the fields in the response are for future use. You can ignore them for now.
When granularity selected as cycle
, the response returns the cycles with analytics. Here is an example response:
20 requests per minute is allowed. After that, the system will give 429
as status code.
To increase this limit please contact support@usehaystack.io.