# redivis$make\_api\_request

### **redivis$**<mark style="color:purple;">**make\_api\_request**</mark>**(*****\*, method, path, query, payload, ...*****)** → **list | NULL**

Initiates an authenticated HTTP request to the [Redivis API](https://docs.redivis.com/api/rest-api).&#x20;

If `parse_response=TRUE` (the default) the result will be a named list corresponding to the API endpoint's JSON response, or `None` if the response is empty. Otherwise, returns a [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) object.

{% hint style="warning" %}
In most cases, you should use the various other methods in the redivis python library, rather than interfacing with the API directly, as these methods are far more user-friendly and cover the vast majority of the REST API.

However, in certain advanced cases, it may make sense to call API endpoint directly through this method.
{% endhint %}

### **Parameters:**

**`method` :&#x20;*****str {"GET"*****&#x20;|&#x20;*****"POST" | "PATCH" | "PUT" | "HEAD" | "DELETE" }, default "GET"***\
The HTTP method of the request. Defaults to "GET"

**`path` :&#x20;*****str, default ""***\
The API path, including the leading forward slash. E.g.: `"/organizations/demo/datasets"`

**`query` :&#x20;*****list***\
An optional named list of query parameters to add to the path

**`payload` :&#x20;*****list***\
An optional payload to include with the request. Must be a named list that will be converted to a JSON string.

**`headers` :&#x20;*****list***\
An optional named list of additional headers to include in the request. Note that authentication is already handled, and there is no need to provide API credentials in the headers when using this method.

**`parse_response` :&#x20;*****bool, default TRUE***\
Whether to parse the API JSON response into a named list. Typically should be set to TRUE, unless the API endpoint doesn't return JSON.

**`stream_callback` :&#x20;*****function***\
For advanced use cases. If provided, the response will by streamed in binary chunks passed to the stream\_callback function.

### **Returns:**

list | NULL

### Examples

```r
# Calls the dataset.list endpoint
# See the REST API documentation for details on the response schema for each endpoint
json_response <- redivis$make_api_request(
    method="GET", 
    path="/organizations/demo/datasets", 
    query=list(maxResults="10")
)
```
