How to extract Facebook and instagram updates or trends

Are there API’s or interface to extract Facebook and instagram data like we extract twitter data?

There is an R package called ‘Rfacebook’, so technically possible by using Custom R Script Data Source.