1
1
import Authorization from ' @docs/shared/common/channel-management-api/authorization.mdx' ;
2
+ import Tabs from ' @theme/Tabs' ;
3
+ import TabItem from ' @theme/TabItem' ;
2
4
import CodeBlock from ' @theme/CodeBlock' ;
3
- import MultiCodeBlock , { CodeGroup , CodeItem } from ' @app/mdx-components/MultiCodeBlock' ;
4
5
5
6
When using Agora real-time audio and video, you can use the <Vg k = " NCS_LONG" /> service to receive channel events.
6
7
@@ -25,75 +26,16 @@ Agora occasionally adjusts the <Vg k="NCS_LONG" /> IP addresses. Best practice i
25
26
26
27
Use one of the following code examples to test this request:
27
28
28
- <MultiCodeBlock caption = " Sample request:" >
29
-
30
- <CodeGroup label = " Shell" >
31
- <CodeItem language = " shell" name = " curl" >{ ` curl --request GET \\
29
+ <Tabs groupId = " language" >
30
+ <TabItem value = " curl" label = " Curl" default >
31
+ <CodeBlock language = " bash" >{ ` curl --request GET \\
32
32
--url https://api.sd-rtn.com/v2/ncs/ip \\
33
33
--header 'Accept: application/json' \\
34
- --header 'Authorization: ' ` } </CodeItem >
35
- <CodeItem language = " shell" name = " HTTPie" >{ ` http GET https://api.sd-rtn.com/v2/ncs/ip \\
36
- Accept:application/json \\
37
- Authorization:'' ` } </CodeItem >
38
- <CodeItem language = " shell" name = " wget" >{ ` wget --quiet \\
39
- --method GET \\
40
- --header 'Authorization: ' \\
41
- --header 'Accept: application/json' \\
42
- --output-document \\
43
- \- https://api.sd-rtn.com/v2/ncs/ip ` } </CodeItem >
44
- </CodeGroup >
34
+ --header 'Authorization: ' ` } </CodeBlock >
35
+ </TabItem >
45
36
46
- <CodeGroup label = " Javascript" >
47
- <CodeItem language = " js" name = " Fetch" >{ ` const url = 'https://api.sd-rtn.com/v2/ncs/ip';
48
- const options = {method: 'GET', headers: {Authorization: '', Accept: 'application/json'}};\n
49
- try {
50
- const response = await fetch(url, options);
51
- const data = await response.json();
52
- console.log(data);
53
- } catch (error) {
54
- console.error(error);
55
- } ` } </CodeItem >
56
- <CodeItem language = " js" name = " XMLHTTPRequest" >{ ` const data = null;\n
57
- const xhr = new XMLHttpRequest();
58
- xhr.withCredentials = true;\n
59
- xhr.addEventListener('readystatechange', function () {
60
- if (this.readyState === this.DONE) {
61
- console.log(this.responseText);
62
- }
63
- });\n
64
- xhr.open('GET', 'https://api.sd-rtn.com/v2/ncs/ip');
65
- xhr.setRequestHeader('Authorization', '');
66
- xhr.setRequestHeader('Accept', 'application/json');\n
67
- xhr.send(data); ` } </CodeItem >
68
- <CodeItem language = " js" name = " jQuery" >{ ` const settings = {
69
- async: true,
70
- crossDomain: true,
71
- url: 'https://api.sd-rtn.com/v2/ncs/ip',
72
- method: 'GET',
73
- headers: {
74
- Authorization: '',
75
- Accept: 'application/json'
76
- }
77
- };\n
78
- $.ajax(settings).done(function (response) {
79
- console.log(response);
80
- }); ` } </CodeItem >
81
- <CodeItem language = " js" name = " Axios" >{ ` import axios from 'axios';\n
82
- const options = {
83
- method: 'GET',
84
- url: 'https://api.sd-rtn.com/v2/ncs/ip',
85
- headers: {Authorization: '', Accept: 'application/json'}
86
- };\n
87
- try {
88
- const { data } = await axios.request(options);
89
- console.log(data);
90
- } catch (error) {
91
- console.error(error);
92
- } ` } </CodeItem >
93
- </CodeGroup >
94
-
95
- <CodeGroup label = " Node" >
96
- <CodeItem language = " js" name = " Native" >{ ` const http = require('http');\n
37
+ <TabItem value = " node" label = " Node.js" >
38
+ <CodeBlock language = " js" >{ ` const http = require('http');\n
97
39
const options = {
98
40
method: 'GET',
99
41
hostname: 'api.sd-rtn.com',
@@ -114,53 +56,11 @@ const req = http.request(options, function (res) {
114
56
console.log(body.toString());
115
57
});
116
58
});\n
117
- req.end(); ` } </CodeItem >
118
- <CodeItem language = " js" name = " Request" >{ ` const request = require('request');\n
119
- const options = {
120
- method: 'GET',
121
- url: 'https://api.sd-rtn.com/v2/ncs/ip',
122
- headers: {Authorization: '', Accept: 'application/json'}
123
- };\n
124
- request(options, function (error, response, body) {
125
- if (error) throw new Error(error);\n
126
- console.log(body);
127
- }); ` } </CodeItem >
128
- <CodeItem language = " js" name = " Unirest" >{ ` const unirest = require('unirest');\n
129
- const req = unirest('GET', 'https://api.sd-rtn.com/v2/ncs/ip');\n
130
- req.headers({
131
- Authorization: '',
132
- Accept: 'application/json'
133
- });\n
134
- req.end(function (res) {
135
- if (res.error) throw new Error(res.error);\n
136
- console.log(res.body);
137
- }); ` } </CodeItem >
138
- <CodeItem language = " js" name = " Fetch" >{ ` const fetch = require('node-fetch');\n
139
- const url = 'https://api.sd-rtn.com/v2/ncs/ip';
140
- const options = {method: 'GET', headers: {Authorization: '', Accept: 'application/json'}};\n
141
- try {
142
- const response = await fetch(url, options);
143
- const data = await response.json();
144
- console.log(data);
145
- } catch (error) {
146
- console.error(error);
147
- } ` } </CodeItem >
148
- <CodeItem language = " js" name = " Axios" >{ ` const axios = require('axios').default;\n
149
- const options = {
150
- method: 'GET',
151
- url: 'https://api.sd-rtn.com/v2/ncs/ip',
152
- headers: {Authorization: '', Accept: 'application/json'}
153
- };\n
154
- try {
155
- const { data } = await axios.request(options);
156
- console.log(data);
157
- } catch (error) {
158
- console.error(error);
159
- } ` } </CodeItem >
160
- </CodeGroup >
59
+ req.end(); ` } </CodeBlock >
60
+ </TabItem >
161
61
162
- <CodeGroup label = " Python" >
163
- < CodeItem language = " python" name = " Python 3 " >{ ` import http.client\n
62
+ <TabItem value = " python " label = " Python" >
63
+ < CodeBlock language = " python" >{ ` import http.client\n
164
64
conn = http.client.HTTPConnection("api.sd-rtn.com")\n
165
65
headers = {
166
66
'Authorization': "",
@@ -169,228 +69,10 @@ headers = {
169
69
conn.request("GET", "/v2/ncs/ip", headers=headers)\n
170
70
res = conn.getresponse()
171
71
data = res.read()\n
172
- print(data.decode("utf-8")) ` } </CodeItem >
173
- <CodeItem language = " python" name = " Requests" >{ ` import requests\n
174
- url = "https://api.sd-rtn.com/v2/ncs/ip"\n
175
- headers = {
176
- "Authorization": "",
177
- "Accept": "application/json"
178
- }\n
179
- response = requests.get(url, headers=headers)\n
180
- print(response.json()) ` } </CodeItem >
181
- </CodeGroup >
182
-
183
- <CodeGroup label = " C#" >
184
- <CodeItem language = " csharp" name = " HTTPClient" >{ ` using System.Net.Http.Headers;
185
- var client = new HttpClient();
186
- var request = new HttpRequestMessage
187
- \{
188
- Method = HttpMethod.Get,
189
- RequestUri = new Uri("https://api.sd-rtn.com/v2/ncs/ip"),
190
- Headers =
191
- \{
192
- \{ "Authorization", "" },
193
- \{ "Accept", "application/json" },
194
- \} ,
195
- \} ;
196
- using (var response = await client.SendAsync(request))
197
- \{
198
- response.EnsureSuccessStatusCode();
199
- var body = await response.Content.ReadAsStringAsync();
200
- Console.WriteLine(body);
201
- \} ` } </CodeItem >
202
- <CodeItem language = " csharp" name = " RestSharp" >{ ` var client = new RestClient("https://api.sd-rtn.com/v2/ncs/ip");
203
- var request = new RestRequest(Method.GET);
204
- request.AddHeader("Authorization", "");
205
- request.AddHeader("Accept", "application/json");
206
- IRestResponse response = client.Execute(request); ` } </CodeItem >
207
- </CodeGroup >
208
-
209
- <CodeGroup label = " Java" >
210
- <CodeItem language = " java" name = " AsyncHttp" >{ ` AsyncHttpClient client = new DefaultAsyncHttpClient();
211
- client.prepare("GET", "https://api.sd-rtn.com/v2/ncs/ip")
212
- .setHeader("Authorization", "")
213
- .setHeader("Accept", "application/json")
214
- .execute()
215
- .toCompletableFuture()
216
- .thenAccept(System.out::println)
217
- .join();\n
218
- client.close(); ` } </CodeItem >
219
- <CodeItem language = " java" name = " NetHttp" >{ ` HttpRequest request = HttpRequest.newBuilder()
220
- .uri(URI.create("https://api.sd-rtn.com/v2/ncs/ip"))
221
- .header("Authorization", "")
222
- .header("Accept", "application/json")
223
- .method("GET", HttpRequest.BodyPublishers.noBody())
224
- .build();
225
- HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
226
- System.out.println(response.body()); ` } </CodeItem >
227
- <CodeItem language = " java" name = " OkHttp" >{ ` OkHttpClient client = new OkHttpClient();\n
228
- Request request = new Request.Builder()
229
- .url("https://api.sd-rtn.com/v2/ncs/ip")
230
- .get()
231
- .addHeader("Authorization", "")
232
- .addHeader("Accept", "application/json")
233
- .build();\n
234
- Response response = client.newCall(request).execute(); ` } </CodeItem >
235
- <CodeItem language = " java" name = " Unirest" >{ ` HttpResponse<String> response = Unirest.get("https://api.sd-rtn.com/v2/ncs/ip")
236
- .header("Authorization", "")
237
- .header("Accept", "application/json")
238
- .asString(); ` } </CodeItem >
239
- </CodeGroup >
240
-
241
- <CodeGroup label = " PHP" >
242
- <CodeItem language = " php" name = " cURL" >{ ` <?php\n
243
- $curl = curl_init();\n
244
- curl_setopt_array($curl, [
245
- CURLOPT_URL => "https://api.sd-rtn.com/v2/ncs/ip",
246
- CURLOPT_RETURNTRANSFER => true,
247
- CURLOPT_ENCODING => "",
248
- CURLOPT_MAXREDIRS => 10,
249
- CURLOPT_TIMEOUT => 30,
250
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
251
- CURLOPT_CUSTOMREQUEST => "GET",
252
- CURLOPT_HTTPHEADER => [
253
- "Accept: application/json",
254
- "Authorization: "
255
- ],
256
- ]);\n
257
- $response = curl_exec($curl);
258
- $err = curl_error($curl);\n
259
- curl_close($curl);\n
260
- if ($err) {
261
- echo "cURL Error #:" . $err;
262
- } else {
263
- echo $response;
264
- } ` } </CodeItem >
265
- <CodeItem language = " php" name = " Guzzle" >{ ` <?php\n
266
- $client = new GuzzleHttp\\ Client();\n
267
- $response = $client->request('GET', 'https://api.sd-rtn.com/v2/ncs/ip', [
268
- 'headers' => [
269
- 'Accept' => 'application/json',
270
- 'Authorization' => '',
271
- ],
272
- ]);\n
273
- echo $response->getBody(); ` } </CodeItem >
274
- </CodeGroup >
275
-
276
- <CodeGroup label = " PowerShell" >
277
- <CodeItem language = " shell" name = " WebRequest" >{ ` $headers=@{}
278
- $headers.Add("Authorization", "")
279
- $headers.Add("Accept", "application/json")
280
- $response = Invoke-WebRequest -Uri 'https://api.sd-rtn.com/v2/ncs/ip' -Method GET -Headers $headers ` } </CodeItem >
281
- <CodeItem language = " shell" name = " RestMethod" >{ ` $headers=@{}
282
- $headers.Add("Authorization", "")
283
- $headers.Add("Accept", "application/json")
284
- $response = Invoke-RestMethod -Uri 'https://api.sd-rtn.com/v2/ncs/ip' -Method GET -Headers $headers ` } </CodeItem >
285
- </CodeGroup >
286
-
287
- <CodeGroup label = " Other" >
288
- <CodeItem language = " go" name = " Go" >{ ` package main\n
289
- import (
290
- "fmt"
291
- "net/http"
292
- "io"
293
- )\n
294
- func main() {\n
295
- url := "https://api.sd-rtn.com/v2/ncs/ip"\n
296
- req, _ := http.NewRequest("GET", url, nil)\n
297
- req.Header.Add("Authorization", "")
298
- req.Header.Add("Accept", "application/json")\n
299
- res, _ := http.DefaultClient.Do(req)\n
300
- defer res.Body.Close()
301
- body, _ := io.ReadAll(res.Body)\n
302
- fmt.Println(res)
303
- fmt.Println(string(body))
304
- } ` } </CodeItem >
305
- <CodeItem language = " c" name = " C" >{ ` CURL *hnd = curl_easy_init();\n
306
- curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
307
- curl_easy_setopt(hnd, CURLOPT_URL, "https://api.sd-rtn.com/v2/ncs/ip");\n
308
- struct curl_slist *headers = NULL;
309
- headers = curl_slist_append(headers, "Authorization: ");
310
- headers = curl_slist_append(headers, "Accept: application/json");
311
- curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);\n
312
- CURLcode ret = curl_easy_perform(hnd); ` } </CodeItem >
313
- <CodeItem language = " objc" name = " Objective-C" >{ ` #import <Foundation/Foundation.h>\n
314
- NSDictionary *headers = @{ @"Authorization": @"",
315
- @"Accept": @"application/json" };\n
316
- NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.sd-rtn.com/v2/ncs/ip"]
317
- cachePolicy:NSURLRequestUseProtocolCachePolicy
318
- timeoutInterval:10.0];
319
- [request setHTTPMethod:@"GET"];
320
- [request setAllHTTPHeaderFields:headers];\n
321
- NSURLSession *session = [NSURLSession sharedSession];
322
- NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
323
- completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
324
- if (error) {
325
- NSLog(@"%@", error);
326
- } else {
327
- NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
328
- NSLog(@"%@", httpResponse);
329
- }
330
- }];
331
- [dataTask resume]; ` } </CodeItem >
332
- <CodeItem language = " ocaml" name = " OCaml" >{ ` open Cohttp_lwt_unix
333
- open Cohttp
334
- open Lwt\n
335
- let uri = Uri.of_string "https://api.sd-rtn.com/v2/ncs/ip" in
336
- let headers = Header.add_list (Header.init ()) [
337
- ("Authorization", "");
338
- ("Accept", "application/json");
339
- ] in\n
340
- Client.call ~headers \` GET uri
341
- \>\> = fun (res, body_stream) -\>
342
- \( * Do stuff with the result *) ` } </CodeItem >
343
- <CodeItem language = " http" name = " Http 1.1" >{ ` GET /v2/ncs/ip HTTP/1.1
344
- Authorization:
345
- Accept: application/json
346
- Host: api.sd-rtn.com ` } </CodeItem >
347
- <CodeItem language = " clojure" name = " Clojure" >{ ` (require '[clj-http.client :as client])\n
348
- (client/get "https://api.sd-rtn.com/v2/ncs/ip" {:headers {:Authorization ""}
349
- :accept :json}) ` } </CodeItem >
350
- <CodeItem language = " kotlin" name = " Kotlin" >{ ` val client = OkHttpClient()\n
351
- val request = Request.Builder()
352
- .url("https://api.sd-rtn.com/v2/ncs/ip")
353
- .get()
354
- .addHeader("Authorization", "")
355
- .addHeader("Accept", "application/json")
356
- .build()\n
357
- val response = client.newCall(request).execute() ` } </CodeItem >
358
- <CodeItem language = " r" name = " R" >{ ` library(httr)\n
359
- url <- "https://api.sd-rtn.com/v2/ncs/ip"\n
360
- response <- VERB("GET", url, add_headers('Authorization' = ''), content_type("application/octet-stream"), accept("application/json"))\n
361
- content(response, "text") ` } </CodeItem >
362
- <CodeItem language = " ruby" name = " Ruby" >{ ` require 'uri'
363
- require 'net/http'\n
364
- url = URI("https://api.sd-rtn.com/v2/ncs/ip")\n
365
- http = Net::HTTP.new(url.host, url.port)\n
366
- request = Net::HTTP::Get.new(url)
367
- request["Authorization"] = ''
368
- request["Accept"] = 'application/json'\n
369
- response = http.request(request)
370
- puts response.read_body ` } </CodeItem >
371
- <CodeItem language = " swift" name = " Swift" >{ ` import Foundation\n
372
- let headers = [
373
- "Authorization": "",
374
- "Accept": "application/json"
375
- ]\n
376
- let request = NSMutableURLRequest(url: NSURL(string: "https://api.sd-rtn.com/v2/ncs/ip")! as URL,
377
- cachePolicy: .useProtocolCachePolicy,
378
- timeoutInterval: 10.0)
379
- request.httpMethod = "GET"
380
- request.allHTTPHeaderFields = headers\n
381
- let session = URLSession.shared
382
- let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
383
- if (error != nil) {
384
- print(error as Any)
385
- } else {
386
- let httpResponse = response as? HTTPURLResponse
387
- print(httpResponse)
388
- }
389
- })\n
390
- dataTask.resume() ` } </CodeItem >
391
- </CodeGroup >
72
+ print(data.decode("utf-8")) ` } </CodeBlock >
73
+ </TabItem >
392
74
393
- </MultiCodeBlock >
75
+ </Tabs >
394
76
395
77
### Response parameters
396
78
0 commit comments