I am building a python script that gets a string and determines if it is a valid bitcoin private key or public key, and if so it returns its type/format (base58, BIP32, HexaDecimal etc.) and its derivations (public key from private key and address from public key).

Is there any free library that I can use its code inside mine, to get those details?

I have tried to do so myself but there are a lot of formats of keys and mathematical computations for validation and derivation the keys. Thank you.

2 Answers 2


No sane application should EVER attempt to validate a private key by attempting to pass it to an external API. That's a ridiculously easy way to lose all your funds if the API operator is malicious, compromised, or someone is eavesdropping on your communication with said API.

You should do this yourself, preferably using a well tested, community supported, open source library for your choice of language - most major languages have such libraries.

If this is too much work, you should reconsider building something like this. Do not compromise on safety, especially if you intend for other people to trust this code with their funds.

  • I now see that I did not explained myself correctly. I meant that I need a library and not API (a code that I can download from github or somewhere else and use it in my code without copyrights issues). I will edit my question accordingly. thank you @Raghav Sood
    – Avi El
    Aug 2, 2020 at 8:21

See if this library will suit you https://github.com/bitaps-com/pybtc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.