If you did backup the data on your iPhone 5 you can retrieve it from iTunes or iCloud backup. Here are detailed steps you can follow:
1. Recover iPhone data from iTunes backup
(1) Connect the iPhone to the computer with a USB cable.
(2) Open iTunes.
(3) If you have a new or erased iPhone, iTunes will prompt you to restore from backup.
(4) Otherwise, Control-click on your iPhone under DEVICES in the left menu.
(5) Select Restore From Backup...
(6) Choose the backup you wish to sync and click the Restore button.
2. Recover lost iPhone data from iCloud backup
(1) Make sure your iPhone is connected to Wi-Fi and plugged into the charger.
(2) Select the option Restore From iCloud Backup.
(3) Enter your iCloud account and password.
(4) Choose the recent backup you wish to restore to your iPhone.
(5) Enter any passwords required when prompted.
Also you can use a third-party tool like iPhone Data Recovery to recover the data.