# Misc › Consumption API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Misc product's sections: https://developers.eu.ovhcloud.com/reference/misc/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 3 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/misc/consumption/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/misc/consumption.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/misc/consumption.json?format=openapi3

## Operations

- `GET /me/consumption/usage/current` — Get on-going consumptions for all services
- `GET /me/consumption/usage/forecast` — Get forecasted consumptions for all services
- `GET /me/consumption/usage/history` — Get list of transactions between two dates

## Get on-going consumptions for all services

`GET /1.0/me/consumption/usage/current`

Link: https://developers.eu.ovhcloud.com/reference/misc/consumption/#get-me-consumption-usage-current

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/consumption/usage/current/get`

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | me.consumption.Transaction[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `beginDate` | string (date-time) | read-only | Begin date |
| `creationDate` | string (date-time) | read-only | Creation date |
| `elements` | me.consumption.transaction.Element[] | read-only | List of product plan code consumption |
| `elements[].details` | me.consumption.transaction.element.Detail[] | read-only | List of consumption details for this planCode |
| `elements[].details[].price` | me.consumption.Price | read-only | Consumption amount price |
| `elements[].details[].quantity` | integer | read-only | Consumption quantity |
| `elements[].details[].unique_id` | string | read-only | Unique ID associated to one service element |
| `elements[].planCode` | string | read-only | Identifier of the offer |
| `elements[].planFamily` | string | read-only | Family of the offer |
| `elements[].price` | me.consumption.Price | read-only | Consumption amount price |
| `elements[].price.currencyCode` | order.CurrencyCodeEnum | read-only | Currency code — one of `AUD`, `CAD`, `CZK`, `EUR`, `GBP`, `INR`, `LTL`, `MAD`, `N/A`, `PLN`, `SGD`, `TND`, … |
| `elements[].price.text` | string | read-only |  |
| `elements[].price.value` | number | read-only |  |
| `elements[].price.valueInUcents` | integer | read-only |  |
| `elements[].quantity` | integer | read-only | Consumption quantity |
| `endDate` | string (date-time) | read-only | End date |
| `id` | integer | read-only | Transaction ID |
| `lastUpdate` | string (date-time) | read-only | Last update |
| `price` | me.consumption.Price | read-only | Consumption amount price |
| `price.currencyCode` | order.CurrencyCodeEnum | read-only | Currency code — one of `AUD`, `CAD`, `CZK`, `EUR`, `GBP`, `INR`, `LTL`, `MAD`, `N/A`, `PLN`, `SGD`, `TND`, … |
| `price.text` | string | read-only |  |
| `price.value` | number | read-only |  |
| `price.valueInUcents` | integer | read-only |  |
| `serviceId` | integer | read-only | Service ID |

```json
[
  {
    "beginDate": "2024-01-01T12:00:00Z",
    "creationDate": "2024-01-01T12:00:00Z",
    "elements": [
      {
        "details": [
          {
            "price": {
              "currencyCode": null,
              "text": null,
              "value": null,
              "valueInUcents": null
            },
            "quantity": 0,
            "unique_id": "string"
          }
        ],
        "planCode": "string",
        "planFamily": "string",
        "price": {
          "currencyCode": "AUD",
          "text": "string",
          "value": 0,
          "valueInUcents": 0
        },
        "quantity": 0
      }
    ],
    "endDate": "2024-01-01T12:00:00Z",
    "id": 0,
    "lastUpdate": "2024-01-01T12:00:00Z",
    "price": {
      "currencyCode": "AUD",
      "text": "string",
      "value": 0,
      "valueInUcents": 0
    },
    "serviceId": 0
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/me/consumption/usage/current" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/me/consumption/usage/current")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/me/consumption/usage/current");

print_r($result);
?>
```

## Get forecasted consumptions for all services

`GET /1.0/me/consumption/usage/forecast`

Link: https://developers.eu.ovhcloud.com/reference/misc/consumption/#get-me-consumption-usage-forecast

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/consumption/usage/forecast/get`

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | me.consumption.Transaction[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `beginDate` | string (date-time) | read-only | Begin date |
| `creationDate` | string (date-time) | read-only | Creation date |
| `elements` | me.consumption.transaction.Element[] | read-only | List of product plan code consumption |
| `elements[].details` | me.consumption.transaction.element.Detail[] | read-only | List of consumption details for this planCode |
| `elements[].details[].price` | me.consumption.Price | read-only | Consumption amount price |
| `elements[].details[].quantity` | integer | read-only | Consumption quantity |
| `elements[].details[].unique_id` | string | read-only | Unique ID associated to one service element |
| `elements[].planCode` | string | read-only | Identifier of the offer |
| `elements[].planFamily` | string | read-only | Family of the offer |
| `elements[].price` | me.consumption.Price | read-only | Consumption amount price |
| `elements[].price.currencyCode` | order.CurrencyCodeEnum | read-only | Currency code — one of `AUD`, `CAD`, `CZK`, `EUR`, `GBP`, `INR`, `LTL`, `MAD`, `N/A`, `PLN`, `SGD`, `TND`, … |
| `elements[].price.text` | string | read-only |  |
| `elements[].price.value` | number | read-only |  |
| `elements[].price.valueInUcents` | integer | read-only |  |
| `elements[].quantity` | integer | read-only | Consumption quantity |
| `endDate` | string (date-time) | read-only | End date |
| `id` | integer | read-only | Transaction ID |
| `lastUpdate` | string (date-time) | read-only | Last update |
| `price` | me.consumption.Price | read-only | Consumption amount price |
| `price.currencyCode` | order.CurrencyCodeEnum | read-only | Currency code — one of `AUD`, `CAD`, `CZK`, `EUR`, `GBP`, `INR`, `LTL`, `MAD`, `N/A`, `PLN`, `SGD`, `TND`, … |
| `price.text` | string | read-only |  |
| `price.value` | number | read-only |  |
| `price.valueInUcents` | integer | read-only |  |
| `serviceId` | integer | read-only | Service ID |

```json
[
  {
    "beginDate": "2024-01-01T12:00:00Z",
    "creationDate": "2024-01-01T12:00:00Z",
    "elements": [
      {
        "details": [
          {
            "price": {
              "currencyCode": null,
              "text": null,
              "value": null,
              "valueInUcents": null
            },
            "quantity": 0,
            "unique_id": "string"
          }
        ],
        "planCode": "string",
        "planFamily": "string",
        "price": {
          "currencyCode": "AUD",
          "text": "string",
          "value": 0,
          "valueInUcents": 0
        },
        "quantity": 0
      }
    ],
    "endDate": "2024-01-01T12:00:00Z",
    "id": 0,
    "lastUpdate": "2024-01-01T12:00:00Z",
    "price": {
      "currencyCode": "AUD",
      "text": "string",
      "value": 0,
      "valueInUcents": 0
    },
    "serviceId": 0
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/me/consumption/usage/forecast" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/me/consumption/usage/forecast")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/me/consumption/usage/forecast");

print_r($result);
?>
```

## Get list of transactions between two dates

`GET /1.0/me/consumption/usage/history`

Link: https://developers.eu.ovhcloud.com/reference/misc/consumption/#get-me-consumption-usage-history

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/consumption/usage/history/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `beginDate` | query | string (date-time) | yes | Begin date |
| `endDate` | query | string (date-time) | yes | End date |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | me.consumption.Transaction[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `beginDate` | string (date-time) | read-only | Begin date |
| `creationDate` | string (date-time) | read-only | Creation date |
| `elements` | me.consumption.transaction.Element[] | read-only | List of product plan code consumption |
| `elements[].details` | me.consumption.transaction.element.Detail[] | read-only | List of consumption details for this planCode |
| `elements[].details[].price` | me.consumption.Price | read-only | Consumption amount price |
| `elements[].details[].quantity` | integer | read-only | Consumption quantity |
| `elements[].details[].unique_id` | string | read-only | Unique ID associated to one service element |
| `elements[].planCode` | string | read-only | Identifier of the offer |
| `elements[].planFamily` | string | read-only | Family of the offer |
| `elements[].price` | me.consumption.Price | read-only | Consumption amount price |
| `elements[].price.currencyCode` | order.CurrencyCodeEnum | read-only | Currency code — one of `AUD`, `CAD`, `CZK`, `EUR`, `GBP`, `INR`, `LTL`, `MAD`, `N/A`, `PLN`, `SGD`, `TND`, … |
| `elements[].price.text` | string | read-only |  |
| `elements[].price.value` | number | read-only |  |
| `elements[].price.valueInUcents` | integer | read-only |  |
| `elements[].quantity` | integer | read-only | Consumption quantity |
| `endDate` | string (date-time) | read-only | End date |
| `id` | integer | read-only | Transaction ID |
| `lastUpdate` | string (date-time) | read-only | Last update |
| `price` | me.consumption.Price | read-only | Consumption amount price |
| `price.currencyCode` | order.CurrencyCodeEnum | read-only | Currency code — one of `AUD`, `CAD`, `CZK`, `EUR`, `GBP`, `INR`, `LTL`, `MAD`, `N/A`, `PLN`, `SGD`, `TND`, … |
| `price.text` | string | read-only |  |
| `price.value` | number | read-only |  |
| `price.valueInUcents` | integer | read-only |  |
| `serviceId` | integer | read-only | Service ID |

```json
[
  {
    "beginDate": "2024-01-01T12:00:00Z",
    "creationDate": "2024-01-01T12:00:00Z",
    "elements": [
      {
        "details": [
          {
            "price": {
              "currencyCode": null,
              "text": null,
              "value": null,
              "valueInUcents": null
            },
            "quantity": 0,
            "unique_id": "string"
          }
        ],
        "planCode": "string",
        "planFamily": "string",
        "price": {
          "currencyCode": "AUD",
          "text": "string",
          "value": 0,
          "valueInUcents": 0
        },
        "quantity": 0
      }
    ],
    "endDate": "2024-01-01T12:00:00Z",
    "id": 0,
    "lastUpdate": "2024-01-01T12:00:00Z",
    "price": {
      "currencyCode": "AUD",
      "text": "string",
      "value": 0,
      "valueInUcents": 0
    },
    "serviceId": 0
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/me/consumption/usage/history" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/me/consumption/usage/history")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/me/consumption/usage/history");

print_r($result);
?>
```
