import inspect def get_api_info(api): try: # Split the API string into module and function parts module_parts = api.split('.') function_name = module_parts.pop() module_name = '.'.join(module_parts) # Dynamically import the module module = __import__(module_name, fromlist=[function_name]) # Get the function or class from the module api_object = getattr(module, function_name) # Get the signature signature = inspect.signature(api_object) # Get the docstring docstring = inspect.getdoc(api_object) return { 'name': api, 'signature': str(signature), 'docstring': docstring } except ImportError: return {'name': api, 'error': 'Module not found'} except AttributeError: return {'name': api, 'error': 'Function or class not found in module'} except Exception as e: return {'name': api, 'error': str(e)}