rough version with partially working api