Disclosed is a wheel hub for an electric bicycle, the wheel hub comprising a main shaft, a wheel hub housing, and a flywheel, and an electric motor, a battery and a controller arranged inside the wheel hub housing, wherein an inner wall of the wheel hub housing adjacent to the flywheel is provided with a sensing switch, the sensing switch and the controller are electrically connected to each other and are fixed on the inner wall of the wheel hub housing to rotate around the main shaft, a sensing head of the sensing switch passes through the inner wall of the wheel hub housing to point to the flywheel, the sensing switch can detect whether the flywheel rotates, and the controller is electrically connected to the battery. The present invention has a simple structure. According to a signal transmitted by the sensing switch, the controller controls the electric motor to turn same off and on: in a gliding state, the sensing switch senses that the flywheel rotates relative to the wheel hub housing and sends an electrical signal to the controller, then the controller controls the electric motor to turn off same, so that the electric motor is not in operation; and in a pedalling state, the flywheel does not rotate relative to the wheel hub housing, the sensing switch does not send the electrical signal, the controller controls the electric motor to turn on same to operate, so as to realise power assisting, and the risk of a rapid increase in rotation speed is effectively prevented.