API merged with csv code