{"library":"sdmx1","title":"SDMX: Statistical Data and Metadata eXchange","description":"sdmx1 is a Python library for consuming and working with Statistical Data and Metadata eXchange (SDMX) web services and files. It supports various SDMX versions and data formats, allowing users to query, download, and parse statistical data from official sources like Eurostat, IMF, and OECD. The library is actively maintained with frequent minor releases, currently at version 2.26.0, and requires Python >=3.10.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install sdmx1","pip install sdmx1[cache]"],"cli":null},"imports":["import sdmx\nreq = sdmx.Request('ESTAT')","import sdmx\nwith open('data.xml', 'rb') as f:\n    msg = sdmx.read_sdmx(f)"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import sdmx\nimport os\n\n# Example agency ID; replace with a real one like 'ESTAT' (Eurostat), 'IMF', 'OECD'\n# Some agencies may require specific authentication or have strict rate limits.\nagency_id = os.environ.get('SDMX_AGENCY_ID', 'IMF') # Using IMF as a common example\n\ntry:\n    # Create a Request object for the specified agency\n    req = sdmx.Request(agency_id)\n\n    print(f\"Attempting to connect to SDMX agency: {agency_id}\")\n\n    # Fetch available dataflows\n    # This performs an HTTP GET request to the agency's API endpoint\n    dataflows = req.dataflow()\n\n    print(f\"Successfully retrieved dataflows from {agency_id}.\")\n    print(f\"First 3 dataflows from {agency_id} (ID: Name):\")\n    if dataflows.data.dataflow:\n        for i, flow in enumerate(dataflows.data.dataflow[:3]):\n            print(f\"  - {flow.id}: {flow.name.get('en', 'No English name')}\")\n    else:\n        print(\"  No dataflows found.\")\n\n    # To fetch actual data, you would then use a specific dataflow ID and keys.\n    # Example (commented out, as specific dataflow IDs and keys vary greatly):\n    # # For IMF, using International Financial Statistics (IFS) dataflow, if available\n    # if agency_id == 'IMF':\n    #     print(\"\\nAttempting to fetch data from IMF (example).\")\n    #     data = req.get_data(\n    #         resource_id='IFS',\n    #         key={'REF_AREA': ['US', 'CN'], 'INDICATOR': ['LP_CPI_IX']},\n    #         params={'startPeriod': '2020', 'endPeriod': '2022'}\n    #     )\n    #     print(f\"Fetched {len(data.series)} series from IFS.\")\n\nexcept sdmx.api.APIError as e:\n    print(f\"Error connecting to or fetching data from {agency_id}: {e}\")\n    print(\"Possible causes: invalid agency ID, network issues, API rate limits, or specific API endpoint errors.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"Demonstrates how to connect to an SDMX agency (e.g., IMF) using `sdmx.Request`, list available dataflows, and print basic information. It includes error handling for common API issues. The example for fetching specific data is commented out as it requires specific knowledge of an agency's data structure.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}