En esta sección encontrará ejemplos de como consumir nuestra API en los lenguajes de programación más populares, así como, tips y trucos que le ayudarán a comenzar rápidamente.
Ejemplos de como consumir la API de búsqueda con los lenguajes de programación más populares para Backend y Frontend.
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept-Encoding: application/gzip");
headers = curl_slist_append(headers, "X-AibcomAPI-Key: AQUI-VA-TU-API-KEY");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR" {:headers {:Accept-Encoding "application/gzip"
:X-AibcomAPI-Key "AQUI-VA-TU-API-KEY"}})
var client = new RestClient("https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR");
var request = new RestRequest(Method.GET);
request.AddHeader("Accept-Encoding", "application/gzip");
request.AddHeader("X-AibcomAPI-Key", "AQUI-VA-TU-API-KEY");
IRestResponse response = client.Execute(request);
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR"),
Headers =
{
{ "X-AibcomAPI-Key", "AQUI-VA-TU-API-KEY" },
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Accept-Encoding", "application/gzip")
req.Header.Add("X-AibcomAPI-Key", "AQUI-VA-TU-API-KEY")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /language/translate/v2/languages HTTP/1.1
Accept-Encoding: application/gzip
X-AibcomAPI-Key: AQUI-VA-TU-API-KEY
Host: google-translate1.p.rapidapi.com
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR")
.get()
.addHeader("Accept-Encoding", "application/gzip")
.addHeader("X-AibcomAPI-Key", "AQUI-VA-TU-API-KEY")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR")
.header("Accept-Encoding", "application/gzip")
.header("X-AibcomAPI-Key", "AQUI-VA-TU-API-KEY")
.asString();
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR")
.setHeader("Accept-Encoding", "application/gzip")
.setHeader("X-AibcomAPI-Key", "AQUI-VA-TU-API-KEY")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR"))
.header("Accept-Encoding", "application/gzip")
.header("X-AibcomAPI-Key", "AQUI-VA-TU-API-KEY")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
const settings = {
"async": true,
"crossDomain": true,
"url": "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR",
"method": "GET",
"headers": {
"Accept-Encoding": "application/gzip",
"X-AibcomAPI-Key": "AQUI-VA-TU-API-KEY"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
const options = {
method: 'GET',
headers: {
'Accept-Encoding': 'application/gzip',
'X-AibcomAPI-Key': 'AQUI-VA-TU-API-KEY'
}
};
fetch('https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR");
xhr.setRequestHeader("Accept-Encoding", "application/gzip");
xhr.setRequestHeader("X-AibcomAPI-Key", "AQUI-VA-TU-API-KEY");
xhr.send(data);
import axios from "axios";
const options = {
method: 'GET',
url: 'https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR',
headers: {
'Accept-Encoding': 'application/gzip',
'X-AibcomAPI-Key': 'AQUI-VA-TU-API-KEY'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR")
.get()
.addHeader("Accept-Encoding", "application/gzip")
.addHeader("X-AibcomAPI-Key", "AQUI-VA-TU-API-KEY")
.build()
val response = client.newCall(request).execute()
const http = require("https");
const options = {
"method": "GET",
"hostname": "google-translate1.p.rapidapi.com",
"port": null,
"path": "/language/translate/v2/languages",
"headers": {
"Accept-Encoding": "application/gzip",
"X-AibcomAPI-Key": "AQUI-VA-TU-API-KEY",
"useQueryString": true
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'GET',
url: 'https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR',
headers: {
'Accept-Encoding': 'application/gzip',
'X-AibcomAPI-Key': 'AQUI-VA-TU-API-KEY',
useQueryString: true
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require("unirest");
const req = unirest("GET", "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR");
req.headers({
"Accept-Encoding": "application/gzip",
"X-AibcomAPI-Key": "AQUI-VA-TU-API-KEY",
"useQueryString": true
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require("axios");
const options = {
method: 'GET',
url: 'https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR',
headers: {
'Accept-Encoding': 'application/gzip',
'X-AibcomAPI-Key': 'AQUI-VA-TU-API-KEY'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
const fetch = require('node-fetch');
const url = 'https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR';
const options = {
method: 'GET',
headers: {
'Accept-Encoding': 'application/gzip',
'X-AibcomAPI-Key': 'AQUI-VA-TU-API-KEY'
}
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error('error:' + err));
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Accept-Encoding": @"application/gzip",
@"X-AibcomAPI-Key": @"AQUI-VA-TU-API-KEY" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Accept-Encoding: application/gzip",
"X-AibcomAPI-Key: AQUI-VA-TU-API-KEY"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
$request = new HttpRequest();
$request->setUrl('https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders([
'Accept-Encoding' => 'application/gzip',
'X-AibcomAPI-Key' => 'AQUI-VA-TU-API-KEY'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR');
$request->setRequestMethod('GET');
$request->setHeaders([
'Accept-Encoding' => 'application/gzip',
'X-AibcomAPI-Key' => 'AQUI-VA-TU-API-KEY'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
import http.client
conn = http.client.HTTPSConnection("api.aibcom.com.mx")
headers = {
'Accept-Encoding': "application/gzip",
'X-AibcomAPI-Key': "AQUI-VA-TU-API-KEY"
}
conn.request("GET", "/search?q=name:EL NOMBRE A BUSCAR", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR"
headers = {
"Accept-Encoding": "application/gzip",
"X-AibcomAPI-Key": "AQUI-VA-TU-API-KEY"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
library(httr)
url <- "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR"
response <- VERB("GET", url, add_headers('Accept-Encoding' = 'application/gzip', 'X-AibcomAPI-Key' = 'AQUI-VA-TU-API-KEY'), content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["Accept-Encoding"] = 'application/gzip'
request["X-AibcomAPI-Key"] = 'AQUI-VA-TU-API-KEY'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"Accept-Encoding": "application/gzip",
"X-AibcomAPI-Key": "AQUI-VA-TU-API-KEY"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
curl --request GET \
--url https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR \
--header 'Accept-Encoding: application/gzip' \
--header 'X-AibcomAPI-Key: AQUI-VA-TU-API-KEY'
http GET https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR \
Accept-Encoding:application/gzip \
X-AibcomAPI-Key:AQUI-VA-TU-API-KEY
wget --quiet \
--method GET \
--header 'Accept-Encoding: application/gzip' \
--header 'X-AibcomAPI-Key: AQUI-VA-TU-API-KEY' \
--output-document \
- https://api.aibcom.com.mx/search?q=name:EL NOMBRE A BUSCAR