- 25 May 2023
- 3 Minutes to read
- PDF
Public APIs
- Updated on 25 May 2023
- 3 Minutes to read
- PDF
Traceable provides GraphQL public APIs that you can leverage to use your existing automation setup to access Traceable. You can use Traceable's public API for configuration and accessing operational data. To use Traceable's GraphQL public API, you have to complete the following two steps:
- Login to Traceable Platform to copy the Platform API token. This token is used in the GraphQL API client.
- Install or use an existing GraphQL client. The topic explains using Altair GraphQL client. For more information on downloading the client, see Altair GraphQL client.
The topic also provides some examples of Traceable's public APIs.
Step 1 – Copy the Platform API token
Complete the following steps to access the Platform API token:
- Login to Traceable Platform.
- Navigate to Your Account > My Preferences as shown below.
- On the My Preferences page, click on API Tokens > Generate API Token as shown below.
- Copy the token and then click on Okay.
You can only edit or delete the token. When you edit the token, you can only change the name of the token and not the value of the token.
Step 2 – Access the Public API
You can use any GraphQL client to access Traceable's public API. In the below steps, we are using Altair GraphQL client. Complete the following steps in Altair GraphQL client:
- Launch the Altair GraphQL client and click on the Set Headers icon as shown below.
- Click on Add header in the Headers window to add the
Authorization
header. Add the Platform API Token that you copied in step 1 and click on Save. - Add the
https://api.traceable.ai/graphql
URL and click on Reload Docs icon as shown below. - Click on Queries or Mutations to start exploring the documentation. You can also type your query in the search field.
Example Queries
Total number of learned APIs
Query
query {
entities(
scope: "API"
between: {
startTime: "2021-10-27T22:52:55.026Z"
endTime: "2021-10-27T23:52:55.026Z"
}
filterBy: [
{
keyExpression: { key: "isLearnt" }
operator: EQUALS
value: true
type: ATTRIBUTE
}
{
keyExpression: { key: "apiDiscoveryState" }
operator: IN
value: ["DISCOVERED", "UNDER_DISCOVERY"]
type: ATTRIBUTE
}
]
includeInactive: true
) {
total
}
}
Result
{
"data": {
"entities": {
"total": 658
}
}
}
Total number of learning API endpoints
Query
query {
entities(
scope: "API"
between: {
startTime: "2021-10-27T22:52:55.026Z"
endTime: "2021-10-27T23:52:55.026Z"
}
filterBy: [
{
keyExpression: { key: "isLearnt" }
operator: EQUALS
value: false
type: ATTRIBUTE
}
{
keyExpression: { key: "apiDiscoveryState" }
operator: IN
value: ["DISCOVERED", "UNDER_DISCOVERY"]
type: ATTRIBUTE
}
]
includeInactive: true
) {
total
}
}
Result
{
"data": {
"entities": {
"total": 33657
}
}
}
Total number of services
Query
{
entities(
scope: "SERVICE"
limit: 1
between: {startTime: "2021-10-27T22:52:55.026Z", endTime: "2021-10-27T23:52:55.026Z"}
includeInactive: true
) {
total
}
}
Result
{
"data": {
"entities": {
"total": 572
}
}
}
Top 10 APIs
The following query fetches top 10 API endpoints by call volume.
Query
{
explore(
scope: "API"
limit: 10
between: {
startTime: "2022-01-01T22:52:55.026Z"
endTime: "2022-01-10T23:52:55.026Z"
}
filterBy: [
{
keyExpression: { key: "apiDiscoveryState" }
operator: IN
value: ["DISCOVERED", "UNDER_DISCOVERY"]
type: ATTRIBUTE
}
]
groupBy: {
expressions: [{ key: "id" }, { key: "name" }]
groupLimit: 10000
}
orderBy: [
{ keyExpression: { key: "name" }, aggregation: COUNT, direction: DESC }
]
) {
results {
id: selection(expression: { key: "id" }) {
value
}
name: selection(expression: { key: "name" }) {
value
}
count_name: selection(expression: { key: "name" }, aggregation: COUNT) {
value
}
}
}
}
Result
{
"data": {
"explore": {
"results": [
{
"id": {
"value": "7ccf74e7-8b28-360a-a5b9-e701ddf6b828"
},
"name": {
"value": "hipstershop.ProductCatalogService.GetProduct"
},
"count_name": {
"value": 2784148
}
},
{
"id": {
"value": "457b9ecc-91be-30c2-b814-e11ba0f5b396"
},
"name": {
"value": "GET /product/{product-id}"
},
"count_name": {
"value": 1286569
}
},
{
"id": {
"value": "6806a4b7-ad8a-32b4-83ca-a46653f87cbc"
},
"name": {
"value": "POST /partner/{partner-id}"
},
"count_name": {
"value": 649034
}
},
{
"id": {
"value": "906589e9-2064-3f1c-991f-a71d78d8cce3"
},
"name": {
"value": "GET /loginservice/check"
},
"count_name": {
"value": 492144
}
},
{
"id": {
"value": "ccbd507b-60db-330e-aafa-facc559f0228"
},
"name": {
"value": "hipstershop.CurrencyService.Convert"
},
"count_name": {
"value": 470178
}
},
{
"id": {
"value": "fd271283-9c38-3767-9fb4-5a4a3cc7aec4"
},
"name": {
"value": "hipstershop.ProductCatalogService.ListProducts"
},
"count_name": {
"value": 396176
}
},
{
"id": {
"value": "09b1f28b-9075-3e62-8313-e5640041c143"
},
"name": {
"value": "hipstershop.ProductCatalogService.GetProductsSlice"
},
"count_name": {
"value": 265645
}
},
{
"id": {
"value": "8e4dbf89-ce90-3f3d-8461-0a227b961085"
},
"name": {
"value": "hipstershop.CartService.GetCart"
},
"count_name": {
"value": 211799
}
},
{
"id": {
"value": "1a4dddc6-6bd6-3f31-916b-e8beb514dbf2"
},
"name": {
"value": "hipstershop.RecommendationService.ListRecommendations"
},
"count_name": {
"value": 203979
}
},
{
"id": {
"value": "98a5be1d-ed4b-370c-a953-5ce58441178d"
},
"name": {
"value": "GET /product"
},
"count_name": {
"value": 179195
}
}
]
}
}
}