We propose a generalization of the existing maximum entropy models used for spike trains statistics analysis. We bring a simple method to estimate Gibbs distributions, generalizing existing approaches based on Ising model or one step Markov chains to arbitrary parametric potentials. Our method enables one to take into account memory effects in dynamics. It provides directly the Kullback-Leibler divergence between the empirical statistics and the statistical model. It does not assume a specific Gibbs potential form and does not require the assumption of detailed balance. Furthermore, it enables the comparison of different statistical models and offers a control of finite-size sampling effects, inherent to empirical statistics, by using large deviations results. A numerical validation of the method is proposed. Applications to biological data of multi-electrode recordings from retina ganglion cells in animals are presented. Additionally, our formalism permits to study the evolution of the distribution of spikes caused by the variation of synaptic weights induced by synaptic plasticity. We provide an application to the analysis of synthetic data from a simulated neural network under Spiketime Dependent Plasticity STDP.