Check HikerAPI Endpoint Deprecation with Python

Before updating an Instagram integration, check whether the API operations it uses are still listed in the current schema and whether they are marked deprecated. A small Python script can do that without making a request for Instagram data.

This example uses HikerAPI's public OpenAPI document. It downloads the document once, then checks the method and path for each operation you name. It needs Python 3.11 or later and its standard library. The example runs without an API key.

What the check tells you

In OpenAPI, deprecated: true marks an operation as deprecated. If the field is omitted, its default is false. The flag belongs to an operation, such as GET /v1/user/by/username; checking only that the path exists is insufficient because another method could be defined at the same path. OpenAPI operation reference.

The script returns three operation states:

State Meaning
NOT_DEPRECATED The operation exists in this document and has no deprecation flag, or an explicit false flag.
DEPRECATED The operation exists and its flag is true.
MISSING This method and path do not appear in the downloaded document.

MISSING does not establish that the service removed an endpoint. A schema can be incomplete or out of date. Likewise, NOT_DEPRECATED does not prove that an authenticated data request will succeed. Check those questions separately.

Save the checker

Save this as check_deprecations.py:

"""Check named operations in HikerAPI's public schema, without a data call."""

import argparse
import json
import sys
from http.client import HTTPException
from urllib.error import URLError
from urllib.request import Request, urlopen

SCHEMA_URL = "https://api.hikerapi.com/openapi.json"
METHODS = {"get", "put", "post", "delete", "options", "head", "patch", "trace"}


def check_operation(spec, method, path):
    if not isinstance(spec, dict) or not isinstance(spec.get("paths"), dict):
        raise ValueError("Expected an OpenAPI document with a paths object")
    if path not in spec["paths"]:
        return "MISSING"
    item = spec["paths"][path]
    if not isinstance(item, dict) or "$ref" in item:
        raise ValueError("Expected an inline path item; references need resolution")
    method = method.lower()
    if method not in item:
        return "MISSING"
    operation = item[method]
    if not isinstance(operation, dict):
        raise ValueError("Expected an operation object")
    flag = operation.get("deprecated", False)
    if type(flag) is not bool:
        raise ValueError("deprecated must be a boolean")
    return "DEPRECATED" if flag else "NOT_DEPRECATED"


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--operation", action="append", metavar='"METHOD /path"',
                        help="Repeat for operations your integration uses")
    args = parser.parse_args()
    targets = []
    for value in args.operation or ["GET /v1/user/by/username"]:
        parts = value.split()
        if len(parts) != 2 or parts[0].lower() not in METHODS or not parts[1].startswith("/"):
            parser.error('Use --operation "METHOD /path"')
        targets.append((parts[0].upper(), parts[1]))
    try:
        request = Request(SCHEMA_URL, headers={
            "Accept": "application/json", "User-Agent": "HikerAPI-deprecation-check/1.0"})
        with urlopen(request, timeout=20) as response:
            spec = json.load(response)
        results = [(method, path, check_operation(spec, method, path))
                   for method, path in targets]
    except (HTTPException, URLError, OSError, ValueError) as error:
        print(f"SCHEMA_ERROR: {error}", file=sys.stderr)
        return 2
    for method, path, state in results:
        print(f"{state}: {method} {path}")
    return int(any(state != "NOT_DEPRECATED" for _, _, state in results))


if __name__ == "__main__":
    raise SystemExit(main())

The request goes only to /openapi.json. Arguments such as --operation "GET /v1/user/by/username" select entries inside that JSON document; the script does not send requests to those data endpoints. If you omit --operation, the script checks GET /v1/user/by/username as a sample only; in CI, name the operations your own integration uses. The request includes a descriptive User-Agent, an Accept header and a 20-second timeout. A failed download or invalid JSON is reported as SCHEMA_ERROR, rather than being treated as an all-clear.

This is a focused check for inline path items, not a full OpenAPI validator or reference resolver. A path item containing $ref produces an error for manual investigation.

Check the operations your application uses

Start with one operation:

python3 check_deprecations.py --operation "GET /v1/user/by/username"

During verification on 31 October 2026, the live schema produced:

NOT_DEPRECATED: GET /v1/user/by/username

Now name a legacy operation:

python3 check_deprecations.py --operation "GET /v1/user/medias"

The same day's live check produced:

DEPRECATED: GET /v1/user/medias

For a deliberately absent operation:

python3 check_deprecations.py --operation "GET /not-a-real-operation-for-this-example"

The result was:

MISSING: GET /not-a-real-operation-for-this-example

These are dated observations, not fixed expectations for a changing schema. Replace the examples with the operations your own application calls. Repeat the argument to check several operations in one schema download:

python3 check_deprecations.py \
  --operation "GET /v1/user/by/username" \
  --operation "GET /v1/user/medias"

Use the exit status in a build check

Exit status Meaning
0 Every requested operation is present and not marked deprecated.
1 At least one requested operation is deprecated or missing.
2 The check could not complete: for example, a download error, malformed document or invalid CLI argument.

A CI step can run the command before deployment. Treat status 1 as a reason to review the affected operation and status 2 as an incomplete check. A network failure is not evidence that an endpoint was removed.

When an operation is deprecated, consult its current documentation and the changelog for the replacement. Do not guess a replacement by incrementing /v1 to /v2, or make an automatic migration from this flag alone. This script does not inspect response fields, parameter-level deprecations or other breaking changes.

HikerAPI's deprecation policy explains the separate lifecycle rules. Provider-led replacements have a minimum notice period; upstream Instagram changes can shorten the available migration time. The schema flag itself does not give you a removal date.

Review your integration's operation list

Keep the list of methods and paths alongside your integration and update it when the code changes. A check of a sample operation says nothing about the other calls your application makes.

Open the HikerAPI API reference to review the operations your application uses, their parameters and any migration notes.

Related Guides

Ready to get started?

100 free API requests. No credit card required.

Sign Up Free