You can deny certain groups the right to use the write API by denying them the writeapi right.
By default, all groups have the writeapi right.
However, both the writeapi right and $wgEnableWriteAPI = true; are required in order to use the write API.