Affine gravity and the Palatini formalism contribute both to produce a simple and unique formula for calculating charges at spatial and null infinity for Lovelock type Lagrangians whose variational derivatives do not depend on second-order derivatives of the field components. The method is based on the covariant generalization due to Julia and Silva of the Regge-Teitelboim procedure that was used to define properly the mass in the classical formulation of Einstein's theory of gravity. Numerous applications reproduce standard results obtained by other secure but mostly specialized method like in ADM energy for asymptotically flat spacetimes and in Abbot and Deser for asymptotically de Sitter and anti-de Sitter spacetimes, both at spatial infinity. As a novel application we calculate the Bondi energy loss in five dimensional gravity, based on the asymptotic solution given by Tanabe et al. and obtain, as expected, the same result. We also give the superpotential for Einstein-Gauss-Bonnet gravity and find the superpotential for Lovelock theories of gravity when the number of dimensions tends to infinity with maximally symmetrical boundaries. The paper is written in standard component formalism.