{"id":111702,"date":"2018-06-27T12:21:00","date_gmt":"2018-06-27T17:21:00","guid":{"rendered":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/\/\/using-apis-to-collect-website-data\/"},"modified":"2024-04-14T04:10:45","modified_gmt":"2024-04-14T09:10:45","slug":"using-apis-to-collect-website-data","status":"publish","type":"decoded","link":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/2018\/06\/27\/using-apis-to-collect-website-data\/","title":{"rendered":"Using APIs to collect website data"},"content":{"rendered":"\n<figure class=\"wp-block-image size-640-wide\"><a rel=\"attachment wp-att-126078\" href=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/2013\/01\/using-apis-to-collect-website-data\/2018-06-27_decoded_featured-2-png\/\"><img data-dominant-color=\"e9efee\" data-has-transparency=\"false\" style=\"--dominant-color: #e9efee;\" loading=\"lazy\" decoding=\"async\"  srcset=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?resize=480,270 480w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?resize=782,440 782w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?resize=960,540 960w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?resize=1200,675 1200w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?resize=1400,788 1400w\" sizes=\"(max-width: 480px) 480px, (max-width: 782px) 782px, 640px\" height=\"360\" width=\"640\" src=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?w=640\" alt=\"\" class=\"wp-image-126078 not-transparent\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"7b6b\">Many researchers are interested in obtaining new kinds of data directly from websites. But collecting large amounts of data from a website can be impractical. When done manually, this approach is prone to human error. When automated, it may violate a website\u2019s terms of service.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"3901\">Instead, researchers typically rely on a tool called an API, which stands for Application Programming Interface. Web APIs provide a means of communication between websites and users, structured by rules. In particular, they allow users to obtain clearly defined kinds of data quickly, by requesting it directly from the database underlying a particular website. (This isn\u2019t the only kind of API. For example, smartphone apps frequently use APIs to send data back and forth between your device and the application\u2019s database. In this blog post, however, we\u2019re focusing on APIs that deliver data from websites to users.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"80a5\">Many major companies, as well as government agencies, have created public APIs. These organizations provide easy access to their data to encourage developers to use their platforms. At Pew Research Center, we regularly use APIs to collect information for the studies we produce. For example, we\u2019ve used APIs in reports about&nbsp;<a href=\"http:\/\/www.people-press.org\/2017\/02\/23\/partisan-conflict-and-congressional-outreach\/\" target=\"_blank\" rel=\"noreferrer noopener\">online congressional communication<\/a>,&nbsp;<a href=\"http:\/\/www.pewinternet.org\/2018\/04\/09\/bots-in-the-twittersphere\/\" target=\"_blank\" rel=\"noreferrer noopener\">bots in social media<\/a>,&nbsp;<a href=\"http:\/\/alpha.pewresearch.org\/pewresearch-org\/short-reads\/2018\/03\/16\/what-google-searches-can-tell-us-about-americans-interest-in-guns\/\" target=\"_blank\" rel=\"noreferrer noopener\">Google searches about guns<\/a>,&nbsp;<a href=\"http:\/\/www.pewinternet.org\/2018\/03\/21\/the-science-people-see-on-social-media\/\" target=\"_blank\" rel=\"noreferrer noopener\">science pages on Facebook<\/a>, and&nbsp;<a href=\"http:\/\/www.pewinternet.org\/2017\/11\/29\/public-comments-to-the-federal-communications-commission-about-net-neutrality-contain-many-inaccuracies-and-duplicates\/\" target=\"_blank\" rel=\"noreferrer noopener\">public comments on government policy<\/a>.<\/p>\n\n\n\n<h3 data-is-section=\"true\" data-wp-context=\"{&quot;id&quot;:&quot;9fc7&quot;}\" data-wp-interactive=\"{&quot;namespace&quot;:&quot;prc-block\\\/table-of-contents&quot;}\" class=\"wp-block-heading\" id=\"9fc7\">How APIs provide data<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"3e7a\">APIs provide data in various formats, but JSON is the most popular. JSON is a useful file format for structuring data because it preserves more hierarchical structure and meta information about a dataset than tab- or comma-separated files (such as .tsv and .csv files). Depending on the programming language you\u2019re using for your data analysis, there are libraries that make JSON data manipulation intuitive. For example, in the R statistical language, you can use the&nbsp;<code>jsonlite<\/code>&nbsp;library to transform data from APIs into familiar R objects and classes.<\/p>\n\n\n\n<h3 data-is-section=\"true\" data-wp-context=\"{&quot;id&quot;:&quot;e4f3&quot;}\" data-wp-interactive=\"{&quot;namespace&quot;:&quot;prc-block\\\/table-of-contents&quot;}\" class=\"wp-block-heading\" id=\"e4f3\">APIs can be used in different programming languages<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"936a\">In order to interact with an API efficiently across a variety of computer programs written in different languages (such as Java, Python, R, etc), researchers rely on API \u201cwrappers.\u201d These tools \u2014 which exist for most popular APIs \u2014 allow a researcher to request data directly from an API while using their own programming language of choice. Below, we use the World Bank\u2019s API as an example and access the data using R.<\/p>\n\n\n\n<h3 data-is-section=\"true\" data-wp-context=\"{&quot;id&quot;:&quot;ff98&quot;}\" data-wp-interactive=\"{&quot;namespace&quot;:&quot;prc-block\\\/table-of-contents&quot;}\" class=\"wp-block-heading\" id=\"ff98\">Example: How to interact with the World Bank\u2019s API<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"8217\">The&nbsp;<a href=\"https:\/\/datahelpdesk.worldbank.org\/knowledgebase\/articles\/889392-api-documentation\" rel=\"noreferrer noopener\" target=\"_blank\">World Bank API<\/a>&nbsp;gives researchers access to hundreds of variables about the health, wealth and culture of countries around the world. To show how to use this API, we can write a script to get a couple of variables and plot them. In this case, we\u2019ll search for variables using the identifying codes provided by the World Bank, and then pull the variables into memory in R.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"31ea\">The code below uses the&nbsp;<code>WDI<\/code>&nbsp;<a href=\"https:\/\/cran.r-project.org\/web\/packages\/WDI\/WDI.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">package<\/a>, an R package that includes a wrapper for the World Bank API. (A wrapper, as noted above, is a function or set of functions to execute calls to the API and convert the results into something more usable than what the API may return on its own.) To execute this code, you first have to install the&nbsp;<code>WDI<\/code>&nbsp;package, as well as&nbsp;<code><a href=\"https:\/\/cran.r-project.org\/web\/packages\/devtools\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">devtools<\/a><\/code>,<code><a href=\"https:\/\/cran.r-project.org\/web\/packages\/ggplot2\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">ggplot2<\/a><\/code>,&nbsp;<code><a href=\"https:\/\/www.ggplot2-exts.org\/gganimate.html\" target=\"_blank\" rel=\"noreferrer noopener\">gganimate<\/a><\/code>,&nbsp;<code><a href=\"https:\/\/cran.r-project.org\/web\/packages\/data.table\/\" target=\"_blank\" rel=\"noreferrer noopener\">data.table<\/a><\/code>, and&nbsp;<code><a href=\"https:\/\/cran.r-project.org\/web\/packages\/dplyr\/vignettes\/dplyr.html\" target=\"_blank\" rel=\"noreferrer noopener\">dplyr<\/a><\/code>. You can install these functions for R with the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>install.packages(c(\u201cWDI\u201d, \u201cggplot2\u201d, \u201cdevtools\u201d, \u201cdata.table\u201d, \u201cdplyr\u201d))\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We\u2019ll also install the gganimate add-on package for animation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>devtools::install_github(\u201cdgrtwo\/gganimate\u201d)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now that these packages are installed, let\u2019s load them into working memory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>library(WDI)\nlibrary(gganimate)\nlibrary(ggplot2)\nlibrary(data.table)\nlibrary(dplyr)\nlibrary(devtools)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"2166\">The&nbsp;<code>WDI<\/code>&nbsp;package provides a convenient way to search the World Bank API for variables that might be interesting for research. Below, we specify the word we want to search for after the \u201cstring\u201d field, and where to look for it \u2014 the \u201cname\u201d field. Doing so, we can see all the variables related to road infrastructure, immunization rates, and any other variables measured on a per capita basis.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#This code to search the API\nWDIsearch(string=\u201droads\u201d, field=\u201dname\u201d)\nWDIsearch(string=\u201dimmunization\u201d, field=\u201dname\u201d)\nWDIsearch(string=\u201dper capita\u201d, field=\u201dname\u201d)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The search returns lists of variables and their corresponding codes. Now that we know the codes for the variables we\u2019re interested in, we can call for the data from the API. We do this with the&nbsp;<code>WDI<\/code>&nbsp;function. Within this function call, we supply as arguments the countries we want (which is all of them), the variable codes, the first year of data, the last year of data, and an optional \u201cextra\u201d set of fields. The \u201cextra\u201d fields are country metadata \u2014 try turning this option off and on to see what happens.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Interesting Variables to plot\n# mortality per 1K women: SP.DYN.AMRT.FE\n# immunization rates of DPT: SH.IMM.IDPT\n# income per capita (constant): NY.ADJ.NNTY.PC.KD\n# population: SP.POP.TOTL\n# Getting the preliminary variables, using the code above\ndat&lt;-data.table(WDI(country=\u201dall\u201d, indicator=c(\u201cSP.DYN.AMRT.FE\u201d, \u201cSH.IMM.IDPT\u201d, \u201cNY.ADJ.NNTY.PC.KD\u201d, \u201cSP.POP.TOTL\u201d), start=1980, end=2017, extra=T))<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The data are loaded into memory as a&nbsp;<code>data.table<\/code>&nbsp;object, which is a type of rectangular data frame that\u2019s easy to interact with and analyze. One problem is that the variable names are not easy to interpret, so let\u2019s convert them to something more intuitive. We do this with the<code>dplyr<\/code>&nbsp;package, which provides a set of tools for manipulating data. It has a convenient and readable syntax. We will use the \u201crename\u201d command to rename the variables.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ndat = dat %&gt;%\n dplyr::rename(mortality = SP.DYN.AMRT.FE, immunization = SH.IMM.IDPT, \n<span style=\"background-color: initial\"> income_cap = NY.ADJ.NNTY.PC.KD, population = SP.POP.TOTL)<\/span>\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, let\u2019s remove the missing observations so we can plot the data. Of course, you should think carefully about which countries are missing and why.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ndat = na.omit(ndat)\nndat = ndat&#091;ndat$region!=\u201dAggregates\u201d, ]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-640-wide\"><a rel=\"attachment wp-att-126080\" href=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/2013\/01\/using-apis-to-collect-website-data\/image-png-20\/\"><img data-dominant-color=\"2e3336\" data-has-transparency=\"false\" style=\"--dominant-color: #2e3336;\" loading=\"lazy\" decoding=\"async\"  srcset=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/11\/image.png?resize=480,237 480w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/11\/image.png?resize=782,386 782w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/11\/image.png?resize=960,474 960w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/11\/image.png?resize=1010,499 1010w\" sizes=\"(max-width: 480px) 480px, (max-width: 782px) 782px, 640px\" height=\"316\" width=\"640\" src=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/11\/image.png?w=640\" alt=\"\" class=\"wp-image-126080 not-transparent\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"db7e\">We can create a visual representation of the relationship between income and immunization rates for a particular year. We\u2019ll plot one point for each country, sized by the log of the country\u2019s population. We\u2019ll plot a&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Local_regression\" rel=\"noreferrer noopener\" target=\"_blank\">LOESS<\/a>&nbsp;line of the general relationship, too.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"4984\">Here is a static plot using&nbsp;<code>ggplot2<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p &lt;- ggplot(filter(ndat, year==1980), aes(income_cap, immunization, size = log(population))) +\ngeom_point(aes(col=country), show.legend = FALSE) +\ngeom_smooth(aes(group = year), method = \u201cloess\u201d, show.legend = FALSE) + scale_x_log10()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a rel=\"attachment wp-att-126084\" href=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/2013\/01\/using-apis-to-collect-website-data\/image-1-png-13\/\"><img data-dominant-color=\"e2e3e4\" data-has-transparency=\"false\" style=\"--dominant-color: #e2e3e4;\" loading=\"lazy\" decoding=\"async\" width=\"573\" height=\"470\"  srcset=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/11\/image-1.png?resize=480,394 480w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/11\/image-1.png?resize=573,470 573w\" sizes=\"(max-width: 480px) 480px, (max-width: 782px) 782px, 640px\" src=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/11\/image-1.png\" alt=\"\" class=\"wp-image-126084 not-transparent\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"6083\">Finally, we\u2019ll create an animation of the same relationship over time. To do so, first install&nbsp;<code><a href=\"https:\/\/www.imagemagick.org\/script\/install-source.php\" target=\"_blank\" rel=\"noreferrer noopener\">ImageMagick<\/a><\/code>. Then create a plot that includes all the years in the data:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p &lt;- ggplot(ndat, aes(income_cap, immunization, size = log(population), frame = year)) +\n geom_point(aes(col=country), show.legend = FALSE) + \n geom_smooth(aes(group = year), method = \u201cloess\u201d, show.legend = FALSE) + scale_x_log10()\ngganimate(p)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-640-wide\"><a rel=\"attachment wp-att-126091\" href=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/2013\/01\/using-apis-to-collect-website-data\/0_xa51wayrzbqswt2m-gif\/\"><img data-dominant-color=\"e4e5e5\" data-has-transparency=\"false\" style=\"--dominant-color: #e4e5e5;\" loading=\"lazy\" decoding=\"async\"  srcset=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/12\/0_XA51waYrzBqSWt2M.gif?resize=480,480 480w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/12\/0_XA51waYrzBqSWt2M.gif?resize=782,782 782w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/12\/0_XA51waYrzBqSWt2M.gif?resize=800,800 800w\" sizes=\"(max-width: 480px) 480px, (max-width: 782px) 782px, 640px\" height=\"640\" width=\"640\" src=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/12\/0_XA51waYrzBqSWt2M.gif?w=640\" alt=\"\" class=\"wp-image-126091 not-transparent\" \/><\/a><\/figure>\n\n\n\n<h3 data-is-section=\"true\" data-wp-context=\"{&quot;id&quot;:&quot;188b&quot;}\" data-wp-interactive=\"{&quot;namespace&quot;:&quot;prc-block\\\/table-of-contents&quot;}\" class=\"wp-block-heading\" id=\"188b\">Some useful APIs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"9315\">In addition to the World Bank\u2019s API, here are some others that we\u2019ve interacted with and found useful:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.twitter.com\/en\/docs\/tweets\/search\/overview.html\" rel=\"noreferrer noopener\" target=\"_blank\">Twitter<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/projects.propublica.org\/api-docs\/congress-api\/\" rel=\"noreferrer noopener\" target=\"_blank\">ProPublica Congress<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/datahelpdesk.worldbank.org\/knowledgebase\/articles\/889392-api-documentation\">World Bank<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/developers.facebook.com\/docs\/graph-api\/\" rel=\"noreferrer noopener\" target=\"_blank\">Facebook<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.census.gov\/developers\/\" rel=\"noreferrer noopener\" target=\"_blank\">U.S. Census Bureau<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/developer.oxforddictionaries.com\/\" rel=\"noreferrer noopener\" target=\"_blank\">Oxford Dictionaries API<\/a><\/li>\n\n\n\n<li><a href=\"http:\/\/data.un.org\/Host.aspx?Content=API\" rel=\"noreferrer noopener\" target=\"_blank\">United Nations Data<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"8908\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>At Pew Research Center, we regularly use APIs to collect information for the studies we produce. Web APIs provide a means of communication between websites and users, structured by rules. <\/p>\n","protected":false},"author":377,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"sub_headline":"","sub_title":"","_prc_public_revisions":[],"_ppp_expiration_hours":0,"_ppp_enabled":false,"ai_generated_summary":"","relatedPosts":[],"_prc_fork_parent":0,"_prc_fork_status":"","_prc_active_fork":0,"datacite_doi":"","datacite_doi_citation":"","_prc_seo_qr_attachment_id":0,"spoken_article_player_enabled":true,"displayBylines":true,"footnotes":"","prc_watchers":[]},"categories":[353],"bylines":[936,819,931],"collection":[],"_post_visibility":[],"decoded-category":[531,530],"formats":[],"_fund_pool":[],"languages":[],"regions-countries":[],"research-teams":[524],"workflow-status":[],"class_list":["post-111702","decoded","type-decoded","status-publish","hentry","category-data-science","bylines-adam-hughes","bylines-onyi-lam","bylines-stefan-wojcik","decoded-category-coding-how-to","decoded-category-data-science","research-teams-decoded"],"label":"Decoded","post_parent":0,"word_count":1221,"canonical_url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/2018\/06\/27\/using-apis-to-collect-website-data\/","art_direction":{"A1":{"id":126078,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?w=564&h=317&crop=1","width":564,"height":317,"caption":"","chartArt":false},"A2":{"id":126078,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?w=268&h=151&crop=1","width":268,"height":151,"caption":"","chartArt":false},"A3":{"id":126078,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?w=194&h=110&crop=1","width":194,"height":110,"caption":"","chartArt":false},"A4":{"id":126078,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?w=268&h=151&crop=1","width":268,"height":151,"caption":"","chartArt":false},"XL":{"id":126078,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?w=720&h=405&crop=1","width":720,"height":405,"caption":"","chartArt":false},"social":{"id":126078,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2018.06.27_decoded_featured-2.png?w=1200&h=628&crop=1","width":1200,"height":628,"caption":"","chartArt":false}},"_embeds":[],"watchers":[],"table_of_contents":[],"datacite_doi":"","prc_seo_data":{"title":"Using APIs to collect website data","description":"At Pew Research Center, we regularly use APIs to collect information for the studies we produce. Web APIs provide a means of communication between websites and users, structured by rules. ","og_title":"Using APIs to collect website data","og_description":"At Pew Research Center, we regularly use APIs to collect information for the studies we produce. Web APIs provide a means of communication between websites and users, structured by rules. ","schema_type":"Article","noindex":false,"canonical_url":"","primary_terms":{"category":1},"custom_schema":[],"og_image":126078,"indexnow_submitted_at":null,"gsc_index_status":null},"prepublish_checks":{},"jetpack_sharing_enabled":true,"relatedPostsOrdered":[],"bylinesOrdered":[{"key":"_ysyoy7kaw","termId":819},{"key":"_8ydcl318c","termId":936},{"key":"_9i588fc2r","termId":931}],"acknowledgementsOrdered":[],"_links":{"self":[{"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/decoded\/111702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/decoded"}],"about":[{"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/types\/decoded"}],"author":[{"embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/users\/377"}],"replies":[{"embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/comments?post=111702"}],"version-history":[{"count":2,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/decoded\/111702\/revisions"}],"predecessor-version":[{"id":138554,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/decoded\/111702\/revisions\/138554"}],"wp:attachment":[{"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/media?parent=111702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/categories?post=111702"},{"taxonomy":"bylines","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/bylines?post=111702"},{"taxonomy":"collection","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/collection?post=111702"},{"taxonomy":"_post_visibility","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/_post_visibility?post=111702"},{"taxonomy":"decoded-category","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/decoded-category?post=111702"},{"taxonomy":"formats","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/formats?post=111702"},{"taxonomy":"_fund_pool","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/_fund_pool?post=111702"},{"taxonomy":"languages","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/languages?post=111702"},{"taxonomy":"regions-countries","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/regions-countries?post=111702"},{"taxonomy":"research-teams","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/research-teams?post=111702"},{"taxonomy":"workflow-status","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/workflow-status?post=111702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}