Presuming that your root filesystem is ext4...
There are undelete tools you can use, but you must have turned off your machine immediately after discovering that the files had been deleted.
Linux is regularly writing logs and other files while it is running, and the way filesystems work, this means they will overwrite blocks which have been marked as "free" but contained the data that you want to restore.
If you DID turn your system off straight away, you could put your SD card in another Linux system and use the tools to scan the blocks to see if there are files that they recognise and can re-assemble. (all files larger than your block size will use multiple blocks, so finding the right chunks and putting them back together needs a bit of a miracle)
Depending on the tool you use, it is quite possible that the card should not be mounted in the system that you're doing the restoring on (because that could be writing to the card as well) - the recovery tools will scan the storage device block by block and possibly don't need to see the filesystem. Again, you don't want to write back to the card, so save restored files on a different device.
(unless the tool you use is just marking the blocks as "not free" and updating the inode table and existing directories.)
Even in the best-case scenario, expect to find that a number of your files are corrupted and can't be restored. The longer it was running before you stopped it (don't even shut it down, just pull the power immediately) the less data you will be able to get back.
extundelete and ext4magic are tools which may work for you.
I agree though, unless you had the only copy of some important data on that card, you're better off re-flashing it and starting from scratch. Don't trust the restored files to run off, undeleting is just to get back particular files to copy over to a different system before trashing and re-imaging the card.