Class: ScrapeBadger::ChatGPTApi

Inherits:
Object
  • Object
show all
Defined in:
lib/scrapebadger/api/chat_gpt_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ChatGPTApi

Returns a new instance of ChatGPTApi.



19
20
21
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#chatgpt_ask_chatgpt_a_question(prompt, opts = {}) ⇒ Object

Ask ChatGPT a question Send a prompt to ChatGPT and get the answer plus the web sources it cited.

Parameters:

  • prompt (String)

    The prompt to send to ChatGPT (max 4096 characters).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :country (String)

    ISO-3166 alpha-2 egress country, e.g. 'US', 'GB', 'DE'.

  • :web_search (String)

    auto (let ChatGPT decide) | force (ask it to browse) | off (answer from memory). `web_search_triggered` in the response always reports what actually happened. (default to 'auto')

Returns:

  • (Object)


29
30
31
32
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 29

def chatgpt_ask_chatgpt_a_question(prompt, opts = {})
  data, _status_code, _headers = chatgpt_ask_chatgpt_a_question_with_http_info(prompt, opts)
  data
end

#chatgpt_ask_chatgpt_a_question_post(opts = {}) ⇒ Object

Ask ChatGPT a question (POST) POST form of /ask, for prompts too long for a query string.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


96
97
98
99
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 96

def chatgpt_ask_chatgpt_a_question_post(opts = {})
  data, _status_code, _headers = chatgpt_ask_chatgpt_a_question_post_with_http_info(opts)
  data
end

#chatgpt_ask_chatgpt_a_question_post_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>

Ask ChatGPT a question (POST) POST form of `/ask`, for prompts too long for a query string.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 105

def chatgpt_ask_chatgpt_a_question_post_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChatGPTApi.chatgpt_ask_chatgpt_a_question_post ...'
  end
  # resource path
  local_var_path = '/v1/chatgpt/ask'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"ChatGPTApi.chatgpt_ask_chatgpt_a_question_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChatGPTApi#chatgpt_ask_chatgpt_a_question_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#chatgpt_ask_chatgpt_a_question_with_http_info(prompt, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Ask ChatGPT a question Send a prompt to ChatGPT and get the answer plus the web sources it cited.

Parameters:

  • prompt (String)

    The prompt to send to ChatGPT (max 4096 characters).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :country (String)

    ISO-3166 alpha-2 egress country, e.g. 'US', 'GB', 'DE'.

  • :web_search (String)

    auto (let ChatGPT decide) | force (ask it to browse) | off (answer from memory). `web_search_triggered` in the response always reports what actually happened. (default to 'auto')

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 41

def chatgpt_ask_chatgpt_a_question_with_http_info(prompt, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChatGPTApi.chatgpt_ask_chatgpt_a_question ...'
  end
  # verify the required parameter 'prompt' is set
  if @api_client.config.client_side_validation && prompt.nil?
    fail ArgumentError, "Missing the required parameter 'prompt' when calling ChatGPTApi.chatgpt_ask_chatgpt_a_question"
  end
  # resource path
  local_var_path = '/v1/chatgpt/ask'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'prompt'] = prompt
  query_params[:'country'] = opts[:'country'] if !opts[:'country'].nil?
  query_params[:'web_search'] = opts[:'web_search'] if !opts[:'web_search'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"ChatGPTApi.chatgpt_ask_chatgpt_a_question",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChatGPTApi#chatgpt_ask_chatgpt_a_question\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#chatgpt_chatgpt_scraper_health_check(opts = {}) ⇒ Object

ChatGPT scraper health check Check health of the ChatGPT scraper service (accepts HEAD).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


153
154
155
156
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 153

def chatgpt_chatgpt_scraper_health_check(opts = {})
  data, _status_code, _headers = chatgpt_chatgpt_scraper_health_check_with_http_info(opts)
  data
end

#chatgpt_chatgpt_scraper_health_check_head(opts = {}) ⇒ Object

ChatGPT scraper health check Check health of the ChatGPT scraper service (accepts HEAD).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


210
211
212
213
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 210

def chatgpt_chatgpt_scraper_health_check_head(opts = {})
  data, _status_code, _headers = chatgpt_chatgpt_scraper_health_check_head_with_http_info(opts)
  data
end

#chatgpt_chatgpt_scraper_health_check_head_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>

ChatGPT scraper health check Check health of the ChatGPT scraper service (accepts HEAD).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 219

def chatgpt_chatgpt_scraper_health_check_head_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChatGPTApi.chatgpt_chatgpt_scraper_health_check_head ...'
  end
  # resource path
  local_var_path = '/v1/chatgpt/health'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"ChatGPTApi.chatgpt_chatgpt_scraper_health_check_head",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:HEAD, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChatGPTApi#chatgpt_chatgpt_scraper_health_check_head\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#chatgpt_chatgpt_scraper_health_check_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>

ChatGPT scraper health check Check health of the ChatGPT scraper service (accepts HEAD).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 162

def chatgpt_chatgpt_scraper_health_check_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChatGPTApi.chatgpt_chatgpt_scraper_health_check ...'
  end
  # resource path
  local_var_path = '/v1/chatgpt/health'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"ChatGPTApi.chatgpt_chatgpt_scraper_health_check",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChatGPTApi#chatgpt_chatgpt_scraper_health_check\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#chatgpt_list_chatgpt_models(opts = {}) ⇒ Object

List ChatGPT models Models chatgpt.com currently serves to an anonymous visitor.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :country (String)

    ISO-3166 alpha-2 egress country.

Returns:

  • (Object)


268
269
270
271
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 268

def chatgpt_list_chatgpt_models(opts = {})
  data, _status_code, _headers = chatgpt_list_chatgpt_models_with_http_info(opts)
  data
end

#chatgpt_list_chatgpt_models_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>

List ChatGPT models Models chatgpt.com currently serves to an anonymous visitor.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :country (String)

    ISO-3166 alpha-2 egress country.

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 278

def chatgpt_list_chatgpt_models_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChatGPTApi.chatgpt_list_chatgpt_models ...'
  end
  # resource path
  local_var_path = '/v1/chatgpt/models'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'country'] = opts[:'country'] if !opts[:'country'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"ChatGPTApi.chatgpt_list_chatgpt_models",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChatGPTApi#chatgpt_list_chatgpt_models\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer(prompt, brand, opts = {}) ⇒ Object

Measure a brand's visibility in a ChatGPT answer Ask ChatGPT, then report whether the brand is mentioned, cited and how prominently.

Parameters:

  • prompt (String)

    The prompt to ask ChatGPT.

  • brand (String)

    Brand name to look for in the answer.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :domain (String)

    Brand domain, for citation matching.

  • :aliases (String)

    Comma-separated alternative names.

  • :competitors (String)

    Comma-separated competitor names.

  • :country (String)

    ISO-3166 alpha-2 egress country.

  • :web_search (String)

    auto | force | off (default to 'force')

Returns:

  • (Object)


334
335
336
337
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 334

def chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer(prompt, brand, opts = {})
  data, _status_code, _headers = chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_with_http_info(prompt, brand, opts)
  data
end

#chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_post(opts = {}) ⇒ Object

Measure a brand's visibility in a ChatGPT answer (POST) POST form, for longer prompts and larger competitor sets.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


413
414
415
416
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 413

def chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_post(opts = {})
  data, _status_code, _headers = chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_post_with_http_info(opts)
  data
end

#chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_post_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>

Measure a brand's visibility in a ChatGPT answer (POST) POST form, for longer prompts and larger competitor sets.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 422

def chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_post_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChatGPTApi.chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_post ...'
  end
  # resource path
  local_var_path = '/v1/chatgpt/brand-visibility'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"ChatGPTApi.chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChatGPTApi#chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_with_http_info(prompt, brand, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Measure a brand's visibility in a ChatGPT answer Ask ChatGPT, then report whether the brand is mentioned, cited and how prominently.

Parameters:

  • prompt (String)

    The prompt to ask ChatGPT.

  • brand (String)

    Brand name to look for in the answer.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :domain (String)

    Brand domain, for citation matching.

  • :aliases (String)

    Comma-separated alternative names.

  • :competitors (String)

    Comma-separated competitor names.

  • :country (String)

    ISO-3166 alpha-2 egress country.

  • :web_search (String)

    auto | force | off (default to 'force')

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/scrapebadger/api/chat_gpt_api.rb', line 350

def chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer_with_http_info(prompt, brand, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ChatGPTApi.chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer ...'
  end
  # verify the required parameter 'prompt' is set
  if @api_client.config.client_side_validation && prompt.nil?
    fail ArgumentError, "Missing the required parameter 'prompt' when calling ChatGPTApi.chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer"
  end
  # verify the required parameter 'brand' is set
  if @api_client.config.client_side_validation && brand.nil?
    fail ArgumentError, "Missing the required parameter 'brand' when calling ChatGPTApi.chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer"
  end
  # resource path
  local_var_path = '/v1/chatgpt/brand-visibility'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'prompt'] = prompt
  query_params[:'brand'] = brand
  query_params[:'domain'] = opts[:'domain'] if !opts[:'domain'].nil?
  query_params[:'aliases'] = opts[:'aliases'] if !opts[:'aliases'].nil?
  query_params[:'competitors'] = opts[:'competitors'] if !opts[:'competitors'].nil?
  query_params[:'country'] = opts[:'country'] if !opts[:'country'].nil?
  query_params[:'web_search'] = opts[:'web_search'] if !opts[:'web_search'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"ChatGPTApi.chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ChatGPTApi#chatgpt_measure_a_brand_s_visibility_in_a_chatgpt_answer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end