If you've entered your API key and it continues to come back invalid, make sure that you have verified that it is your correct key in it's entirety.
If that still doesn't work, make sure that your Torn ID (The number found at the top of the settings page) matches your Torn ID in game. If these numbers do not match, you won't be able to validate your API key. You must either delete your account and register again with the correct ID or contact a staff member on Torn Stats'
Discord to help recover the account already using your ID.