Protocols

Introduction

When integrating Netify into a UX, it is often necessary to present to the end user a list of supported protocols. An API endpoint is available to fetch Netify's protocol list as JSON objects that can then be easily parsed as needed.

Script Examples

Bash

curl https://informatics.netify.ai/api/v2/lookup/protocols?settings_limit=10000

Python

Copy and save the Python script below to a file named, for example, netify.py, and execute. The script provided is just a demonstration of sample metadata available and how to format (ex. CSV). Feel free to modify the scripts to access any JSON attributes available in the raw data.

python3 netify.py --csv protos
"ID","Label","Category","Homepage"
"30139","Citrix Online","Remote Desktop","https://en.wikipedia.org/wiki/Citrix_Online"
"30118","Meebo","Messaging","https://en.wikipedia.org/wiki/Meebo"
..
.
"0","Unclassified","Unclassified",""

To get the full JSON output, omit the --csv option.

curl https://informatics.netify.ai/api/v2/lookup/protocols?settings_limit=10000
import json
import requests
import sys
import getopt

def main():

    try:
        opts, args = getopt.getopt(sys.argv[1:], "c", ["csv"])
    except getopt.GetoptError as err:
        print(f"Error: {err}")
        sys.exit(2)

    csv = False
    for opt, _ in opts:
        if opt in ("-c", "--csv"):
            csv = True

    if len(args) != 1 or args[0] not in ("apps", "protos"):
        print("Usage: netify.py [-v] ")
        sys.exit(2)

    resource = args[0]

    if resource == "apps":
        url = 'https://informatics.netify.ai/api/v2/lookup/applications'
    else:
        url = 'https://informatics.netify.ai/api/v2/lookup/protocols'

    params = {
        'settings_data_format': 'objects',
        'settings_limit':10000,
    }

    headers = {
        'content-type': 'application/json',
    }

    response = requests.get(url, data=json.dumps(params), headers=headers)

    data = response.json()['data']
    if csv == True:
        print('"ID","Label","Category","Homepage"')

    for d in data:
        if csv == True:
            print('"%d","%s","%s","%s"' % (d['id'], d['label'], d['category']['label'], d['home_page']['url']))

    if csv == False:
        jprint(data)

def jprint(obj):
    text = json.dumps(obj, sort_keys=True, indent=4)
    print(text)

if __name__ == "__main__":
    main()

Next Steps

Technical Support

Haven't found the answers you're looking for?

Contact Us