Skip to content

new_mcr_price

jvdspeare edited this page Feb 19, 2019 · 1 revision

new_mcr_price

Retrieve the cost of a new MCR given the location and speed.

Usage

import megalib
x = megalib.new_port_price(header, loc_id, speed, prod)

Arguments

header (required) String Header

loc_id (required) Integer Location ID

speed (required) Integer Service Speed (100, 500, 1000, 2000, 3000, 4000 or 5000)

prod Boolean Environment, True = https://api.megaport.com, False = https://api-staging.megaport.com

Response

x.status_code Integer HTTPS Response Status Code

x.json Integer Response

x.currency String Currency

x.monthly_rate Integer Monthly Cost

Example

source

# Import megalib
import megalib

# Authenticate user credentials using the megalib.login function
auth = megalib.login(input('username: '), input('password: '), input('tfa (leave black if not enabled): '), prod=True)

# Check if logging was successful by observing the HTTP Status Code
if auth.status_code == 200:
    print('login successful')

    # Retrieve new mcr price using the megalib.new_port_price function
    price = megalib.new_mcr_price(auth.header, input('location id: '), input('speed: '), input('term: '), prod=True)

    # Print monthly cost
    if price.status_code == 200:
        print(price.currency + ' ' + str(price.monthly_rate))

    # Advise user if lookup failed
    else:
        print('price lookup failed')

# Advise user if login failed
else:
    print('login failed')

Megaport API documentation

New MCR Price

Clone this wiki locally