Hello is there any function available from which we can retrieve 12 char name by giving private key ? or you can say api function or eos library for import eos account
First of all: Never publish your private key, don't make it public, don't paste it to any api's or so, the only place to paste it is your wallet.
Assuming you are speaking about the public key of a specific account, there's the get_accounts_by_authorizers-endpoint provided by the chain-api.
Note that it's only available if
enable-account-queries is set to true in your nodeos-config.