# Get aggregated metered requests for a given time period. GET https://app.unleash-instance.example.com/api/admin/metrics/request **Enterprise feature** Gets metered requests count for the selected period, either aggregated by day or by month. Reference: https://docs.getunleash.io/api/get-requests-for-period ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Get aggregated metered requests for a given time period. version: endpoint_unstable.getRequestsForPeriod paths: /api/admin/metrics/request: get: operationId: get-requests-for-period summary: Get aggregated metered requests for a given time period. description: >- **Enterprise feature** Gets metered requests count for the selected period, either aggregated by day or by month. tags: - - subpackage_unstable parameters: - name: grouping in: query description: Whether to aggregate the data by month or by day required: true schema: $ref: '#/components/schemas/ApiAdminMetricsRequestGetParametersGrouping' - name: from in: query description: >- The starting date of the traffic data usage search in IS:yyyy-MM-dd format required: true schema: type: string format: date - name: to in: query description: >- The starting date of the traffic data usage search in IS:yyyy-MM-dd format required: true schema: type: string format: date - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '200': description: meteredRequestsSchema content: application/json: schema: $ref: '#/components/schemas/meteredRequestsSchema' components: schemas: ApiAdminMetricsRequestGetParametersGrouping: type: string enum: - value: daily - value: monthly MeteredRequestsSchemaGrouping: type: string enum: - value: monthly - value: daily MeteredRequestsSchemaDateRange: type: object properties: from: type: string format: date description: The start of the dateRange to: type: string format: date description: The end of the dateRange required: - from - to MeteredRequestsSchemaApiDataItemsDataPointsItems: type: object properties: period: type: string description: >- The date of the data point. Formatted as a full date (e.g. 2023-04-01) if the data is aggregated by day or as a month (e.g. 2023-04) if the data is aggregated by month. requests: type: number format: double description: Number of requests required: - period - requests MeteredRequestsSchemaApiDataItems: type: object properties: meteredGroup: type: string description: >- The metered group representing charging unit in the organization using Unleash dataPoints: type: array items: $ref: >- #/components/schemas/MeteredRequestsSchemaApiDataItemsDataPointsItems description: The recorded data points for the metered group required: - meteredGroup - dataPoints meteredRequestsSchema: type: object properties: grouping: $ref: '#/components/schemas/MeteredRequestsSchemaGrouping' description: Whether the data is aggregated by month or by day. dateRange: $ref: '#/components/schemas/MeteredRequestsSchemaDateRange' description: >- The date range there is data for. The range is inclusive and goes from the start of the `from` date to the end of the `to` date apiData: type: array items: $ref: '#/components/schemas/MeteredRequestsSchemaApiDataItems' description: Contains the recorded daily/monthly requests for each metered group required: - grouping - dateRange - apiData ``` ## SDK Code Examples ```python import requests url = "https://app.unleash-instance.example.com/api/admin/metrics/request" querystring = {"grouping":"daily","from":"2024-01-01","to":"2024-01-31"} headers = {"Authorization": ""} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` ```javascript const url = 'https://app.unleash-instance.example.com/api/admin/metrics/request?grouping=daily&from=2024-01-01&to=2024-01-31'; const options = {method: 'GET', headers: {Authorization: ''}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/metrics/request?grouping=daily&from=2024-01-01&to=2024-01-31" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://app.unleash-instance.example.com/api/admin/metrics/request?grouping=daily&from=2024-01-01&to=2024-01-31") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = '' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://app.unleash-instance.example.com/api/admin/metrics/request?grouping=daily&from=2024-01-01&to=2024-01-31") .header("Authorization", "") .asString(); ``` ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/metrics/request?grouping=daily&from=2024-01-01&to=2024-01-31', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://app.unleash-instance.example.com/api/admin/metrics/request?grouping=daily&from=2024-01-01&to=2024-01-31"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", ""); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://app.unleash-instance.example.com/api/admin/metrics/request?grouping=daily&from=2024-01-01&to=2024-01-31")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```