{"id":8769,"library":"wadllib","title":"WADLLib","description":"wadllib is a Python library designed to help navigate HTTP resources by parsing and interpreting Web Application Description Language (WADL) files. It allows developers to programmatically explore API structures, resources, methods, and parameters defined in a WADL document, providing a machine-readable guide to RESTful services. The current version is 2.0.0, released in January 2024, with active maintenance targeting Python 3.8+.","status":"active","version":"2.0.0","language":"en","source_language":"en","source_url":"https://github.com/wadllib/wadllib","tags":["WADL","REST","HTTP","client","API description","API specification"],"install":[{"cmd":"pip install wadllib","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"In wadllib 2.0.0+, the main Application class and other core components moved from the top-level 'wadl' module to 'wadllib.application' and other submodules within 'wadllib'.","wrong":"from wadl import Application","symbol":"Application","correct":"from wadllib.application import Application"},{"note":"Used for direct interaction with WADL files or XML strings, providing a lower-level interface to the WADL document structure.","symbol":"WADLFile","correct":"from wadllib.wadl import WADLFile"}],"quickstart":{"code":"from wadllib.application import Application\nfrom io import BytesIO\n\n# A simple example WADL document as a string\nwadl_xml = \"\"\"\n<application xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://wadl.dev.java.net/2009/02\">\n  <resources base=\"http://example.com/api\">\n    <resource path=\"users\">\n      <method name=\"GET\">\n        <request/>\n        <response>\n          <representation mediaType=\"application/json\"/>\n        </response>\n      </method>\n      <method name=\"POST\">\n        <request>\n          <representation mediaType=\"application/json\"/>\n        </request>\n        <response>\n          <representation mediaType=\"application/json\"/>\n        </response>\n      </method>\n    </resource>\n    <resource path=\"products/{id}\">\n      <param name=\"id\" type=\"xsd:int\" style=\"template\" required=\"true\"/>\n      <method name=\"GET\">\n        <request/>\n        <response>\n          <representation mediaType=\"application/xml\"/>\n        </response>\n      </method>\n    </resource>\n  </resources>\n</application>\n\"\"\"\n\n# Load the WADL from a string (encoded to bytes)\napp = Application(wadl_xml.encode('utf-8'))\n\nprint(f\"API Base URL: {app.resources.base}\\n\")\n\nprint(\"Available Resources:\")\nfor uri in app.resources:\n    resource = app.resources[uri]\n    print(f\"- Path: {resource.path} (Full URI: {uri})\")\n    for method in resource.methods:\n        print(f\"  - Method: {method.name}\")\n        for response in method.responses:\n            for rep in response.representations:\n                print(f\"    - Responds with: {rep.mediaType}\")\n\n# Access a specific resource and its method\nusers_resource = app.resources.get('http://example.com/api/users')\nif users_resource:\n    get_users_method = users_resource.method_by_name('GET')\n    if get_users_method:\n        print(f\"\\nGET /users method details:\")\n        print(f\"  HTTP Verb: {get_users_method.name}\")\n        print(f\"  Request params: {get_users_method.request.params}\")\n","lang":"python","description":"This quickstart demonstrates how to load a WADL document from a string, navigate its resources and methods, and inspect their properties using the `wadllib.application.Application` object. It illustrates how to programmatically explore an API's structure as defined by WADL."},"warnings":[{"fix":"Update import statements from `from wadl import ...` to `from wadllib.application import ...` or `from wadllib.wadl import ...`.","message":"The import paths for core classes like `Application` and `WADLFile` changed significantly in version 2.0.0. Code written for `wadllib` 1.x will fail with `ImportError`.","severity":"breaking","affected_versions":"2.0.0+"},{"fix":"Ensure your project's Python interpreter is version 3.8 or higher. Upgrade your Python environment if necessary.","message":"Version 2.0.0 of `wadllib` dropped support for older Python versions, now requiring Python 3.8 or newer. Running on unsupported Python environments will lead to `SyntaxError` or runtime issues.","severity":"breaking","affected_versions":"2.0.0+"},{"fix":"Validate your WADL document against the official WADL schema. Ensure all elements and attributes conform to the specification to prevent parsing issues.","message":"wadllib strictly adheres to the WADL specification (2009/02). Malformed or non-compliant WADL files, even if partially readable by humans, may lead to parsing errors (`WADLError`) or unexpected behavior.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change the import statement to `from wadllib.application import Application`.","cause":"Attempting to import `Application` using the old import path from `wadllib` 1.x after upgrading to 2.x.","error":"ImportError: cannot import name 'Application' from 'wadl' (/path/to/wadl/__init__.py)"},{"fix":"Upgrade your Python environment to version 3.8 or newer to match the library's requirements. Alternatively, downgrade `wadllib` to a 1.x version if compatible with your Python version.","cause":"Running `wadllib` 2.0.0+ with an older Python version (e.g., Python 3.7 or earlier), which does not meet the `requires_python >=3.8` requirement.","error":"SyntaxError: invalid syntax (on a line of the library code itself)"},{"fix":"Ensure the XML document you are passing to `Application()` or `WADLFile()` is a well-formed WADL document, starting with the `<application>` root element and conforming to the WADL schema.","cause":"The provided XML string or file is not a valid WADL document, or its root element is not `<application>`.","error":"wadllib.exceptions.WADLError: Root element must be 'application'"}]}