i am trying to automate the download of a bit of data from the API of this government website.
the website instructs:
All requests for this version should be made to the following URL:
http://api.finder.healthcare.gov/v2.0/
i can find plenty of information about how to send xml requests, but none of the examples are R
-specific.. and there's plenty of R code out there that shows how to use the XML
, httr
, and RCurl
packages, but i couldn't find any examples on SO or the r-help mailing list of how to actually send an xml request. ..there's more documentation for parsing the response.
on the government website, if you click the PlansForIndividualOrFamily Samples
example, it displays the xml request (code below) that needs to be sent.
url <- "http://api.finder.healthcare.gov/v2.0/"
xml.request <-
"<?xml version='1.0' encoding='UTF-8'?>
<PrivateOptionsAPIRequest>
<PlansForIndividualOrFamilyRequest>
<Enrollees>
<Primary>
<DateOfBirth>1990-01-01</DateOfBirth>
<Gender>Male</Gender>
<TobaccoUser>Smoker</TobaccoUser>
</Primary>
</Enrollees>
<Location>
<ZipCode>69201</ZipCode>
<County>
<CountyName>CHERRY</CountyName>
<StateCode>NE</StateCode>
</County>
</Location>
<InsuranceEffectiveDate>2012-10-01</InsuranceEffectiveDate>
<IsFilterAnalysisRequiredIndicator>false</IsFilterAnalysisRequiredIndicator>
<PaginationInformation>
<PageNumber>1</PageNumber>
<PageSize>10</PageSize>
</PaginationInformation>
<SortOrder>
<SortField>OOP LIMIT - INDIVIDUAL - IN NETWORK</SortField>
<SortDirection>ASC</SortDirection>
</SortOrder>
<Filter/>
</PlansForIndividualOrFamilyRequest>
</PrivateOptionsAPIRequest>"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…