A lot depends on where you intend to stay and if you intend to book ahead through a site like booking.com, (that will be pensions, hostals, casa rurals, and hotels depending on your budget) or stick to albergues. Albergues will require cash - and they are a lot cheaper. Other types of accommodation took credit cards, visa, most of the time.
I believe in a safety margin, so took cash, but used credit cards where we did stay in alternative accommodation. .That stretched our cash out. Food and drink were cash.
I bought the cash over some time, watching the exchange rates to get a good deal. Probably better rates than using ATM's - which we did infrequently.
I hope that helps.