@mahsanamin thanks for your question.
We have an example script that demonstrates how to do this in Python available here.
In that script, we pull all line items and all promoted tweets for an account using with_deleted=true. In your case, since you know the campaign IDs, you could also use the parameter campaign_ids=XXXX,XXXX,XXXX to grab just the line items you are concerned about.
twurl -H ads-api.twitter.com "/0/accounts/XXXXX/line_items?with_deleted=true&campaign_ids=XXXXX,XXXXX,XXXX"
Then before making any stats calls, you can follow the behavior of best practices example and filter out any line items or promoted tweets that couldn’t have any data for your specified time window.
Never pull real-time data older than 7 days, and as a reminder:
- All analytics metrics are locked and will not change after 24 hours, with the exception of billed_charge_local_micro.
- The billed_charge_local_micro metric is an estimate for up to 3 days after the data is returned.
- After 24 hours, this metric can decrease due to credits for overspend (ads served after the given end_time) and for billable events that are determined to be junk. This metric changes minimally after 24 hours.
Related documentation:
https://dev.twitter.com/ads/analytics/best-practices