We can do using the Postman tool - here are the steps:
Please follow the below steps:
Step 1: - Register Add-In – SharePoint online:
- Client Id – will get it from the SharePoint online page.
https://YourSharePointOnlineSiteUrl/_layouts/15/appregnew.aspx
Step 2: Grant Permissions to Add-In – SharePoint online:
- Client Secret – will get it from the SharePoint online page.
https://YourSharePointOnlineSiteUrl/_layouts/15/appinv.aspx
Step 3: Generate Realm and Access Token from Postman (refer to the below supporting article).
- Realm (Tenant Id) – will get it from the postman tool
- Access Token – will get it from the postman tool
Step 4: REST API "GET" successful operation (refer to the below supporting article)
Using the above Client Id, Client Secret,Realm (Tenant Id) and Access Token from the postman tool, perform a sample "GET" REST API query from the SharePoint online list.
Step 5: GENERATE CODE SNIPPETS (refer to the below supporting article)
On the successful GET operation result, go to the GENERATE CODE SNIPPETS option, there, we can generate code snippets in almost all popular languages, like C#, C, Java, PowerShell, etc.
Generate the code in C# language, then plugin (use that) that code into your actual project code file.

For the details steps, refer to the below article:
In 4 steps access SharePoint online data using postman tool