How to extract tweets from a country

I am trying to extract tweets from a particular country but I see the tweets returned seem to be from all over. here is my code:

  # fetch tweets from Nigeria using the keywords covid-19 and coronavirus
  covid_tweets <- searchTwitter( c('covid-19', 'coronavirus'), 
                               'en', 
                               lookup_coords("nigeria"))

lookup_coords will use google geocoding API if the location is not already included in the package. See ?rtweet::lookup_coords
You must have an API KEY and enable billing on GCP.
See

and

See the doc about Geocoding API

I think this is why you don't get what you want.

Is lookup_coords("nigeria") resulting with a list containing coordinates ?
If none, then the API does not return anything I thing...
You can check also the result of

jsonlite::fromJSON(glue::glue("https://maps.googleapis.com/maps/api/geocode/json?key={key}&address=nigeria", key = Sys.getenv("GOOGLE_MAPS_KEY")))

Hope it helps

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

thanks @cderv. I still struggled with it so I just went ahead to do a live stream of tweets that contain the word 'Nigeria'