Skip to main content
Cost API
Updated over 2 months ago

Cost API

Finout Cost API enables you to query and analyze costs using user-defined Finout views. You can easily get a list of your views and retrieve the costs for a specified view. You can query the costs for any date range of up to 90 days specified in UTC timestamps. The results are returned in JSON format for easy processing.

Note: Only cost data is returned when querying a view via the Cost API.

Finout API is fully secured using a secret key and client token, which can be managed from your Finout account. Your Finout account allows for five concurrent requests per API key. When you generate the API token, it creates both a secret key and a client ID (token). These parameters will be passed in the Authorization header when invoking any Finout API methods.

Important: Copy and save your Client ID and Secret Key for future use. They will only appear once and will not show again.

To configure API access:

  1. Select your profile from the user dropdown on the top left of any screen in Finout.

  2. Click Admin Portal. The Profile window appears.

  3. Select API Tokens. The API Token screen appears.

  4. Click Generate Token. The Generate Token window appears.

  5. Enter a Description, choose a role, choose token expiration, and click Create. Your token is generated.

  6. Copy the Client ID and the Secret Key, which won't be accessible later, and then click Done.

  7. Add the Client ID and Secret Key in Headers when invoking any of the Finout endpoints:

    • x-finout-client-id

    • x-finout-secret-key

GET view

Description

Gets a list of all your account views. For more information on views, see Finout Views.

Note: Only cost data is returned when querying a view via the Cost API.

Prerequisites

  • You must create a view in the MegaBill before querying the GET view. There is currently no 'Create View' API option.

  • Generate a Client ID and Secret Key from Finout to add in Headers.

Base URL

The base URL for all API requests is: https://app.finout.io/v1/

Endpoints

GET/view

Parameters

None

Response

Returns a JSON object with the following properties:

  • name: The names of your account's views.

  • id: The unique identifier of your account's views.

Example

Request:

https://app.finout.io/v1/view

Response:

{

"data": [

{

"name": "Nat Gateways",

"id": "6244e453-e8b8-4f1f-9a96-4ba1ae5d48f7"

},

{

"name": "K8s by App_Component",

"id": "f76be053-1138-431f-a6e1-9f6d1852398b"

}

],

"requestId": "c130a3f4-13f3-4c64-8f26-bd0f9c5fc2e5"

}

Errors

400

Bad Request

401

Unauthorized

429

Too many requests

503

Server unavailable

504

Gateway Timeout

POST query by view

Description

Return all costs for a specified view and date range for up to 90 days. For more information on views, see Finout Views.

.

Prerequisites

  • You must first GET the view you want to query

  • Add the GET view ID to the body of the POST query.
    Example:
    {

    "viewId": "6244e453-e8b8-4f1f-9a96-4ba1ae5d48f7"

    }

  • You must either specify dates or delete them completely. The query won't work when blank dates are still present.
    Example:
    {

"viewId": "6244e453-e8b8-4f1f-9a96-4ba1ae5d48f7",

"date": {

"unixTimeMillSecondsStart": 1719824738,

"unixTimeMillSecondsEnd": 1719911138

},

"costType": "netAmortizedCost"

}

Base URL

The base URL for all API requests is: https://app.finout.io/v1/


Endpoints

POST/query-by-view

Parameters

Parameter

Type

Description

viewId

String

The viewId is returned by the view endpoint.
Note: If a ViewID is saved with a GroupBy, the data attribute in the response will display results organized by the specified GroupBy values.

date

It is optional to specify the date object. If this is not specified, the date defaults to the date range in the specified view.

unixTimeMillSecondsStart

Numeric

Start Date represented in Unix Epoch time

unixTimeMillSecondsEnd

Numeric

End Date represented in Unix Epoch time

costType

String

Types of costs:
- blendedCost
- unblendedCost
- netUnblendedCost
- amortizedCost
- netAmortizedCost
See Cost and Usage Types for an explanation of each cost.

Response

Returns a JSON object with the following properties:

  • name: The names of your account's views.

  • id: The unique identifier of your account's views.

  • cost : The cost for each group per period.

Example

Request:

https://app.finout.io/v1/cost/query-by-view
Body of request:
{

"viewId": "9c0344f2-94d6-4b9a-b1d5-e57353c117ee",

"date": {

"unixTimeMillSecondsStart": 1719824738,

"unixTimeMillSecondsEnd": 1719911138

},

"costType": "netAmortizedCost"

}

Response without groupby:

{

"data": [

{

"name": "Total",

"data": [

{

"time": 1716768000000,

"cost": 0

},

{

"time": 1719100800000,

"cost": 0

}

]

}

],

"request": {

"viewId": "9c0344f2-94d6-4b9a-b1d5-e57353c117ee"

},

"requestId": "610fada6-bd33-4ef0-b2e4-da581d7620ab"

}

Response with groupby:

{

"data": [

{

"name": "Total",

"data": [

{

"time": 1716768000000,

"cost": 150

},

{

"time": 1719100800000,

"cost": 220

}

]

},

{

"name": "AmazonS3",

"data": [

{

"time": 1716768000000,

"cost": 50

},

{

"time": 1719100800000,

"cost": 20

}

]

},

{

"name": "AmazonEC2",

"data": [

{

"time": 1716768000000,

"cost": 100

},

{

"time": 1719100800000,

"cost": 200

}

]

}

],

"request": {

"viewId": "9c0344f2-94d6-4b9a-b1d5-e57353c117ee"

},

"requestId": "610fada6-bd33-4ef0-b2e4-da581d7620ab"

}

Errors

400

Bad Request

401

Unauthorized

429

Too many requests

503

Server unavailable

504

Gateway Timeout

Did this answer your question?