Chapter 4. Example Script


#!/usr/bin/env python
from __future__ import print_function
import sys
import requests
from datetime import datetime, timedelta

API_HOST = 'https://access.redhat.com/product-life-cycles/api/v1'


def get_data(query):

    full_query = API_HOST + query
    r = requests.get(full_query)

    if r.status_code != 200:
        print('ERROR: Invalid request; returned {} for the following '
              'query:\n{}'.format(r.status_code, full_query))
        sys.exit(1)

    if not r.json():
        print('No data returned with the following query:')
        print(full_query)
        sys.exit(0)

    return r.json()

# Get RHEL and Openshift Container Platform 4 life cycle data
endpoint = '/products'
params = 'name=Red Hat Enterprise Linux,Openshift Container Platform 4'

data = get_data(endpoint + '?' + params)
products = data['data']

for product in products:
    print(product)

# Get RHEL and Openshift Container Platform 4 life cycle data using legacy JSON endpoint
endpoint = '/plccapi/lifecycle.json'
params = 'products=Red Hat Enterprise Linux,Openshift Container Platform 4'

data = get_data(endpoint + '?' + params)

for product in data:
    print(product)

print('-----')
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top