pg.get: PostgREST GET

Description Usage Arguments Value Examples

Description

RESTful GET for PostgREST resources.

Usage

1
2
3
pg.get(domain = "https://postgrest.herokuapp.com", table = "",
  select = "", filter = "", limit = "", order = "",
  pg.filter.syntax = FALSE, url.only = FALSE, encoding = "UTF-8", ...)

Arguments

domain

The root of the PostgREST server. E.g. https://postgrest.herokuapp.com

table

The table you are querying. Can be an empty string ("") for default root table listing.

select

Character vector or comma separated string of columns to return (optional)

filter

Character vector or comma separated string of filter expressions in R syntax or PostgREST syntax when pg.filter.syntax == TRUE.

limit

Integer limiting the number of records returned from the API.

order

Character vector or comma separated string of columns to sort by. Ascending by default, otherwise wrap the column in desc() to sort by descending.

pg.filter.syntax

Boolean indicating whether your filter expression is in PostgREST filter syntax or not. Defaults to FALSE using R expressions.

url.only

Boolean when TRUE returns the URL built and does not call the API. Useful for debugging purposes. Defaults to FALSE.

encoding

Character passed to content. Defaults to UTF-8

...

Extra parameters passed to GET. e.g. config = add_headers(custom_header="hello world")

Value

data.frame of your response

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
domain <- "https://postgrest.herokuapp.com"

pg.get(domain, "speakers", limit = 5,
	filter = c("id >= 228", "featured == TRUE"))

pg.get(domain, "speakers", filter = "id=eq.228",
	pg.filter.syntax = TRUE)

# All of the below give the same result
pg.get(domain, "speakers", filter = "id in (228,161)")
pg.get(domain, "speakers", filter = "id %in% (228,161)")
pg.get(domain, "speakers", filter = "id in c(228,161)")
pg.get(domain, "speakers", filter = "id %in% c(228,161)")

# View table list
pg.get(domain)

# View the URL that will be called for debugging purposes
pg.get(domain, "speakers", select = "id,name,bio",
	limit = 2, filter = "id in (228,161),featured == TRUE",
	url.only = TRUE)

clesiemo3/postgrestR documentation built on May 13, 2019, 8 p.m.