Skip to content

new_ix_price

jvdspeare edited this page Feb 19, 2019 · 1 revision

new_ix_price

Retrieve the cost of a new IX service given the target IX, location and speed.

Usage

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

Arguments

header (required) String Header

ix_name (required) String Target IX Name

loc_id (required) Integer Location ID

speed (required) Integer Service Speed

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 ix price using the megalib.new_ix_price function
    price = megalib.new_ix_price(auth.header, input('target ix name: '), input('location id: '), input('speed: '), 
                                 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 IX Price

Clone this wiki locally