Here I’ll show some examples to use this package
service <- ODataQuery$new("https://services.odata.org/V4/TripPinServiceRW")
service$all()
#> name kind
#> 1 Photos EntitySet
#> 2 People EntitySet
#> 3 Airlines EntitySet
#> 4 Airports EntitySet
#> 5 Me Singleton
#> 6 GetNearestAirport FunctionImport
#> url
#> 1 http://services.odata.org/V4/(S(5nc4yxfk4uf0zsocmrcuuq1j))/TripPinServiceRW/Photos
#> 2 http://services.odata.org/V4/(S(5nc4yxfk4uf0zsocmrcuuq1j))/TripPinServiceRW/People
#> 3 http://services.odata.org/V4/(S(5nc4yxfk4uf0zsocmrcuuq1j))/TripPinServiceRW/Airlines
#> 4 http://services.odata.org/V4/(S(5nc4yxfk4uf0zsocmrcuuq1j))/TripPinServiceRW/Airports
#> 5 http://services.odata.org/V4/(S(5nc4yxfk4uf0zsocmrcuuq1j))/TripPinServiceRW/Me
#> 6 http://services.odata.org/V4/(S(5nc4yxfk4uf0zsocmrcuuq1j))/TripPinServiceRW/GetNearestAirport
people_entity <- service$path("People")
# Get first page
people_entity$retrieve(count=TRUE)
#> $`@odata.count`
#> [1] 20
#>
#> $`@odata.nextLink`
#> [1] "https://services.odata.org/V4/(S(j0yfx2ikz4gvkb3ufawsoaiz))/TripPinServiceRW/People?%24count=true&%24skiptoken=8"
#>
#> $value
#> UserName FirstName LastName Emails
#> 1 russellwhyte Russell Whyte [email protected], [email protected]
#> 2 scottketchum Scott Ketchum [email protected]
#> 3 ronaldmundy Ronald Mundy [email protected], [email protected]
#> 4 javieralfred Javier Alfred [email protected], [email protected]
#> 5 willieashmore Willie Ashmore [email protected], [email protected]
#> 6 vincentcalabrese Vincent Calabrese [email protected], [email protected]
#> 7 clydeguess Clyde Guess [email protected]
#> 8 keithpinckney Keith Pinckney [email protected], [email protected]
#> AddressInfo Gender Concurrency
#> 1 187 Suffolk Ln., United States, Boise, ID Male 6.386847e+17
#> 2 2817 Milton Dr., United States, Albuquerque, NM Male 6.386847e+17
#> 3 NULL Male 6.386847e+17
#> 4 89 Jefferson Way Suite 2, United States, Portland, WA Male 6.386847e+17
#> 5 NULL Male 6.386847e+17
#> 6 55 Grizzly Peak Rd., United States, Butte, MT Male 6.386847e+17
#> 7 NULL Male 6.386847e+17
#> 8 NULL Male 6.386847e+17
# Get all pages
people_entity$select("UserName", "FirstName", "LastName")$all()
#> UserName FirstName LastName
#> 1 russellwhyte Russell Whyte
#> 2 scottketchum Scott Ketchum
#> 3 ronaldmundy Ronald Mundy
#> 4 javieralfred Javier Alfred
#> 5 willieashmore Willie Ashmore
#> 6 vincentcalabrese Vincent Calabrese
#> 7 clydeguess Clyde Guess
#> 8 keithpinckney Keith Pinckney
#> 9 marshallgaray Marshall Garay
#> 10 ryantheriault Ryan Theriault
#> 11 elainestewart Elaine Stewart
#> 12 salliesampson Sallie Sampson
#> 13 jonirosales Joni Rosales
#> 14 georginabarlow Georgina Barlow
#> 15 angelhuffman Angel Huffman
#> 16 laurelosborn Laurel Osborn
#> 17 sandyosborn Sandy Osborn
#> 18 ursulabright Ursula Bright
#> 19 genevievereeves Genevieve Reeves
#> 20 kristakemp Krista Kemp
russellwhyte <- people_entity$get("russellwhyte")
first_person <- people_entity$top(1)$one()
head(first_person)
#> $UserName
#> [1] "russellwhyte"
#>
#> $FirstName
#> [1] "Russell"
#>
#> $LastName
#> [1] "Whyte"
#>
#> $Emails
#> [1] "[email protected]" "[email protected]"
#>
#> $AddressInfo
#> Address City.CountryRegion City.Name City.Region
#> 1 187 Suffolk Ln. United States Boise ID
#>
#> $Gender
#> [1] "Male"
russellwhyte_friends <- russellwhyte$path("Friends")
russellwhyte_friends$all()
#> UserName FirstName LastName Emails
#> 1 scottketchum Scott Ketchum [email protected]
#> 2 ronaldmundy Ronald Mundy [email protected], [email protected]
#> 3 javieralfred Javier Alfred [email protected], [email protected]
#> 4 angelhuffman Angel Huffman [email protected]
#> AddressInfo Gender Concurrency
#> 1 2817 Milton Dr., United States, Albuquerque, NM Male 6.386847e+17
#> 2 NULL Male 6.386847e+17
#> 3 89 Jefferson Way Suite 2, United States, Portland, WA Male 6.386847e+17
#> 4 NULL Female 6.386847e+17
get_nearest_airport <- service$func('GetNearestAirport')
get_nearest_airport(lat = 33, lon = -118)
#> $IcaoCode
#> [1] "KLAX"
#>
#> $Name
#> [1] "Los Angeles International Airport"
#>
#> $IataCode
#> [1] "LAX"
#>
#> $Location
#> $Location$Address
#> [1] "1 World Way, Los Angeles, CA, 90045"
#>
#> $Location$City
#> $Location$City$CountryRegion
#> [1] "United States"
#>
#> $Location$City$Name
#> [1] "Los Angeles"
#>
#> $Location$City$Region
#> [1] "California"
#>
#>
#> $Location$Loc
#> $Location$Loc$type
#> [1] "Point"
#>
#> $Location$Loc$coordinates
#> [1] -118.4081 33.9425
#>
#> $Location$Loc$crs
#> $Location$Loc$crs$type
#> [1] "name"
#>
#> $Location$Loc$crs$properties
#> $Location$Loc$crs$properties$name
#> [1] "EPSG:4326"
people_query <- people_entity$
top(5)$
select('FirstName', 'LastName')$
filter(Concurrency.gt = 500)$
expand('Friends($count=true)')$
orderby('LastName')
people_query$all()
#> FirstName LastName [email protected]
#> 1 Javier Alfred 3
#> 2 Willie Ashmore 2
#> 3 Georgina Barlow 1
#> 4 Ursula Bright 1
#> 5 Vincent Calabrese 2
#> Friends
#> 1 willieashmore, vincentcalabrese, georginabarlow, Willie, Vincent, Georgina, Ashmore, Calabrese, Barlow, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], 55 Grizzly Peak Rd., United States, Butte, MT, Male, Male, Female, 638684672126977408, 638684672126977408, 638684672126977408
#> 2 javieralfred, vincentcalabrese, Javier, Vincent, Alfred, Calabrese, [email protected], [email protected], [email protected], [email protected], 89 Jefferson Way Suite 2, United States, Portland, WA, 55 Grizzly Peak Rd., United States, Butte, MT, Male, Male, 638684672126977408, 638684672126977408
#> 3 javieralfred, Javier, Alfred, [email protected], [email protected], 89 Jefferson Way Suite 2, United States, Portland, WA, Male, 638684672126977408
#> 4 keithpinckney, Keith, Pinckney, [email protected], [email protected], Male, 638684672126977408
#> 5 javieralfred, willieashmore, Javier, Willie, Alfred, Ashmore, [email protected], [email protected], [email protected], [email protected], 89 Jefferson Way Suite 2, United States, Portland, WA, Male, Male, 638684672126977408, 638684672126977408
Connecting with older OData v2 works, but some features have been changed.