arazzo: 1.0.1
info:
title: Treblle Find a Project and Pull Its Analytics
summary: List workspace projects, select the first one, and retrieve its analytics over a date range.
description: >-
A discovery-to-insight flow for callers who do not yet know a project ID.
The workflow lists all projects in the workspace, branches on whether any
exist, and when at least one is present pulls aggregated analytics for the
first project returned. Every step spells out its request inline so the flow
can be read and executed without opening the underlying OpenAPI description.
version: 1.0.0
sourceDescriptions:
- name: analyticsApi
url: ../openapi/treblle-analytics-api-openapi.yml
type: openapi
- name: projectsApi
url: ../openapi/treblle-projects-api-openapi.yml
type: openapi
workflows:
- workflowId: find-project-and-analytics
summary: Discover the first workspace project and retrieve its analytics.
description: >-
Lists workspace projects and, when at least one exists, pulls analytics for
the first project over the supplied date range.
inputs:
type: object
required:
- apiKey
properties:
apiKey:
type: string
description: Treblle API key passed in the Treblle-Api-Key header.
startDate:
type: string
description: Analytics start date (YYYY-MM-DD).
endDate:
type: string
description: Analytics end date (YYYY-MM-DD).
steps:
- stepId: listProjects
description: List all projects in the workspace.
operationId: $sourceDescriptions.projectsApi.listProjects
parameters:
- name: Treblle-Api-Key
in: header
value: $inputs.apiKey
successCriteria:
- condition: $statusCode == 200
outputs:
firstProjectId: $response.body#/data/0/id
onSuccess:
- name: projectsExist
type: goto
stepId: getAnalytics
criteria:
- context: $response.body
condition: $.data[0]
type: jsonpath
- name: noProjects
type: end
- stepId: getAnalytics
description: >-
Retrieve aggregated analytics for the first project over the supplied
date range.
operationId: $sourceDescriptions.analyticsApi.getProjectAnalytics
parameters:
- name: Treblle-Api-Key
in: header
value: $inputs.apiKey
- name: projectId
in: path
value: $steps.listProjects.outputs.firstProjectId
- name: start_date
in: query
value: $inputs.startDate
- name: end_date
in: query
value: $inputs.endDate
successCriteria:
- condition: $statusCode == 200
outputs:
totalRequests: $response.body#/total_requests
errorRate: $response.body#/error_rate
avgResponseTime: $response.body#/avg_response_time
outputs:
projectId: $steps.listProjects.outputs.firstProjectId
totalRequests: $steps.getAnalytics.outputs.totalRequests
errorRate: $steps.getAnalytics.outputs.errorRate
avgResponseTime: $steps.getAnalytics.outputs.avgResponseTime
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. By signing up you are subscribing to the APIs.io and API Evangelist
newsletters — you can unsubscribe from any issue. See our
Privacy Policy and Terms.