So there is a getTiles() function that gets all the tiles of a world, but is there any way to getBlocks()?
no, because it would take an absurd amount of CPU time and memory. Find a better way to do whatever you're doing. getTiles() additionally only returns loaded tiles. Tiles are relatively uncommon and they have to be separately tracked anyway.
How is that supposed to help me? Well, I do not need all the blocks actually. Could you tell me how to get the nearby blocks of the server's spawn location. for() would help but I do not know how to use it.