Sleep apnea (SA) is a pervasive and highly prevalent sleep disorder identified by recurrent breathing-related problems such as respiratory pauses for almost 10 s (called apnea events) during sleep. It is a strongly underdiagnosed problem because the person suffering from this disease is not aware of this situation. It may cause serious health issues and badly affect the quality of life. Therefore, the diagnosis of sleep is crucial to cure disease. Polysomnography (PSG) is a golden technique for diagnosing sleep disorders. In this technique, multiple sensors are used to collect specific physiological signals such as electroencephalogram (EEG), electromyogram (EMG), electrooculogram (EOG), and many more. In regular clinical practice, medical experts need to manually analyze the signals of sleep hours which is a tedious process. Therefore, the automatic diagnosis tool is needed to simplify this process. Recently, many research groups have proposed deep learning models for the automatic diagnosis of SA using physiological signals with good accuracy. However, all these models require a large amount of annotated data in the supervised training process, which limits the use of those models in real-time scenarios. However, annotating a huge amount of biomedical signals is challenging and requires lots of time and domain expertise. This study proposes a self-supervised representation learning (SSRL) method for detecting hypopnea events from single-channel electrocardiography (ECG) signals. The proposed model is trained in two phases. In the first training phase, an encoder is trained to learn signal representation from the unlabeled data. In the second training phase, the classifier and the encoder are fine-tuned for the classification. Our proposed model performed well on the test dataset with a per-segment classification accuracy of 85%, 89%, and 92% using only 1%, 10%, and 100% of the training data with labels, respectively, for fine-tuning encoder along with the classifier. Also, our proposed model can identify a person suffering from the obstructive SA (OSA) with the accuracy of 100%, even when the encoder and classifier are fine-tuned using only 1% of the training data with the label. The proposed model outperformed the state-of-the-art techniques and can be implemented offline or online for rapid and accurate diagnosis of the problem.