APIs for social scientists: A collaborative review: различия между версиями

Материал из Поле цифровой дидактики
()
Строка 77: Строка 77:
== ==
== ==


== ==
== Reddit API ==
https://bookdown.org/paul/apis_for_social_scientists/reddit-api.html
; https://www.reddit.com/dev/api/
: https://bookdown.org/paul/apis_for_social_scientists/reddit-api.html

Версия 20:59, 26 сентября 2023



Описание книги В книге представлено множество 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

Reddit API

https://www.reddit.com/dev/api/
https://bookdown.org/paul/apis_for_social_scientists/reddit-api.html