APIs for social scientists: A collaborative review

Материал из Поле цифровой дидактики



Описание книги В книге представлено множество API социальных сетей и основы их использования. В статье по этой книге собраны примеры API и особенности работы с ними. Код а книге - R
Область знаний NetSci, Информатика, Образование
Год издания 2022
Веб-сайт где можно прочитать книгу или статью https://bookdown.org/paul/apis for social scientists/
Видео запись
Авторы
Среды и средства, на которые повлияла книга R, RStudio, API


Лучшие практики

Например,
First, the Developer Agreement and Policy provide information on what you can and cannot do with the data obtained through the API. It is important for both Open Science practices (e.g. sharing data publicly) and sharing data between individuals within the research group. Please make sure you understand the data redistribution policy. The API provided by Twitter, for example, forbids the redistribution of Twitter Content to third parties. However, academic researchers are permitted to distribute an unlimited number of Tweet IDs and/or User IDs for peer review purposes.

API Meta Ad Library (FaceBook)

 
# install.packages('pacman')
library(pacman)
p_load('httr', 'remotes', 'dplyr',
'ggplot2', 'tidyr', 'Radlibrary', 'dplyr', 'tidyr', 'DT')

GitHub.com API

The GitHub.com API provides a service for interacting with the social coding platform GitHub. A social coding platform is a website that allows users to work on software projects collaboratively. Users can share their work, engage in discussions and track activities of other users and projects. GitHub is currently the largest such platform with more than 50M user accounts (as of January 2022). GitHub’s API allows for retrieving user-generated data from its platform, which is probably of main interest for social scientists. It also provides tools for controlling your account, organizations and projects on the platform in order to automate workflows. This is more of interest for professional software development.

https://docs.github.com/en/rest/guides/getting-started-with-the-rest-api?apiVersion=2022-11-28
This article describes how to use the GitHub REST API using GitHub CLI, JavaScript, or curl.

 
# install.packages('pacman')
library(pacman)
p_load('jsonlite', 'httr')

Google Translation API

To access and to use the API the following steps are necessary:

  • Create a google account (if you do not already have one).
  • Using this google account login to the google cloud platform and create a Google Cloud Project.
  • Within this Google Cloud Project enable the Google Translation API.
  • For authentication you will need to create an API key (which you additionally should restrict to the Translation API).

GoogleTrends API

It can be used without an API key by anyone for free directly in the internet browser

Internet Archive API

 
# Load required packages
library(httr)
library(jsonlite)
library(tibble)

# API call
res <- GET("http://web.archive.org/cdx/search/cdx?", query = list(
  url = "nytimes.com",         
  matchType = "url",
  from = "20191201",
  to = "20191202",
  collapse = "timestamp:8",
  output = "json"
         ))

# Translate json output to tibble
result <- httr::content(res, type = "text")
result <- fromJSON(result)
result <- as_tibble(result)
names(result) <- result[1,]
result <- result[-1,]

result

The API is free and accessible without any authentification via HTTP Urls, httr and the archiveRetriever - https://github.com/liserman/archiveRetriever

Twitter API

The API is provided by Twitter. As of 2021, there are 5 different tracks of API: Standard (v1.1), Premium (v1.1), Essential (v2), Elevated (v2), and Academic Research (v2). They offer different data as well as cost differently. For academic research, one should use Standard (v1.1) or Academic Research (v2).

MediaWiki Action API

No pre-registration is required to access the API. However, for certain actions, such as very large queries, a registration is required.

Пример wikipedia https://en.wikipedia.org/w/api.php?action=query&format=json&prop=info&titles=Albert%20Einstein
{"batchcomplete":"","query":{"pages":{"736":{"pageid":736,"ns":0,"title":"Albert Einstein","contentmodel":"wikitext","pagelanguage":"en","pagelanguagehtmlcode":"en","pagelanguagedir":"ltr","touched":"2023-09-26T08:29:20Z","lastrevid":1176888903,"length":234485}}}}
http://digida.mgpu.ru/api.php?action=query&format=json&prop=info&titles=Papert
"batchcomplete":"","query":{"pages":{"1021":{"pageid":1021,"ns":0,"title":"Papert","contentmodel":"wikitext","pagelanguage":"ru","pagelanguagehtmlcode":"ru","pagelanguagedir":"ltr","touched":"2023-09-16T07:04:48Z","lastrevid":3105,"length":800}}}}

Youtube API

An overview and guide is given on the YouTube Api website. First, you will need a Google account which you will use to log into the Google Cloud Platform. You will need to create a new project unless you already have one

Reddit API

https://www.reddit.com/dev/api/
https://bookdown.org/paul/apis_for_social_scientists/reddit-api.html
When the API was created it required users to have a Reddit account and use OAuth2 authentication.

Вне книги

discourse


Scratch API

https://en.scratch-wiki.info/wiki/Scratch_API
Как использовать Scratch API