Manual Wrapping
Manual wrapping Universe API
How to use
Using other language
curl -X GET "https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?" \
-H "Authorization: Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX" \
-H "Content-Type: application/json"
import requests
url = "https://api.universebot.space/v1/ai/openai/gpt4/model1"
headers = {
"Authorization": "Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX",
"Content-Type": "application/json"
}
params = {
"prompt": "What is Galaxy Universe?"
}
response = requests.get(url, headers=headers, params=params)
print(response.json())
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX");
con.setRequestProperty("Content-Type", "application/json");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
}
}
#include <iostream>
#include <curl/curl.h>
int main() {
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, "Authorization: Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, "Content-Type: application/json");
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
}
curl_easy_cleanup(curl);
}
return 0;
}
require 'net/http'
require 'uri'
require 'json'
url = URI("https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX"
request["Content-Type"] = "application/json"
response = http.request(request)
puts JSON.parse(response.read_body)
<?php
$url = "https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?";
$headers = [
"Authorization: Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX",
"Content-Type: application/json"
];
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Authorization", "Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(body))
}
import Foundation
let url = URL(string: "https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?")
var request = URLRequest(url: url!)
request.setValue("Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data, error == nil else {
print("Error:", error ?? "Unknown error")
return
}
if let httpResponse = response as? HTTPURLResponse {
if (200...299).contains(httpResponse.statusCode) {
if let responseData = String(data: data, encoding: .utf8) {
print(responseData)
}
} else {
print("HTTP Response Error:", httpResponse.statusCode)
}
}
}
task.resume()
use reqwest;
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let url = "https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?";
let client = reqwest::Client::new();
let res = client.get(url)
.header("Authorization", "Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX")
.header("Content-Type", "application/json")
.send()
.await?;
let body = res.text().await?;
println!("{}", body);
Ok(())
}
import com.github.kittinunf.fuel.httpGet
fun main() {
val url = "https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?"
val (request, response, result) = url
.httpGet()
.header("Authorization" to "Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX")
.header("Content-Type" to "application/json")
.responseString()
result.fold(
success = { data -> println(data) },
failure = { error -> println("Error fetching data: ${error.message}") }
)
}
use LWP::UserAgent;
my $url = "https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?";
my $ua = LWP::UserAgent->new;
$ua->default_header("Authorization" => "Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX");
$ua->default_header("Content-Type" => "application/json");
my $response = $ua->get($url);
if ($response->is_success) {
print $response->decoded_content;
} else {
die "Error fetching data: " . $response->status_line;
}
import scalaj.http.Http
object Main extends App {
val url = "https://api.universebot.space/v1/ai/openai/gpt4/model1?prompt=What+is+Galaxy+Universe?"
val response = Http(url)
.header("Authorization", "Bearer UniverseAPI.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX.XXXXXXXXXXXXX")
.header("Content-Type", "application/json")
.asString
if (response.is2xx) {
println(response.body)
} else {
println("Error fetching data: " + response.code)
}
}
Response
{
"status": true,
"code": 200,
"speed": "string",
"author": "string",
"message": "string",
"data": "object"
}
{
"status": false,
"code": 403,
"speed": "string",
"author": "string",
"message": "string",
"data": null
}
{
"status": false,
"code": 404,
"speed": "string",
"author": "string",
"message": "string",
"data": null
}
{
"status": false,
"code": 429,
"speed": "string",
"author": "string",
"message": "string",
"data": null
}
{
"status": false,
"code": 500,
"speed": "string",
"author": "string",
"message": "string",
"data": null
}
Last updated