With the increasing development of intelligent detection devices, a vast amount of traffic flow data can be collected from intelligent transportation systems. However, these data often encounter issues such as missing and abnormal values, which can adversely affect the accuracy of future tasks like traffic flow forecasting. To address this problem, this paper proposes the Attention-based Spatiotemporal Generative Adversarial Imputation Network (ASTGAIN) model, comprising a generator and a discriminator, to conduct traffic volume imputation. The generator incorporates an information fuse module, a spatial attention mechanism, a causal inference module, and a temporal attention mechanism, enabling it to capture historical information and extract spatiotemporal relationships from the traffic flow data. The discriminator features a Bidirectional Gated Recurrent Unit (BiGRU), which explores the temporal correlation of the imputed data to distinguish between imputed and original values. Additionally, we have devised an imputation filling technique that fully leverages the imputed data to enhance the imputation performance. Comparison experiments with several traditional imputation models demonstrate the superior performance of the ASTGAIN model across diverse missing scenarios.