Chapter 1 About

1.1 Book

This book offers some practical understanding on how to access the Twitter API with R. It assumes an Academic Research access but also some familiarity with R. If you are a student or an academic you can get more information on how to apply here. The book is based on the official Twitter documentation that you can access here. The code used in this book doesn’t rely on any ad-hoc package to access the Twitter API. This probably requries some more work on the user side but it also allows for more flexibility in defining and setting API queries and in responding to API changes. The code used in this book relies on three generalist packages

  1. The httr package (Wickham 2020) to deal with HTTP requests;

  2. The dplyr package (Wickham et al. 2021) to manipulate data objects in R; and

  3. The jsonlite package (Ooms 2022) to deal with JSON-formatted data objects.

This book is very much a working in progress. For suggestions, comments or if you note a mistake, please create an issue here.

1.1.1 Twitter relationships

In collecting Twitter data using the API, there are a number of entry points. Each node in the diagram indicate a possible entry point with arrows indicating the type of API requests necessary to crawl the graph.

Of course there are many other entry points. A good place to see a complete list is the official Twitter API endpoint map.

1.2 Author

Francesco Bailo is Lecturer of Digital and Social Media at the University of Technology Sydney, Australia. His research focuses on the use of digital and social media in politics. He obtained his PhD in 2017 at the University of Sydney, Australia.

References

Ooms, Jeroen. 2022. Jsonlite: A Simple and Robust JSON Parser and Generator for r. https://CRAN.R-project.org/package=jsonlite.
Wickham, Hadley. 2020. Httr: Tools for Working with URLs and HTTP. https://CRAN.R-project.org/package=httr.
Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2021. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.