@Kommu, Ramesh Greetings!
The discrepancy between the Azure portal and the API cost data at different times of the day is most likely due to the asynchronous processing of billing and usage data. Azure Cost Management typically reconciles and finalizes costs throughout the day, which can lead to slight changes in the cost figures displayed on the portal after you fetch them from the API. This is a common situation, the current open month cost data is always an approximate and it is advisable customer makes t-3 days to access the cost data then it would be more stable as compared to checking just previous days data.
Hope this answers your question. Please feel free to reply if you have any further questions.
If the response helped, do "Accept Answer" and up-vote it