APY
APY or annual percentage yield is used to describe the result of the money you've invested in any number of products. APY only takes into account how much you get in return for your money in a given percentage. Annual percentage yield is usually used when banks offer savings or invesment accounts to attract investors with the high return. The total interest/percentage for a given period is calulated when calculating the APY, it takes into account the frequency the percentage is applied which gives a more exact number, and it is always based off of the original value when giving the percentage return.
The formula for calculating the annual yield is:

APR
APR or annual percentage return is often used to describe the total percentage you'll have to pay over the orignal value in any loan you have taken. This is most common found with credit companies and banks offering loans, this is highly due to the fact that APR doesn't give an exact percentage, but a rounded down return rate based on the number of periods. The most common way to find the APR is to simply take the interest and multiply it by the periods at which it is applied or a customer has to pay. This usually ends up shaving off a few decimals and making the number seem less than it is. APR can also be called "nominal interest" in some countries and APY be "effective interest".
The formula for finding the annual percentage return is:

Which is best
The million dollar question, which is better? APR or APY? Well that depends on what the money you are using or getting is focused on.
When borrowing money the lower the actual percentage the better. If a credit card charges 12% as interest APR, you'll actually be paying 12.68% over the period of a year as opposed to 12% if you pay it off immediately. This is slightly higher than if the percentage you would have gotten would've been an APY, then it would've been 12%. However if you do pay off the loan or charge with a smaller number of payments the percentage will be lower and closer to 12% The opposite is true if you are looking to invest or open a savings account, seeing a high APR being more lucrative. APY takes into account the compounding interest whereas APR doesn't. Companies and banks generally have to inform the customers of the APR; not the APY, and if the APR is given on a monthly basis it sounds alot better than it actually is.
When chosing a saving or invesment period, the actual times the percentage will be applied, more periods is better, if you're borrowing money however the fewer periods the better. For example a annual APY of 5% would be 5,06% and quaretly APY would be 5,09% and lastly monthly APY would be 5,11%. This change in return might seems small but they add up, especially over longer periods of time or with a higher percentage. For example annual APY for 9% would be 9,20%, quarterly APY of 9% would be 9,30% and the monthly yield for 9% would be 9,38%. That half percent could be the difference of several thousands dollars depending on how much you're investing and saving, so every bit counts if you want to make the most out of your money. Some companies doesn't even offer APY but a straight APR, meaning they can use the compounding interest to get extra money to line their pockets while you are stuck with a lesser return rate.
The bottom line for which is best depends on what you want to use the money for. If the money is for a product or thing, APR would be better for you, especially if the amount of periods can be decreased. If the money is used for you or to be used in the future, APY is the way to go with a preferred higher number of periods applied to your investment.