tweaks to make api write to database immediately, updated example to show API usage