Package Exports
- azure-retail-prices
- azure-retail-prices/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (azure-retail-prices) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
azure-retail-prices
This is wrapper of Azure Retail Prices API.
You can easily get the retail price of Azure without authenticating.
Installation
# via npm
npm install --save azure-retail-prices
# via yarn
yarn add azure-retail-prices
Examples
After having cloned this repository, run the following commands:
cd example/
npm install
npm run import-sample
# # or
# npm run require-sample
Usage
import arp from "azure-retail-prices";
// // or
// const arp = require("azure-retail-prices").default;
async function getRetailPrices() {
// without currencyCode option (It will return USD)
let retailPrices = await arp({
serviceName: "Virtual Machines",
location: "EU West",
priceType: "Reservation",
});
console.dir(retailPrices);
// with currencyCode option
retailPrices = await arp(
{
serviceName: "Virtual Machines",
location: "EU West",
priceType: "Reservation",
},
"JPY"
);
console.dir(retailPrices);
}
Sample calls
Here are some examples:
// Compute resources
// - Response count: 150K+
// - Response time: 25 minutes
const retailPrices = await arp({
serviceFamily: "Compute",
});
// Virtual machines
// - Response count: 130K+
// - Response time: 20 minutes
const retailPrices = await arp({
serviceName: "Virtual Machines",
});
// Virtual machines located "EU West"
// - Response count: 4K+
// - Response time: 40 seconds
const retailPrices = await arp({
serviceName: "Virtual Machines",
location: "EU West",
});
// Virtual machines located "EU West" with currency in EUR
// - Response count: 4K+
// - Response time: 40 seconds
const retailPrices = await arp(
{
serviceName: "Virtual Machines",
location: "EU West",
},
"EUR"
);
// Reserved virtual machines located "EU West"
// - Response count: 700+
// - Response time: 8 seconds
const retailPrices = await arp({
serviceName: "Virtual Machines",
location: "EU West",
priceType: "Reservation",
});
// Identify by unique ID
// - Response count: 2
// - Response time: 1 second
const retailPrices = await arp({
meterId: "000a794b-bdb0-58be-a0cd-0c3a0f222923",
});
Response examples
Here's a sample response, without reservation prices.
[
{
"currencyCode": "USD",
"tierMinimumUnits": 0.0,
"retailPrice": 0.176346,
"unitPrice": 0.176346,
"armRegionName": "westeurope",
"location": "EU West",
"effectiveStartDate": "2020-08-01T00:00:00Z",
"meterId": "000a794b-bdb0-58be-a0cd-0c3a0f222923",
"meterName": "F16s Spot",
"productId": "DZH318Z0BQPS",
"skuId": "DZH318Z0BQPS/00TG",
"productName": "Virtual Machines FS Series Windows",
"skuName": "F16s Spot",
"serviceName": "Virtual Machines",
"serviceId": "DZH313Z7MMC8",
"serviceFamily": "Compute",
"unitOfMeasure": "1 Hour",
"type": "DevTestConsumption",
"isPrimaryMeterRegion": true,
"armSkuName": "Standard_F16s"
}
]
Here's a sample response with reservation prices and term in the response.
[
{
"currencyCode": "USD",
"tierMinimumUnits": 0.0,
"reservationTerm": "1 Year",
"retailPrice": 25007.0,
"unitPrice": 25007.0,
"armRegionName": "southcentralus",
"location": "US South Central",
"effectiveStartDate": "2020-08-01T00:00:00Z",
"meterId": "0016083a-928f-56fd-8eeb-39287dcf676d",
"meterName": "E64 v4",
"productId": "DZH318Z0D1L7",
"skuId": "DZH318Z0D1L7/018J",
"productName": "Virtual Machines Ev4 Series",
"skuName": "E64 v4",
"serviceName": "Virtual Machines",
"serviceId": "DZH313Z7MMC8",
"serviceFamily": "Compute",
"unitOfMeasure": "1 Hour",
"type": "Reservation",
"isPrimaryMeterRegion": true,
"armSkuName": "Standard_E64_v4"
}
]
Filters
You can append the filters to function call, as shown in the Sample calls.
Filters are supported for the following fields:
Fields | Example Values | Definition |
---|---|---|
armRegionName | westeurope | ARM region where the service is available. This version only supports prices on Commercial Cloud. |
location | EU West | Azure data center where the resource is deployed |
meterId | 000a794b-bdb0-58be-a0cd-0c3a0f222923 | Unique identifier of the resource |
meterName | F16s Spot | Name of the meter |
productId | DZH318Z0BQPS | UniqueID of the product |
skuId | DZH318Z0BQPS/00TG | UniqueID for the SKU |
productName | Virtual Machines FS Series Windows | Product name |
skuName | F16s Spot | SKU name |
serviceName | Virtual Machines | Name of the service |
serviceId | DZH313Z7MMC8 | UniqueID of the service |
serviceFamily | Compute | Service family of the SKU |
priceType | DevTestConsumption | Meter consumption type. Other types are Reservation , Consumption . |
armSkuName | Standard_F16s | SKU name registered in Azure |
Supported currencies
You append the currency code to the API endpoint, as shown in the API sample call.
Currency code | Detail |
---|---|
USD | US dollar |
AUD | Australian dollar |
BRL | Brazilian real |
CAD | Canadian dollar |
CHF | Swiss franc |
CNY | Chinese yuan |
DKK | Danish krone |
EUR | Euro |
GBP | British pound |
INR | Indian rupee |
JPY | Japanese yen |
KRW | Korean won |
NOK | Norwegian krone |
NZD | New Zealand dollar |
RUB | Russian ruble |
SEK | Swedish krona |
TWD | Taiwan dollar |
License
This library is licensed under the MIT License.