Skip to content

Commit

Permalink
Added code for Node SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
codingis4noobs2 authored Oct 30, 2023
1 parent d47022f commit 1f70dff
Showing 1 changed file with 152 additions and 2 deletions.
154 changes: 152 additions & 2 deletions api-reference/subscribers/get-subscribers.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,155 @@
---
openapi: get /v1/subscribers
openapi: get /v1/subscribers/{subscriberId}
---

<Snippet file="apikey-warning.mdx" />
<Snippet file="apikey-warning.mdx" />

<RequestExample>

```javascript Node.js
import { Novu } from '@novu/node';

const novu = new Novu("<NOVU_API_KEY>");

const response = await novu.subscribers.get("subscriberId");
console.log(response.data);
```

```bash cURL
curl --request GET \
--url https://api.novu.co/v1/subscribers \
--header 'Authorization: <authorization>'
```

```python Python
import requests

url = "https://api.novu.co/v1/subscribers"

headers = {"Authorization": "<authorization>"}

response = requests.request("GET", url, headers=headers)

print(response.text)
```

```js JavaScript
const options = {method: 'GET', headers: {Authorization: '<authorization>'}};

fetch('https://api.novu.co/v1/subscribers', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
```

```php PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.novu.co/v1/subscribers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
```

```go Go
package main

import (
"fmt"
"net/http"
"io/ioutil"
)

func main() {

url := "https://api.novu.co/v1/subscribers"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "<authorization>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res)
fmt.Println(string(body))

}
```

```java Java
HttpResponse<String> response = Unirest.get("https://api.novu.co/v1/subscribers")
.header("Authorization", "<authorization>")
.asString();
```

</RequestExample>

<ResponseExample>

```json Response
{
"data": [
{
"__v": "number",
"_environmentId": "string",
"_id": "string",
"_organizationId": "string",
"avatar": "string",
"channels": [
{
"_integrationId": "string",
"credentials": {
"channel": "string",
"deviceTokens": [
"string"
],
"webhookUrl": "string"
},
"integrationIdentifier": "string",
"providerId": "slack"
}
],
"createdAt": "string",
"deleted": "boolean",
"email": "string",
"firstName": "string",
"isOnline": "boolean",
"lastName": "string",
"lastOnlineAt": "string",
"locale": "string",
"phone": "string",
"subscriberId": "string",
"updatedAt": "string"
}
],
"hasMore": "boolean",
"page": "number",
"pageSize": "number"
}
```

</ResponseExample>

0 comments on commit 1f70dff

Please sign in to comment.