A crankshaft is a part in a reciprocating engine that rotates due to the reciprocating motion of the pistons. However in a pump, the crankshaft's motion causes the piston to move back and forth. The crankshaft is connected to the pistons by "crankpins" which have an offset axis allowing this conversion of motion to be accomplished, and can be viewed in Figure 1. Since the common four-stroke cycle (Figure 2) of the reciprocating engine isn't continuous, the crankshaft is often connected to a flywheel which is used to store rotational energy in order to reduce the pulsation or choppiness of the pistons.
Figure 1: The crankshaft (red) converts reciprocating motion from the pistons (grey) which is often combined with a flywheel (black).
Figure 2: 4-stroke internal combustion engine. 1:fuel injection, 2:ignition, 3:expansion(work is done), 4:exhaust.